-
Notifications
You must be signed in to change notification settings - Fork 90
301 lines (249 loc) · 9.61 KB
/
verify-ghas.yaml
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
name: Pseudo Validate GHA Output
# Approximation of the GHA "on" block
on:
# GitHub has started calling new repo's first branch "main" https://github.com/github/renaming
# The cookiecutter uses the "--initial-branch" flag when it runs git-init
push:
branches:
- "main"
pull_request:
branches:
- "main"
- "review23"
schedule:
# Nightly tests run on main by default:
# Scheduled workflows run on the latest commit on the default or base branch.
# (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
- cron: "0 0 * * 0"
# Custom global env block (Has to be recreated in each matrix, can't pass sequences to this)
env: # I want to share these between jobs, but I can't access the env from inside matrix, has to be on the steps.
licenses: "1 2"
depend-sources: "1 2 3"
rtd: "1 2"
jobs:
generate-cookiecutter:
name: "Cookiecutter Artifacts"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
python-version: [3.9, "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: "Install dependencies"
shell: bash
run: |
python -m pip install -U pyyaml cookiecutter
- name: "Construct Cookiecutter"
shell: bash
run: |
mkdir artifact_upload # Uploading artifact directory uploads as "path/*" rather than "path", so stage the upload.
for LIC in ${{ env.licenses }}
do
for DEP in ${{ env.depend-sources }}
do
for RTD in ${{ env.rtd }}
do
COMBO="$LIC"_"$DEP"_"$RTD"
python tests/setup_cookiecutter.py prj_$COMBO $LIC $DEP $RTD
mv prj_$COMBO artifact_upload/prj_$COMBO
done
done
done
- name: "Upload artifacts"
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == 3.9 }} # Upload only if ubuntu and latest python (only need to run once)
uses: actions/upload-artifact@v2
with:
name: cookiecutter_outputs
path: artifact_upload
compare-action-output:
name: "Compare GHA Output"
runs-on: ubuntu-latest
needs: "generate-cookiecutter"
strategy:
matrix:
license: [1, 2]
depend-source: [1, 2, 3]
rtd: [1, 2]
steps:
- uses: actions/checkout@v4
- name: "Fetch Artifacts"
uses: actions/[email protected]
with:
name: cookiecutter_outputs
- name: "Compare Reference CI"
shell: bash
run: |
COMBO="${{ matrix.license }}_${{ matrix.depend-source }}_${{ matrix.rtd }}"
mv prj_$COMBO/.github/workflows/CI.yaml CI_$COMBO.yaml
COMPARE=$(diff CI_$COMBO.yaml .github/reference-workflows/CI_$COMBO.yaml)
if [[ ! -z $COMPARE ]]
then
echo "CI_$COMBO.yaml differs from reference!"
echo $COMPARE
exit 1
fi
conda-forge-dep:
needs: "generate-cookiecutter"
name: Test CF (Approx) on ${{ matrix.os }}, Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy: # Approximate strategy, uses a few other options
matrix:
os: [ubuntu-latest , macOS-latest, windows-latest]
python-version: [3.9, "3.10", "3.11"]
license: [1] # Nonstandard
rtd: [1, 2] # Nonstandard
steps:
# - uses: actions/checkout@v4 # This isn't necessary here
- name: "Fetch Artifacts"
uses: actions/[email protected]
with:
name: cookiecutter_outputs
- name: Additional info about the build
shell: bash
run: |
uname -a
df -h
ulimit -a
# - name: "Change directory" # Have to CD here to make sure this works
# shell: bash
# run: |
# cd prj_${{ matrix.license }}_1_${{ matrix.rtd }}
# More info on options: https://github.com/marketplace/actions/setup-micromamba
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: prj_${{ matrix.license }}_1_${{ matrix.rtd }}/devtools/conda-envs/test_env.yaml
environment-name: test
create-args: >-
python=${{ matrix.python-version }}
condarc: |
channels:
- conda-forge
- name: Install package
# conda setup requires this special shell
shell: bash -l {0}
working-directory: prj_${{ matrix.license }}_1_${{ matrix.rtd }} # Nonstandard
run: |
python -m pip install . --no-deps
micromamba list
- name: Run tests
# conda setup requires this special shell
shell: bash -l {0}
working-directory: prj_${{ matrix.license }}_1_${{ matrix.rtd }} # Nonstandard
run: |
pytest -v --cov=prj_${{ matrix.license }}_1_${{ matrix.rtd }} --cov-report=xml --color=yes prj_${{ matrix.license }}_1_${{ matrix.rtd }}/tests/
- name: CodeCov
uses: codecov/codecov-action@v1
with:
file: ./prj_${{ matrix.license }}_1_${{ matrix.rtd }}/coverage.xml
flags: unittests
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}
conda-defaults-dep:
needs: "generate-cookiecutter"
name: Test Conda Defaults (Approx) on ${{ matrix.os }}, Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy: # Approximate strategy, uses a few other options
matrix:
os: [ubuntu-latest , macOS-latest, windows-latest]
python-version: [3.9, "3.10", "3.11"]
license: [1] # Nonstandard
rtd: [1, 2] # Nonstandard
steps:
# - uses: actions/checkout@v4 # This isn't necessary here
- name: Additional info about the build
shell: bash
run: |
uname -a
df -h
ulimit -a
- name: "Fetch Artifacts"
uses: actions/[email protected]
with:
name: cookiecutter_outputs
# - name: "Change directory" # Have to CD here to make sure this works
# shell: bash
# run: |
# cd prj_${{ matrix.license }}_2_${{ matrix.rtd }}
# More info on options: https://github.com/marketplace/actions/setup-micromamba
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: prj_${{ matrix.license }}_2_${{ matrix.rtd }}/devtools/conda-envs/test_env.yaml
environment-name: test
create-args: >-
python=${{ matrix.python-version }}
condarc: |
channels:
- defaults
- name: Install package
# conda setup requires this special shell
shell: bash -l {0}
working-directory: prj_${{ matrix.license }}_2_${{ matrix.rtd }} # Nonstandard
run: |
python -m pip install . --no-deps
micromamba list
- name: Run tests
# conda setup requires this special shell
shell: bash -l {0}
working-directory: prj_${{ matrix.license }}_2_${{ matrix.rtd }} # Nonstandard
run: |
pytest -v --cov=prj_${{ matrix.license }}_2_${{ matrix.rtd }} --cov-report=xml --color=yes prj_${{ matrix.license }}_2_${{ matrix.rtd }}/tests/
- name: CodeCov
uses: codecov/codecov-action@v1
with:
file: ./prj_${{ matrix.license }}_2_${{ matrix.rtd }}/coverage.xml
flags: unittests
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}
pip-dep:
needs: "generate-cookiecutter"
name: Test Pip (Approx) on ${{ matrix.os }}, Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy: # Approximate strategy, uses a few other options
matrix:
os: [ubuntu-latest , macOS-latest, windows-latest]
python-version: [3.9, "3.10", "3.11"]
license: [1] # Nonstandard
rtd: [1, 2] # Nonstandard
steps:
# - uses: actions/checkout@v4 # This isn't necessary here
- name: Additional info about the build
shell: bash
run: |
uname -a
df -h
ulimit -a
- name: "Fetch Artifacts"
uses: actions/[email protected]
with:
name: cookiecutter_outputs
# - name: "Change directory" # Have to CD here to make sure this works
# shell: bash
# run: |
# cd prj_${{ matrix.license }}_3_${{ matrix.rtd }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Testing Dependencies
shell: bash
run: |
python -m pip install -U pytest pytest-cov codecov
- name: Install package
shell: bash
working-directory: prj_${{ matrix.license }}_3_${{ matrix.rtd }} # Nonstandard
run: |
python -m pip install .
- name: Run tests
shell: bash
working-directory: prj_${{ matrix.license }}_3_${{ matrix.rtd }} # Nonstandard
run: |
pytest -v --cov=prj_${{ matrix.license }}_3_${{ matrix.rtd }} --cov-report=xml --color=yes prj_${{ matrix.license }}_3_${{ matrix.rtd }}/tests/
- name: CodeCov
uses: codecov/codecov-action@v1
with:
file: ./prj_${{ matrix.license }}_3_${{ matrix.rtd }}/coverage.xml
flags: unittests
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}