-
Notifications
You must be signed in to change notification settings - Fork 41
119 lines (99 loc) · 3.32 KB
/
ci.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
115
116
117
118
119
name: linkedevents-ci
on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
SECRET_KEY: topsecret123
POSTGRES_DB: test_linkedevents
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
DATABASE_URL: "postgis://postgres:postgres@localhost/test_linkedevents"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.9]
services:
postgres:
image: helsinkitest/postgis:9.6-2.5-alpine
env:
# Note: not redundant, parent env is not applied to service
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_linkedevents
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# Required by Sonar
fetch-depth: 0
- name: Update apt
run: sudo apt-get update
- name: psycopg2 prerequisites
run: sudo apt-get install libpq-dev
- name: System requirements for Django
run: sudo apt-get install gdal-bin gettext postgresql-client
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Check migrations
run: |
python manage.py makemigrations --dry-run --check
- name: Apply migrations
run: |
python manage.py migrate
- name: Compile translations
run: |
django-admin compilemessages
- name: Check black
run: |
black --check .
- name: Check flake8
uses: liskin/gh-problem-matcher-wrap@v2
with:
linters: flake8
run: flake8
- name: Check isort
uses: liskin/gh-problem-matcher-wrap@v2
with:
linters: isort
run: isort . --check-only --diff
# With pytest-cov use: --cov=.
# Some errors, skipping --doctest-modules for now
- name: Run tests
uses: liskin/gh-problem-matcher-wrap@v2
with:
linters: pytest
run: pytest -ra -vvv --cov=.
- name: Codecov
uses: codecov/codecov-action@v3
# Without this workaround Sonar reports a warning about an incorrect source path
- name: Override coverage report source path for Sonar
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}