Python 在github操作上为Django设置Postgres
我一直在尝试设置工作流以测试Django应用程序,但设置工作流时遇到问题: 到目前为止,我已经创建了:Python 在github操作上为Django设置Postgres,python,django,github,github-actions,Python,Django,Github,Github Actions,我一直在尝试设置工作流以测试Django应用程序,但设置工作流时遇到问题: 到目前为止,我已经创建了: name: Django CI on: push: branches: [ master ] pull_request: branches: [ master ] jobs: build: runs-on: ubuntu-latest strategy: max-parallel: 4 matrix: d
name: Django CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
db: [postgres]
python-version: [3.7, 3.8]
include:
- db: postgres
db_port: 5432
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
env:
SECRET_KEY: vz@h6kziphf$m&xxu4$dfe4bt6h8_a_!^54yup$rk*_93d1x+h
DEV_ENV: dev
DB_NAME: ${{ matrix.db }}
DB_HOST: 127.0.0.1
DB_USER: postgres
DB_PASSWORD: password
DB_PORT: ${{ matrix.db_port }}
run: |
python manage.py test test user.tests.test_models
在我的设置文件中,我有:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': config('DB_NAME'),
'USER': config('DB_USER'),
'PASSWORD': config('DB_PASSWORD'),
'HOST': config('DB_HOST', default='localhost'),
'PORT':config('DB_PORT')
}
}
运行此管道大约需要20分钟,但会出现线程错误。我想知道什么是正确的设置方法,这样我就可以运行我的测试了