-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (149 loc) · 4.96 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: CI
# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
on:
pull_request:
branches: [ "main" ]
paths-ignore: [ "docs/**" ]
push:
branches: [ "main" ]
paths-ignore: [ "docs/**" ]
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: pip
cache-dependency-path: |
requirements/requirements.txt
requirements/test-requirements.txt
# Run all pre-commit hooks on all the files.
# Getting only staged files can be tricky in case a new PR is opened
# since the action is run on a branch in detached head state
- name: Install and Run Pre-commit
uses: pre-commit/[email protected]
pytest-mariadb:
runs-on: ubuntu-latest
strategy:
max-parallel: 2
matrix:
# While we are only running for a single version
# ahead of planned upgrades we can add versions as
# needed
python-version: [3.8]
mariadb-version: ["10.4"]
services:
mysql:
image: mariadb:${{ matrix.mariadb-version }}
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
env:
# mysql://user:password@host:port/database
DATABASE_URL: "mysql://root:[email protected]:3306/mysql"
# We can set this to an empty string, since we'll never make an API call.
ANVIL_API_SERVICE_ACCOUNT_FILE: foo
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
requirements/requirements.txt
requirements/test-requirements.txt
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install pip-tools
pip-sync requirements/requirements.txt requirements/test-requirements.txt
- name: Collect staticfiles
run: python manage.py collectstatic --noinput --settings=config.settings.test
- name: Run tests
run: coverage run -p -m pytest
env:
# We can set this to an empty string, since we'll never make an API call.
ANVIL_API_SERVICE_ACCOUNT_FILE: foo
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-mysql-${{ strategy.job-index }}
path: .coverage.*
pytest-sqlite:
runs-on: ubuntu-latest
env:
# We can set this to an empty string, since we'll never make an API call.
ANVIL_API_SERVICE_ACCOUNT_FILE: foo
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
cache: pip
cache-dependency-path: |
requirements/requirements.txt
requirements/test-requirements.txt
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install pip-tools
pip-sync requirements/requirements.txt requirements/test-requirements.txt
- name: Collect staticfiles
run: python manage.py collectstatic --noinput --settings=config.settings.test
- name: Run tests
run: coverage run -p -m pytest
env:
# We can set this to an empty string, since we'll never make an API call.
ANVIL_API_SERVICE_ACCOUNT_FILE: foo
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-sqlite-${{ strategy.job-index }}
path: .coverage.*
coverage:
needs:
- pytest-mariadb
- pytest-sqlite
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade coverage "django<4" django-coverage-plugin
- name: Download coverage data
uses: actions/download-artifact@v4
with:
path: ./artifacts/
- name: Merge coverage files
run: |
mv ./artifacts/coverage-data*/.coverage* .
ls -la .coverage*
- name: Combine coverage data
run: |
python -m coverage combine
python -m coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}