-
Notifications
You must be signed in to change notification settings - Fork 3
195 lines (160 loc) · 6.07 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
183
184
185
186
187
188
189
190
191
192
193
194
195
name: ci
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
tests_v1:
name: "V1 - Python ${{ matrix.python-version }} - ${{ matrix.db }}"
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.9", "3.10"]
db: ["postgres"]
services:
postgres:
# Disable postgres service when using sqlite, through the workaround
# described in https://github.com/actions/runner/issues/822
image: ${{ (matrix.db != 'sqlite') && 'postgres' || '' }}
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: fractal_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Cache SLURM Docker images
id: cache-docker-slurm-multipy
uses: actions/cache@v4
with:
path: ci/cache/docker/slurm-multipy
key: cache-docker-slurm-multipy
- name: Use SLURM Docker Image Cache if cache hit
if: steps.cache-docker-slurm-multipy.outputs.cache-hit == 'true'
run: docker image load --input ./ci/cache/docker/slurm-multipy/slurm-multipy.tar
- name: Update SLURM Docker Image Cache if cache miss
if: steps.cache-docker-slurm-multipy.outputs.cache-hit != 'true'
run: docker pull ghcr.io/fractal-analytics-platform/ubuntu22-slurm-multipy:0.1 && mkdir -p ci/cache/docker/slurm-multipy && docker image save ghcr.io/fractal-analytics-platform/ubuntu22-slurm-multipy:0.1 --output ./ci/cache/docker/slurm-multipy/slurm-multipy.tar
- name: Install poetry
run: pipx install poetry==1.8.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: |
if [[ ${{ matrix.db }} == "postgres" ]]; then
DB="-E postgres"
else
DB="-E postgres-psycopg-binary"
fi
poetry install --with dev --without docs --no-interaction -E gunicorn $DB
- name: Test with pytest
run: poetry run coverage run --concurrency=thread,greenlet,multiprocessing -m pytest --ignore tests/no_version --ignore tests/v2
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: ".coverage*"
tests_v2:
name: "V2 - Python ${{ matrix.python-version }} - ${{ matrix.db }}"
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
db: ["sqlite", "postgres", "postgres-psycopg"]
exclude:
- python-version: "3.11"
db: "sqlite"
- python-version: "3.11"
db: "postgres"
services:
postgres:
# Disable postgres service when using sqlite, through the workaround
# described in https://github.com/actions/runner/issues/822
image: ${{ (matrix.db != 'sqlite') && 'postgres' || '' }}
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: fractal_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Cache SLURM Docker images
id: cache-docker-slurm-multipy
uses: actions/cache@v4
with:
path: ci/cache/docker/slurm-multipy
key: cache-docker-slurm-multipy
- name: Use SLURM Docker Image Cache if cache hit
if: steps.cache-docker-slurm-multipy.outputs.cache-hit == 'true'
run: docker image load --input ./ci/cache/docker/slurm-multipy/slurm-multipy.tar
- name: Update SLURM Docker Image Cache if cache miss
if: steps.cache-docker-slurm-multipy.outputs.cache-hit != 'true'
run: docker pull ghcr.io/fractal-analytics-platform/ubuntu22-slurm-multipy:0.1 && mkdir -p ci/cache/docker/slurm-multipy && docker image save ghcr.io/fractal-analytics-platform/ubuntu22-slurm-multipy:0.1 --output ./ci/cache/docker/slurm-multipy/slurm-multipy.tar
- name: Install poetry
run: pipx install poetry==1.8.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: |
if [[ ${{ matrix.db }} == "postgres" ]]; then
DB="-E postgres"
elif [[ ${{ matrix.db }} == "postgres-psycopg" ]]; then
DB="-E postgres-psycopg-binary"
fi
poetry install --with dev --without docs --no-interaction -E gunicorn $DB
- name: Test with pytest
run: poetry run coverage run --concurrency=thread,greenlet,multiprocessing -m pytest tests/v2 tests/no_version --ignore tests/v1
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: ".coverage*"
coverage:
name: Coverage
runs-on: ubuntu-22.04
needs: [tests_v1, tests_v2]
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: python -m pip install --upgrade coverage[toml]
- name: Download data
uses: actions/download-artifact@v3
with:
name: coverage-data
- name: Add coverage comment to Pull Requests
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
MERGE_COVERAGE_FILES: true
MINIMUM_GREEN: 90
MINIMUM_ORANGE: 60
ANNOTATE_MISSING_LINES: true
ANNOTATION_TYPE: notice