Repository navigation
226 lines (216 loc) · 8.34 KB
/
Copy pathci.yml
File metadata and controls
226 lines (216 loc) · 8.34 KB
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: CI
on:
pull_request:
push:
branches: [main]
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
inputs:
upgrade:
description: Upgrade locked dependencies before running tests
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
permissions: {}
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out the repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install just
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: "1.55.0" # Keep in sync with minimum-version in justfile
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
cache-suffix: lint
- name: Check the lockfile is up to date
run: uv lock --check
- name: Lint and check formatting
run: just lint
- name: Build the package
run: uv build
- name: Check generated models match the spec
run: |
just codegen
git diff --exit-code src/pdc_api/_generated.py
zizmor:
name: Zizmor audit
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out the repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Audit the workflows with zizmor
uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1
with:
advanced-security: false
unit-tests-and-type-checks:
name: Unit tests and type checks (Python ${{ matrix.python }}${{ matrix.lowest_direct && ', lowest direct dependencies' || '' }})
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- python: "3.12"
lowest_direct: true
- python: "3.14"
steps:
- name: Check out the repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install just
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: "1.55.0" # Keep in sync with minimum-version in justfile
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
cache-suffix: tests-py${{ matrix.python }}${{ matrix.lowest_direct && '-lowest-direct' || '' }}
- name: Run the unit tests
run: just test --python="$PYTHON" ${LOWEST_DIRECT:+--lowest-direct} ${UPGRADE:+--upgrade}
env:
PYTHON: ${{ matrix.python }}
LOWEST_DIRECT: ${{ matrix.lowest_direct && 'true' || '' }}
UPGRADE: ${{ (github.event_name == 'schedule' || inputs.upgrade) && 'true' || '' }}
- name: Upload unit test coverage data
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-data-unit-py${{ matrix.python }}${{ matrix.lowest_direct && '-lowest-direct' || '' }}
path: .coverage
include-hidden-files: true
if-no-files-found: error
- name: Run the type checks
run: just typecheck --python="$PYTHON" ${LOWEST_DIRECT:+--lowest-direct}
if: ${{ !cancelled() }}
env:
PYTHON: ${{ matrix.python }}
LOWEST_DIRECT: ${{ matrix.lowest_direct && 'true' || '' }}
integration:
name: Integration tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out the repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check out the PDC service repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
repository: PhilanthropyDataCommons/service
path: service
- name: Add hosts entries for the PDC stack
run: echo "127.0.0.1 pdc-api pdc-auth pdc-s3" | sudo tee -a /etc/hosts
- name: Start the PDC stack
working-directory: service
run: docker compose -f compose-ci.yml up -d --wait
timeout-minutes: 5
- name: Install just
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: "1.55.0" # Keep in sync with minimum-version in justfile
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
cache-suffix: integration
- name: Run the integration tests
run: just integration ${UPGRADE:+--upgrade}
timeout-minutes: 5
env:
UPGRADE: ${{ (github.event_name == 'schedule' || inputs.upgrade) && 'true' || '' }}
- name: Upload integration test coverage data
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-data-integration
path: .coverage
include-hidden-files: true
if-no-files-found: error
coverage:
name: Coverage
needs: [unit-tests-and-type-checks, integration]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out the repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
cache-suffix: coverage
- name: Download coverage data
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: coverage-data-*
- name: Report unit and integration coverage separately
run: |
coverage() { uv run --no-dev --group tests -- coverage "$@"; }
for suite in unit integration; do
coverage combine --data-file=".coverage.$suite" coverage-data-"$suite"*/.coverage
coverage report --data-file=".coverage.$suite" --show-missing
coverage html --data-file=".coverage.$suite" --directory="htmlcov/$suite" --title="${suite^} test coverage"
coverage json --data-file=".coverage.$suite" -o "coverage-json/$suite.json"
{ echo "## ${suite^} test coverage"; coverage report --data-file=".coverage.$suite" --format=markdown; } >> "$GITHUB_STEP_SUMMARY"
done
- name: Upload HTML coverage reports
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-html
path: htmlcov/
- name: Upload JSON coverage reports
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-json
path: coverage-json/
- name: Merge coverage data into one artifact
uses: actions/upload-artifact/merge@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-data
pattern: coverage-data-*
separate-directories: true
include-hidden-files: true
delete-merged: true
all-green:
name: All green
if: always()
needs: [lint, zizmor, unit-tests-and-type-checks, integration, coverage]
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Check that every required job passed
uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # v1.3.0
with:
jobs: ${{ toJSON(needs) }}
notify:
name: Notify failed build
needs: [lint, zizmor, unit-tests-and-type-checks, integration, coverage]
if: failure() && (github.event_name == 'push' || github.event_name == 'schedule')
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Open an issue for the failed build
uses: drivendataorg/failed-build-issue-action@940568ce50eeef3f31a920614cefcc6102d2f930 # v1.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}