-
Notifications
You must be signed in to change notification settings - Fork 4
95 lines (80 loc) · 2.77 KB
/
test_backend.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: test_backend
on: [push]
jobs:
test_backend:
runs-on: ubuntu-latest
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: quiz_anthropocene
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/checkout@v2
- name: Install Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install pip and pipenv
run: |
python -m pip install --upgrade pip
pip install --upgrade pipenv
- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('Pipfile.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache pipenv
uses: actions/cache@v2
with:
path: ~/.cache/pipenv
key: ${{ runner.os }}-pipenv-${{ hashFiles('Pipfile.lock') }}
restore-keys: |
${{ runner.os }}-pipenv-
- name: Cache pip-tools
uses: actions/cache@v2
with:
path: ~/.cache/pip-tools
key: ${{ runner.os }}-piptools-${{ hashFiles('**/Pipfile.lock') }}
restore-keys: |
${{ runner.os }}-piptools-
- name: Cache virtualenv
id: cache-venv
uses: actions/cache@v2
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-venv-${{ hashFiles('**/Pipfile.lock') }}
- name: Install python dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
pipenv sync --dev
- name: Run flake8 linting
run: pipenv run python -m flake8
- name: Run tests
run: pipenv run python manage.py test
env:
DEBUG: True
SECRET_KEY: github_workflow
HOST: localhost
DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/quiz_anthropocene
SESSION_COOKIE_SECURE: "False"
CSRF_COOKIE_SECURE: "False"
SECURE_HSTS_SECONDS: 0
SECURE_SSL_REDIRECT: "False"