-
Notifications
You must be signed in to change notification settings - Fork 0
342 lines (328 loc) · 13.3 KB
/
push-pull.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# This runs jobs which pyiron modules should run on pushes or PRs to main
# Usage:
# on:
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
name: Push or Pull
on:
workflow_call:
inputs:
do-commit-updated-env:
type: boolean
description: 'Feature flag: controls if the commit-updated-env step does anything or gets skipped over.'
default: true
required: false
do-build-docs:
type: boolean
description: 'Feature flag: controls if the build-docs job runs.'
default: true
required: false
do-build-notebooks:
type: boolean
description: 'Feature flag: controls if the build-notebooks job runs.'
default: true
required: false
do-unit-tests:
type: boolean
description: 'Feature flag: controls if the unit-tests job runs.'
default: true
required: false
do-coveralls:
type: boolean
description: 'Whether to use the coveralls/github-action after generating coverage. If neither do-coveralls nor do-codacy are true, the coveralls-and-codacy job is skipped.'
default: true
required: false
do-codacy:
type: boolean
description: 'Whether to push the report to codacy after generating coverage. If neither do-coveralls nor do-codacy are true, the coveralls-and-codacy job is skipped.'
default: true
required: false
do-benchmark-tests:
type: boolean
description: 'Feature flag: controls if the benchmark-tests job runs.'
default: true
required: false
do-pip-check:
type: boolean
description: 'Feature flag: controls if the pip-check job runs.'
default: true
required: false
do-black:
type: boolean
description: 'Feature flag: controls if the black job runs.'
default: true
required: false
docs-env-files:
type: string
description: 'Paths to an arbitrary number of (space-separated) conda environment yaml files'
default: .ci_support/environment.yml
required: false
notebooks-env-files:
type: string
description: 'Paths to an arbitrary number of (space-separated) conda environment yaml files'
default: .ci_support/environment.yml
required: false
notebooks-exclusion-file:
type: string
description: 'An optional path to a file containing the names of notebooks to NOT build'
default: .ci_support/exclude
required: false
tests-env-files:
type: string
description: 'Paths to an arbitrary number of (space-separated) conda environment yaml files'
default: .ci_support/environment.yml
required: false
unit-test-timeout-minutes:
type: number
description: 'timout-minutes to apply to running the unit tests'
default: 10
required: false
coveralls-and-codacy-timeout-minutes:
type: number
description: 'timout-minutes to apply to running the coveralls and codacy tests'
default: 15
required: false
benchmark-timeout-minutes:
type: number
description: 'How many minutes to allow tests in units/benchmark to run for'
default: 30
required: false
alternate-tests-timeout-minutes:
type: number
description: 'How many minutes to allow tests in alternate environment tests to run for'
default: 15
required: false
extra-python-paths:
type: string
description: 'Extra paths (e.g. test dirs tests/(benchmark,integration,unit)) to the PYTHONPATH. This is a required workaround for repos that use `pympipool` executors, [cf. this issue](https://github.com/pyiron/pympipool/issues/239).'
default: ''
required: false
runner:
type: string
description: 'The main runner to use everywhere'
default: 'ubuntu-latest'
required: false
runner-alt1:
type: string
description: 'An alternate runner for the unit tests (only on the main python version). Set to the string exclude to skip'
default: 'windows-latest'
required: false
runner-alt2:
type: string
description: 'Another alternate runner for the unit tests (only on the main python version). Set to the string exclude to skip'
default: 'macos-latest'
required: false
python-version:
type: string
description: 'The main version of python to test on, used across all three OS for tests and in other steps'
default: '3.12'
required: false
python-version-alt1:
type: string
description: 'An alternate version of python to run unit tests on, used only on the main runner. Set to the string exclude to skip'
default: '3.11'
required: false
python-version-alt2:
type: string
description: 'An alternate version of python to run unit tests on, used only on the main runner. Set to the string exclude to skip'
default: '3.10'
required: false
python-version-alt3:
type: string
description: 'An alternate version of python to run unit tests on, used only on the main runner. Set to the string exclude to skip'
default: '3.9'
required: false
unit-test-dir:
type: string
description: 'The directory containing the unit tests run on the full platform and python matrix'
default: tests/unit
required: false
coveralls-and-codacy-test-dir:
type: string
description: 'The directory containing the tests analyzed by coveralls'
default: tests
required: false
benchmark-test-dir:
type: string
description: 'The directory containing the benchmark tests'
default: tests/benchmark
required: false
omit-patterns:
type: string
description: 'Patterns passed to --omit for skipping coverage in all unit test calls'
default: '*/_version.py'
required: false
alternate-tests-env-files:
type: string
description: 'An alternate set of (space-separated) conda environment yaml files, e.g. to test a lower-bounds environment. Skipped if empty'
required: false
alternate-tests-python-version:
type: string
description: 'Version of python to use with the alternate tests'
default: '3.12'
required: false
alternate-tests-dir:
type: string
description: 'The directory containing the tests run with the alternate environment'
default: tests
required: false
jobs:
commit-updated-env: # Keep envs read by external sources (binder and readthedocs) up-to-date
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.DEPENDABOT_WORKFLOW_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }} # Check out the head of the actual branch, not the PR
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
if: ${{ inputs.do-commit-updated-env }}
- uses: pyiron/actions/write-docs-env@main
with:
env-files: ${{ inputs.docs-env-files }}
if: ${{ inputs.do-commit-updated-env }}
- uses: pyiron/actions/write-environment@main
with:
env-files: ${{ inputs.notebooks-env-files }}
output-env-file: .binder/environment.yml
if: ${{ inputs.do-commit-updated-env }}
- name: commit
id: commit-docs-env
continue-on-error: true # Allow "failure" when there are no changes (the working tree is clean)
run: |
git config --local user.email "[email protected]"
git config --local user.name "pyiron-runner"
git add docs/environment.yml .binder/environment.yml
git commit -m "[dependabot skip] Update env file" -a
if: ${{ inputs.do-commit-updated-env }}
- name: push
if: steps.commit-docs-env.outcome == 'success' # But only push if we made it here without continue-on-error
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.DEPENDABOT_WORKFLOW_TOKEN }}
branch: ${{ github.event.pull_request.head.ref }}
build-docs:
needs: commit-updated-env
if: ${{ inputs.do-build-docs }}
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v4
- uses: pyiron/actions/build-docs@main
with:
python-version: ${{ inputs.python-version }}
env-files: ${{ inputs.docs-env-files }}
build-notebooks:
needs: commit-updated-env
if: ${{ inputs.do-build-notebooks }}
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v4
- uses: pyiron/actions/build-notebooks@main
with:
python-version: ${{ inputs.python-version }}
env-files: ${{ inputs.notebooks-env-files }}
exclusion-file: ${{ inputs.notebooks-exclusion-file }}
unit-tests:
needs: commit-updated-env
if: ${{ inputs.do-unit-tests }}
runs-on: ${{ matrix.operating-system }}
# All three runners for the highest python version
# Only the main for up to two more versions of python
strategy:
matrix:
operating-system: ["${{ inputs.runner }}", "${{ inputs.runner-alt1 }}", "${{ inputs.runner-alt2 }}"]
python-version: ["${{ inputs.python-version }}", "${{ inputs.python-version-alt1 }}", "${{ inputs.python-version-alt2 }}", "${{ inputs.python-version-alt3 }}"]
exclude:
# Get rid of all combinations of alternative runners and alternative python versions
- operating-system: ${{ inputs.runner-alt1 }}
python-version: ${{ inputs.python-version-alt1 }}
- operating-system: ${{ inputs.runner-alt1 }}
python-version: ${{ inputs.python-version-alt2 }}
- operating-system: ${{ inputs.runner-alt1 }}
python-version: ${{ inputs.python-version-alt3 }}
- operating-system: ${{ inputs.runner-alt2 }}
python-version: ${{ inputs.python-version-alt1 }}
- operating-system: ${{ inputs.runner-alt2 }}
python-version: ${{ inputs.python-version-alt2 }}
- operating-system: ${{ inputs.runner-alt2 }}
python-version: ${{ inputs.python-version-alt3 }}
# Don't run anything tagged with "exclude"
- operating-system: 'exclude'
- python-version: 'exclude'
steps:
- uses: actions/checkout@v4
- uses: pyiron/actions/add-to-python-path@main
if: inputs.extra-python-paths != ''
with:
path-dirs: ${{ inputs.extra-python-paths }}
- uses: pyiron/actions/unit-tests@main
with:
python-version: ${{ matrix.python-version }}
env-files: ${{ inputs.tests-env-files }}
test-dir: ${{ inputs.unit-test-dir }}
omit-patterns: ${{ inputs.omit-patterns }}
timeout-minutes: ${{ inputs.unit-test-timeout-minutes }}
coveralls-and-codacy:
needs: commit-updated-env
if: ${{ inputs.do-coveralls || inputs.do-codacy }}
uses: pyiron/actions/.github/workflows/tests-and-coverage.yml@main
secrets: inherit
with:
tests-env-files: ${{ inputs.tests-env-files }}
extra-python-paths: ${{ inputs.extra-python-paths }}
runner: ${{ inputs.runner }}
python-version: ${{ inputs.python-version }}
test-dir: ${{ inputs.coveralls-and-codacy-test-dir }}
omit-patterns: ${{ inputs.omit-patterns }}
do-coveralls: ${{ inputs.do-coveralls }}
do-codacy: ${{ inputs.do-codacy }}
test-timeout-minutes: ${{ inputs.coveralls-and-codacy-timeout-minutes }}
benchmark-tests:
needs: commit-updated-env
if: ${{ inputs.do-benchmark-tests }}
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v4
- uses: pyiron/actions/unit-tests@main
with:
python-version: ${{ inputs.python-version }}
env-files: ${{ inputs.tests-env-files }}
test-dir: ${{ inputs.benchmark-test-dir }}
omit-patterns: ${{ inputs.omit-patterns }}
timeout-minutes: ${{ inputs.benchmark-timeout-minutes }}
test-alternate-env:
if: ${{ inputs.alternate-tests-env-files != '' }}
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v4
- uses: pyiron/actions/add-to-python-path@main
if: inputs.extra-python-paths != ''
with:
path-dirs: ${{ inputs.extra-python-paths }}
- uses: pyiron/actions/unit-tests@main
with:
python-version: ${{ inputs.alternate-tests-python-version }}
env-files: ${{ inputs.alternate-tests-env-files }}
test-dir: ${{ inputs.alternate-tests-dir }}
omit-patterns: ${{ inputs.omit-patterns }}
timeout-minutes: ${{ inputs.alternate-tests-timeout-minutes }}
pip-check:
needs: commit-updated-env
if: ${{ inputs.do-pip-check }}
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v4
- uses: pyiron/actions/pip-check@main
with:
python-version: ${{ inputs.python-version }}
black:
needs: commit-updated-env
if: ${{ inputs.do-black }}
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
options: "--check --diff"
src: ./${{ github.event.repository.name }}