-
Notifications
You must be signed in to change notification settings - Fork 0
316 lines (279 loc) · 8.58 KB
/
tests.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
name: tests
on:
push:
branches:
- main
pull_request: null
concurrency:
group: tests
cancel-in-progress: false
jobs:
tests:
name: test code
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.11
channels: conda-forge
channel-priority: strict
show-channel-urls: true
miniforge-version: latest
- name: install deps
shell: bash -leo pipefail {0}
run: |
conda install --yes \
click \
ruamel.yaml \
conda \
conda-lock \
pytest \
pygithub
- name: run tests
shell: bash -leo pipefail {0}
run: |
pytest -vvs test_relock.py
tests-lock:
name: test updates
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: conda-lock.yml
ignored-packages: ''
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
automerge: false
base-branch: ${{ github.head_ref }}
head-branch: tests-lock
draft: true
- name: did it relock?
if: steps.relock.outputs.relocked != 'true'
run: exit 1
- name: check the summary
if: steps.relock.outputs.relocked == 'true'
run: |
echo ${{ steps.relock.outputs.summary }}
if [[ "${{ steps.relock.outputs.summary }}" == "" ]]; then
exit 1
fi
- name: test that PR is OK
if: steps.relock.outputs.relocked == 'true'
shell: bash
run: |
gh pr checkout ${{ steps.relock.outputs.pull-request-number }}
ls -lah
if [ -f conda-lock.yml ]; then
: # do nothing
else
echo "conda-lock.yml not found"
exit 1
fi
grep numpy conda-lock.yml
grep python conda-lock.yml
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: close PR
if: always()
continue-on-error: true
shell: bash
run: gh pr close ${{ steps.relock.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tests-file:
name: test updates w/ file
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.11
channels: conda-forge
channel-priority: strict
show-channel-urls: true
miniforge-version: latest
- name: make the lock file
shell: bash -leo pipefail {0}
run: |
conda install --yes conda-lock
cp test-env.yml old-test-env.yml
echo " - python =3.8" >> old-test-env.yml
conda-lock lock --file old-test-env.yml
- name: make a copy of lock file
shell: bash -leo pipefail {0}
run: |
cp conda-lock.yml old-conda-lock.yml
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: conda-lock.yml
ignored-packages: ''
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
action: file
draft: true
- name: did it relock?
if: steps.relock.outputs.relocked != 'true'
run: exit 1
- name: test that lock file is different
if: steps.relock.outputs.relocked == 'true'
shell: bash
run: |
val=$(diff conda-lock.yml old-conda-lock.yml || :)
if [[ "${val}" == "" ]]; then
echo "lock files are the same"
exit 1
fi
tests-no-lock:
name: test no update
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.11
channels: conda-forge
channel-priority: strict
show-channel-urls: true
miniforge-version: latest
- name: make the lock file
shell: bash -leo pipefail {0}
run: |
conda install --yes conda-lock
conda-lock lock --file test-env.yml --lockfile conda-lockk.yml
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: conda-lockk.yml
ignored-packages: ''
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
automerge: false
base-branch: ${{ github.head_ref }}
head-branch: tests-no-lock
draft: true
- name: did it not relock?
if: steps.relock.outputs.relocked == 'true'
run: exit 1
- name: close PR
if: always()
continue-on-error: true
shell: bash
run: gh pr close ${{ steps.relock.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tests-skip-existing-part-1:
name: test skip existing part 1
outputs:
pull-request-number: ${{ steps.relock.outputs.pull-request-number }}
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: conda-lock.yml
ignored-packages: ''
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
automerge: false
base-branch: ${{ github.head_ref }}
head-branch: tests-skip-existing
draft: true
- name: did it relock?
if: steps.relock.outputs.relocked != 'true'
run: exit 1
- name: test that PR is OK
if: steps.relock.outputs.relocked == 'true'
shell: bash
run: |
gh pr checkout ${{ steps.relock.outputs.pull-request-number }}
ls -lah
if [ -f conda-lock.yml ]; then
: # do nothing
else
echo "conda-lock.yml not found"
exit 1
fi
grep numpy conda-lock.yml
grep python conda-lock.yml
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tests-skip-existing-part-2:
name: test skip existing part 2
needs: tests-skip-existing-part-1
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: conda-lock.yml
ignored-packages: ''
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
automerge: false
base-branch: ${{ github.head_ref }}
head-branch: tests-skip-existing
skip-if-pr-exists: true
draft: true
- name: did it relock?
if: steps.relock.outputs.relocked == 'true'
run: exit 1
- name: close PR
if: always()
continue-on-error: true
shell: bash
run: gh pr close ${{ needs.tests-skip-existing-part-1.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tests-ignore:
name: test ignore
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: outdated-conda-lock.yml
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
automerge: false
base-branch: ${{ github.head_ref }}
head-branch: tests-ignore
ignored-packages: |
python
numpy
draft: true
- name: did it not relock?
if: steps.relock.outputs.relocked == 'true'
run: exit 1
- name: close PR
if: always()
continue-on-error: true
shell: bash
run: gh pr close ${{ steps.relock.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}