-
Notifications
You must be signed in to change notification settings - Fork 3
70 lines (56 loc) · 2.26 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
name: Backend Tests
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
pull_request:
paths:
- "backend/**"
- ".github/workflows/test-backend.yml"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
runs-on: ubuntu-18.04
env:
working-directory: ./backend
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.8.10" # using SemVer's version range syntax
architecture: "x64"
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python Packages
working-directory: ${{ env.working-directory }}
run: |
sudo apt-get install python3-setuptools
pip3 install wheel
pip3 install -r deploy/requirements.txt
- name: Create secret.key
working-directory: ${{ env.working-directory }}
run: echo `cat /dev/urandom | head -1 | md5sum | head -c 32` > data/config/secret.key
- name: Create Demo Database
working-directory: ${{ env.working-directory }}
run: |
docker run -it -d -p 127.0.0.1:5432:5432 -e POSTGRES_DB=codingplatform -e POSTGRES_USER=codingplatform -e POSTGRES_PASSWORD=codingplatform --name db postgres:12-alpine
docker run -it -d -p 127.0.0.1:6379:6379 --name redis redis:4.0-alpine
- name: Migrate Database
working-directory: ${{ env.working-directory }}
run: python3 manage.py migrate
- name: Docker Containers List
run: docker ps -a
- name: Check Python Code Style
working-directory: ${{ env.working-directory }}
run: python3 -m flake8 .
- name: Django Test
working-directory: ${{ env.working-directory }}
run: python3 -m coverage run --include="$PWD/*" manage.py test
- name: Result of Django Test
working-directory: ${{ env.working-directory }}
run: python3 -m coverage report