generated from codersforcauses/django-nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 4
109 lines (93 loc) · 2.89 KB
/
ci-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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Backend code checks
on:
push:
branches: [main]
pull_request:
types: ["opened", "synchronize", "reopened", "edited"]
workflow_dispatch:
jobs:
lint:
name: Run Flake8
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Set up Python"
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: "Install flake8"
run: pip install flake8
- name: "Install flake8-django"
run: pip install flake8-django
- name: "Run flake8"
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: flake8
run: flake8 --max-line-length 150 server/
build:
name: Build and test
runs-on: ubuntu-latest
defaults:
run:
working-directory: server
services:
db:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: github-actions
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python Env
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Setup Poetry 🏗
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Cache .venv 📦
id: cached-poetry-dependencies
uses: actions/cache@v3.0.6
with:
path: server/.venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies 👨🏻💻
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Run Migrations 🕊️
env:
API_SECRET_KEY: o!v%_v0zjvc5+_)e!r+o!_uefr2a&)lfgv17$ex=a!ei%!y-_o
POSTGRES_HOST: localhost
POSTGRES_PASSWORD: password
POSTGRES_PORT: 5432
EMAIL_PORT: 1025
FRONTEND_URL: http://localhost:3000
run: |
source .venv/bin/activate
python manage.py migrate
- name: Run tests 🧪
env:
API_SECRET_KEY: o!v%_v0zjvc5+_)e!r+o!_uefr2a&)lfgv17$ex=a!ei%!y-_o
JWT_SIGNING_KEY: NjMgNmYgNmQgNmQgNzUgNmUgNjkgNzQgNzkgNzMgNzAgNjkgNzIgNjkgNzQgNjYgNmYgNzUgNmUgNjQgNjEgNzQgNjkgNmYgNmU=
POSTGRES_HOST: localhost
POSTGRES_PASSWORD: password
POSTGRES_PORT: 5432
EMAIL_PORT: 1025
FRONTEND_URL: http://localhost:3000
run: |
source .venv/bin/activate
python3 -m pip install coverage
coverage run manage.py test
coverage xml
- name: Upload Coverage ☂️
uses: codecov/codecov-action@v3
with:
flags: backend
files: ./server/coverage.xml