-
Notifications
You must be signed in to change notification settings - Fork 170
218 lines (213 loc) · 7.82 KB
/
ci.yml
File metadata and controls
218 lines (213 loc) · 7.82 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
name: ci
on:
push:
branches:
- "main"
- "test-me/*"
pull_request:
concurrency:
group: branch-${{ github.head_ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -el {0}
jobs:
should-run-ci:
name: should run ci
runs-on: ubuntu-slim
if: |
github.repository == 'Parcels-code/Parcels'
&& (github.event_name == 'push' || github.event_name == 'pull_request')
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 2
- uses: xarray-contrib/ci-trigger@v1
id: check-skip
with:
keyword: "[skip-ci]"
- name: Decide if we skip CI
if: steps.check-skip.outputs.trigger-found == 'true' || contains(github.event.pull_request.labels.*.name, 'skip-ci')
run: |
echo "Skipping CI."
exit 1
cache-pixi-lock:
runs-on: ubuntu-latest
needs: [should-run-ci]
outputs:
cache-key: ${{ steps.pixi-lock.outputs.cache-key }}
pixi-version: ${{ steps.pixi-lock.outputs.pixi-version }}
steps:
- uses: actions/checkout@v4
- uses: Parcels-code/pixi-lock/create-and-cache@a9aee67fa67426e6b0297fa5bef80600572be153
id: pixi-lock
- uses: actions/upload-artifact@v7
with:
name: pixi-lock
path: pixi.lock
unit-test:
name: "Unit tests: ${{ matrix.os }} | pixi run -e ${{ matrix.pixi-environment }} tests"
runs-on: ${{ matrix.os }}-latest
needs: [cache-pixi-lock]
env:
COVERAGE_REPORT: "${{ matrix.os }}_${{ matrix.pixi-environment }}_unit_test_report.html"
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows]
pixi-environment: [test]
include:
- os: ubuntu
pixi-environment: "test-py311"
- os: ubuntu
pixi-environment: "test-py313"
- os: ubuntu
pixi-environment: "test-minimum"
steps:
- uses: actions/checkout@v5
- name: Restore cached pixi lockfile
uses: Parcels-code/pixi-lock/restore@a9aee67fa67426e6b0297fa5bef80600572be153
with:
cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }}
- uses: prefix-dev/[email protected]
with:
pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }}
cache: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
- name: Restore cached hypothesis directory
id: restore-hypothesis-cache
uses: actions/cache/restore@v4
with:
path: .hypothesis/
key: cache-hypothesis-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
cache-hypothesis-${{ runner.os }}-
- name: Unit test
id: unit-test
run: |
pixi run -e ${{ matrix.pixi-environment }} tests -v -s --cov=parcels --cov-report=xml --html="${{ env.COVERAGE_REPORT }}" --self-contained-html
# explicitly save the cache so it gets updated, also do this even if it fails.
- name: Save cached hypothesis directory
id: save-hypothesis-cache
if: always() && steps.unit-test.outcome != 'skipped'
uses: actions/cache/save@v4
with:
path: .hypothesis/
key: cache-hypothesis-${{ runner.os }}-${{ github.run_id }}
- name: Codecov
uses: codecov/[email protected]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: unit-tests
- name: Upload test results
if: ${{ always() }} # Always run this step, even if tests fail
uses: actions/upload-artifact@v7
with:
name: Unittest report ${{ matrix.os }}-${{ matrix.pixi-environment }}
path: ${{ env.COVERAGE_REPORT }}
integration-test:
name: "Integration: ${{ matrix.os }} | pixi run -e ${{ matrix.pixi-environment }} tests-notebooks"
runs-on: ${{ matrix.os }}-latest
needs: [cache-pixi-lock]
# TODO v4: Re-enable the workflow once development has stabilized and we want to run integration tests again
if: false
env:
COVERAGE_REPORT: "${{ matrix.os }}_${{ matrix.pixi-environment }}_integration_test_report.html"
strategy:
fail-fast: false
matrix:
os: [ubuntu] #, mac, windows] # TODO v4: Re-enable windows and mac
python-version: ["3.12"]
include:
- os: ubuntu
python-version: "3.11"
steps:
- uses: actions/checkout@v5
- name: Restore cached pixi lockfile
uses: Parcels-code/pixi-lock/restore@a9aee67fa67426e6b0297fa5bef80600572be153
with:
cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }}
- uses: prefix-dev/[email protected]
with:
pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }}
cache: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
- name: Integration test
run: |
pixi run test-notebooks -v -s --html="${{ env.COVERAGE_REPORT }}" --self-contained-html --cov=parcels --cov-report=xml
- name: Codecov
uses: codecov/[email protected]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: integration-tests
- name: Upload test results
if: ${{ always() }} # Always run this step, even if tests fail
uses: actions/upload-artifact@v7
with:
name: Integration test report ${{ matrix.os }}-${{ matrix.pixi-environment }}
path: ${{ env.COVERAGE_REPORT }}
merge-test-artifacts:
runs-on: ubuntu-latest
needs:
- unit-test
- integration-test
- typechecking
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v7
with:
name: Testing reports
pattern: "* report *"
typechecking:
name: "TypeChecking: pixi run typing"
runs-on: ubuntu-latest
needs: [cache-pixi-lock]
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Restore cached pixi lockfile
uses: Parcels-code/pixi-lock/restore@a9aee67fa67426e6b0297fa5bef80600572be153
with:
cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }}
- uses: prefix-dev/[email protected]
with:
pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }}
cache: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
- name: Typechecking
run: | # TODO: Remove `|| true` once typechecking is stable
pixi run typing --output-format github || true
build-and-upload-nightly-parcels: # for alpha testing
needs: [cache-pixi-lock]
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Restore cached pixi lockfile
uses: Parcels-code/pixi-lock/restore@a9aee67fa67426e6b0297fa5bef80600572be153
with:
cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }}
- uses: prefix-dev/[email protected]
with:
pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }}
cache: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
- name: Find the alpha version of Parcels
run: pixi run get-parcels-alpha-version >> $GITHUB_ENV
- name: Build Parcels conda package
run: pixi run build-parcels
- if: github.ref == 'refs/heads/main'
run: |
for pkg in $(find output -type f \( -name "*.conda" -o -name "*.tar.bz2" \) ); do
echo "Uploading ${pkg}"
pixi run -e rattler-build rattler-build upload prefix -c parcels "${pkg}"
done
env:
PREFIX_API_KEY: ${{ secrets.PREFIX_API_KEY }}