【问题标题】:Run django on background for action在后台运行 django 以进行操作
【发布时间】:2021-12-03 08:43:20
【问题描述】:

我正在尝试使用 Github Actions 测试我的 react 应用程序,我需要让 Django 运行一些测试,但是 Django 有

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
October 15, 2021 - 03:32:25
Django version 3.2.6, using settings 'controller.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

锁定 bash 的消息,有什么想法可以在动作中启动 Django 以便动作继续运行吗?

这是我目前的操作

name: CI
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

  workflow_dispatch:

jobs:
  tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Installing dependecies
        run:
          ./install.sh
        shell:
          bash
      - name: Testing backend
        run:
          ./backend-test.sh
        shell:
          bash
      - name: Starting backend
        run:
          ./backend.sh > /dev/null 2>&1
        shell:
          bash
      - name: Testing frontend
        run:
          ./frontend-test.sh
        shell:
          bash

而 backend.sh 会这样做

# Backend test script
cd backend/ && \
    sudo service postgresql start && \
    source .venv/bin/activate && \
    python3 manage.py test

【问题讨论】:

  • 您可以使用 linux screen 在单独的 shell 中运行 django stackoverflow.com/a/10656252/11225821
  • 所以这是您遇到问题的前端测试? backend.shfrontend-test.sh 中有什么内容?

标签: django bash github-actions


【解决方案1】:

您应该在运行 backend.sh 脚本的命令末尾添加& 以在后台运行它。进程 ID 将打印到屏幕上,您可以运行其他脚本/命令

- name: Starting backend
  run:
    ./backend.sh > /dev/null 2>&1 &
  shell:
    bash

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-20
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    相关资源
    最近更新 更多