-
Notifications
You must be signed in to change notification settings - Fork 1
205 lines (185 loc) · 7.65 KB
/
build.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
196
197
198
199
200
201
202
203
204
205
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
branches:
- master
pull_request:
permissions:
contents: read
# https://stackoverflow.com/a/72408109/6388696
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
linting:
name: Run linting/pre-commit checks
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: pip install 'pre-commit<4.0.0'
- run: pre-commit --version
- run: pre-commit install
- run: pre-commit run --all-files --show-diff-on-failure
check_docs:
needs: [linting]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
enable-cache: true
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#github-authentication-token
github-token: ${{ secrets.GITHUB_TOKEN }}
cache-suffix: "3.10"
- name: Install dependencies
run: uv sync --frozen --extra docs
- name: Build the documentation (strict mode)
run: uv run mkdocs build --strict
unit_tests:
needs: [linting]
runs-on: ${{ matrix.platform }}
strategy:
max-parallel: 4
matrix:
platform: [ubuntu-latest, macos-latest]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
enable-cache: true
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#github-authentication-token
github-token: ${{ secrets.GITHUB_TOKEN }}
cache-suffix: ${{ matrix.python-version }}
- name: Pin python-version ${{ matrix.python-version }}
run: uv python pin ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --frozen
- name: Test with pytest
env:
JAX_PLATFORMS: cpu
run: uv run pytest -v --cov=project --cov-report=xml --cov-append --skip-if-files-missing
- name: Store coverage report as an artifact
uses: actions/upload-artifact@v4
with:
name: coverage-reports-unit-tests-${{ matrix.platform }}-${{ matrix.python-version }}
path: ./coverage.xml
local_integration_tests:
needs: [unit_tests, check_docs]
runs-on: self-hosted
timeout-minutes: 30
strategy:
max-parallel: 1
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
enable-cache: false # no need, uses the local uv cache.
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#github-authentication-token
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Pin python-version ${{ matrix.python-version }}
run: uv python pin ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --all-extras --frozen
- name: Test with pytest
run: uv run pytest -v --cov=project --cov-report=xml --cov-append
- name: Test with pytest (only slow tests)
run: uv run pytest -v -m slow --slow --cov=project --cov-report=xml --cov-append
- name: Store coverage report as an artifact
uses: actions/upload-artifact@v4
with:
name: coverage-reports-integration-tests-${{ matrix.python-version }}
path: ./coverage.xml
launch-slurm-actions-runner:
needs: [local_integration_tests]
runs-on: self-hosted
timeout-minutes: 5
strategy:
max-parallel: 5
matrix:
cluster: ["mila"] #, 'narval', 'beluga']
outputs:
job_id: ${{ steps.sbatch.outputs.stdout }}
steps:
- uses: actions/checkout@v4
- name: Copy job script to the cluster
run: "scp .github/actions-runner-job.sh ${{ matrix.cluster }}:actions-runner-job.sh"
- name: Launch Slurm Actions Runner
id: sbatch
# TODO: for DRAC clusters, the account needs to be set somehow (and obviously not be hard-coded here).
# Output the job ID to a file so that the next step can use it.
# NOTE: Could also use the --wait flag to wait for the job to finish (and have this run at the same time as the other step).
run: |
job_id=`ssh ${{ matrix.cluster }} 'cd $SCRATCH && sbatch --parsable $HOME/actions-runner-job.sh'`
echo "Submitted job $job_id on the ${{ matrix.cluster }} cluster!"
echo "job_id=$job_id" >> "$GITHUB_OUTPUT"
# This step runs in a self-hosted Github Actions runner inside a SLURM job on the compute node of the cluster.
slurm_integration_tests:
name: Run integration tests on the ${{ matrix.cluster }} cluster in job ${{ needs.launch-slurm-actions-runner.outputs.job_id}}
needs: [launch-slurm-actions-runner]
runs-on: ${{ matrix.cluster }}
timeout-minutes: 30
strategy:
max-parallel: 5
matrix:
# TODO: this should be tied to the same setting in the `launch-slurm-actions-runner` job.
# cluster: ${{ needs.launch-slurm-actions-runner.strategy.matrix.cluster }}
cluster: ["mila"]
steps:
- uses: actions/checkout@v4
- name: Set up the repo using the setup script
run: scripts/mila_setup.sh
- name: Install dependencies
run: uv sync --all-extras --frozen
- name: Show installed packages
run: uv pip list
- name: Test with pytest
run: uv run pytest -v --cov=project --cov-report=xml --cov-append
# TODO: Disabling full regression tests on the cluster for now, because the worker is often
# interrupted and we want to avoid using the unkillable partition to not interrupt other's
# work. The full regression tests are still run on the local_integration_tests job.
# - name: Test with pytest (only slow tests)
# run: rye run pytest -v -m slow --slow --cov=project --cov-report=xml --cov-append
- name: Store coverage report as an artifact
uses: actions/upload-artifact@v4
with:
name: coverage-reports-slurm-integration-tests-${{ matrix.cluster }}
path: ./coverage.xml
# https://about.codecov.io/blog/uploading-code-coverage-in-a-separate-job-on-github-actions/
upload-coverage-codecov:
needs: [local_integration_tests, slurm_integration_tests]
runs-on: ubuntu-latest
name: Upload coverage reports to Codecov
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: coverage-reports-*
merge-multiple: false
# download all the artifacts in this directory (each .coverage.xml will be in a subdirectory)
# Next step if this doesn't work would be to give the coverage files a unique name and use merge-multiple: true
path: coverage_reports
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: coverage_reports
fail_ci_if_error: true