-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (111 loc) · 3.19 KB
/
backend-pull-request.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
110
111
112
113
114
name: Backend - Pull Request checks
on:
pull_request:
types: [ opened, synchronize, reopened ]
branches:
- main
paths:
- backend/**
push:
branches:
- main
paths:
- backend/**
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-test.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-test.txt
- name: Run tests
env:
DJANGO_SETTINGS_MODULE: app.settings.test
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
run: |
coverage run ./manage.py test
coverage xml
- name: Save coverage report
uses: actions/upload-artifact@v2
with:
name: coverage-report
path: backend/coverage.xml
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-test.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-test.txt
- name: Run linter
run: |
echo "Running flake8"
# black --check .
# flake8
sonarcloud:
runs-on: ubuntu-latest
needs: [ test, lint ]
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- uses: actions/download-artifact@v2
name: Download coverage report
with:
name: coverage-report
path: backend/
- name: Fix coverage
run: |
sed -i -e 's/app</backend\/app</g' coverage.xml
- uses: sonarsource/sonarcloud-github-action@master
name: SonarCloud Scan
with:
projectBaseDir: backend
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }}