39
39
defaults :
40
40
run :
41
41
shell : bash -leo pipefail {0}
42
+ env :
43
+ NUM_SPLITS : 2
42
44
43
45
steps :
44
46
- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -103,19 +105,6 @@ jobs:
103
105
104
106
python -m pip install -v --no-deps --no-build-isolation -e .
105
107
106
- - name : start MongoDB
107
- uses : supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # v1.12.0
108
- if : ${{ ! env.CI_SKIP }}
109
- with :
110
- mongodb-version : " latest"
111
-
112
- - name : test mongodb is OK
113
- if : ${{ ! env.CI_SKIP }}
114
- run : |
115
- python -c "from pymongo import MongoClient; import os; print(MongoClient(os.environ['MONGODB_CONNECTION_STRING']))"
116
- env :
117
- MONGODB_CONNECTION_STRING : " mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000"
118
-
119
108
- name : set up docker buildx
120
109
uses : docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
121
110
if : ${{ ! env.CI_SKIP }}
@@ -143,14 +132,13 @@ jobs:
143
132
if : ${{ ! env.CI_SKIP }}
144
133
run : |
145
134
export TEST_BOT_TOKEN_VAL=unpassword
146
- # note: we do not use pytest-xdist (-n auto) here for now because they interfere with hiding the
147
- # MONGODB_CONNECTION_STRING sensitive environment variable
148
135
if [[ -f .test_durations ]]; then
149
136
cp .test_durations .test_durations.${{ matrix.group }}
150
137
fi
151
138
pytest \
152
139
-v \
153
- --splits 2 --group ${{ matrix.group }} \
140
+ -n 3 \
141
+ --splits ${NUM_SPLITS} --group ${{ matrix.group }} \
154
142
--store-durations \
155
143
--durations-path=.test_durations.${{ matrix.group }} \
156
144
--splitting-algorithm least_duration \
@@ -162,9 +150,9 @@ jobs:
162
150
--cov-report=xml \
163
151
--durations=10 \
164
152
--ignore=tests/model \
153
+ -m "not mongodb" \
165
154
tests
166
155
env :
167
- MONGODB_CONNECTION_STRING : " mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000"
168
156
RUN_URL : " "
169
157
BOT_TOKEN : ${{ secrets.BOT_TOKEN }}
170
158
@@ -184,9 +172,159 @@ jobs:
184
172
path : .coverage
185
173
include-hidden-files : true
186
174
175
+ tests-mongodb :
176
+ name : tests-mongodb
177
+ runs-on : " ubuntu-latest"
178
+ permissions :
179
+ actions : write # for deleting cache entries
180
+ contents : read
181
+ strategy :
182
+ # continue running the tests even if one of the groups fails
183
+ fail-fast : false
184
+ matrix :
185
+ # if change the number of groups here, also change it next to --splits below
186
+ group : [1]
187
+ defaults :
188
+ run :
189
+ shell : bash -leo pipefail {0}
190
+
191
+ steps :
192
+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
193
+ with :
194
+ repository : " regro/cf-scripts"
195
+
196
+ - name : prep the lockfile
197
+ if : ${{ !inputs.lockfile-is-artifact }}
198
+ run : |
199
+ mkdir input-lockfile
200
+ mv conda-lock.yml input-lockfile/${{ inputs.lockfile }}
201
+
202
+ - name : download lockfile if it is an artifact
203
+ if : ${{ inputs.lockfile-is-artifact }}
204
+ uses : actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
205
+ with :
206
+ name : ${{ inputs.lockfile }}
207
+ path : input-lockfile
208
+
209
+ - name : move lockfile to repo
210
+ run : |
211
+ mv input-lockfile/${{ inputs.lockfile }} conda-lock.yml
212
+ rm -rf input-lockfile
213
+
214
+ - uses : mamba-org/setup-micromamba@0dea6379afdaffa5d528b3d1dabc45da37f443fc # v2.0.4
215
+ with :
216
+ environment-file : conda-lock.yml
217
+ environment-name : cf-scripts
218
+ condarc-file : autotick-bot/condarc
219
+
220
+ - name : stop me if needed
221
+ run : |
222
+ python autotick-bot/stop_me_if_needed.py
223
+
224
+ - name : configure conda and install code
225
+ if : ${{ ! env.CI_SKIP }}
226
+ run : |
227
+ pip install --no-deps --no-build-isolation -e .
228
+
229
+ - name : Set up git
230
+ if : ${{ ! env.CI_SKIP }}
231
+ run : |
232
+ git config --global user.name regro-cf-autotick-bot
233
+ git config --global user.email [email protected]
234
+ git config --global pull.rebase false
235
+
236
+ - name : test versions
237
+ if : ${{ ! env.CI_SKIP }}
238
+ run : |
239
+ cd ..
240
+ python -c "import conda_forge_tick; assert conda_forge_tick.__version__ != '0.0.0'"
241
+ cd -
242
+
243
+ pip uninstall conda-forge-tick --yes
244
+ rm -rf dist/*
245
+ python -m build --sdist . --outdir dist
246
+ pip install --no-deps --no-build-isolation dist/*.tar.gz
247
+ cd ..
248
+ python -c "import conda_forge_tick; assert conda_forge_tick.__version__ != '0.0.0'"
249
+ cd -
250
+ pip uninstall conda-forge-tick --yes
251
+
252
+ python -m pip install -v --no-deps --no-build-isolation -e .
253
+
254
+ - name : start MongoDB
255
+ uses : supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # v1.12.0
256
+ if : ${{ ! env.CI_SKIP }}
257
+ with :
258
+ mongodb-version : " latest"
259
+
260
+ - name : test mongodb is OK
261
+ if : ${{ ! env.CI_SKIP }}
262
+ run : |
263
+ python -c "from pymongo import MongoClient; import os; print(MongoClient(os.environ['MONGODB_CONNECTION_STRING']))"
264
+ env :
265
+ MONGODB_CONNECTION_STRING : " mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000"
266
+
267
+ - name : restore test durations
268
+ uses : actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
269
+ if : ${{ ! env.CI_SKIP }}
270
+ with :
271
+ path : .test_durations
272
+ key : test-durations-${{ github.ref }}-${{ github.sha }}
273
+ restore-keys : |
274
+ test-durations-${{ github.ref }}-
275
+ test-durations-
276
+
277
+ - name : run pytest
278
+ if : ${{ ! env.CI_SKIP }}
279
+ run : |
280
+ export TEST_BOT_TOKEN_VAL=unpassword
281
+ # note: we do not use pytest-xdist (-n auto) here for now because they interfere with hiding the
282
+ # MONGODB_CONNECTION_STRING sensitive environment variable
283
+ if [[ -f .test_durations ]]; then
284
+ cp .test_durations .test_durations.${{ matrix.group }}
285
+ fi
286
+ pytest \
287
+ -v \
288
+ --splits 1 --group ${{ matrix.group }} \
289
+ --store-durations \
290
+ --durations-path=.test_durations.mongodb \
291
+ --splitting-algorithm least_duration \
292
+ --clean-durations \
293
+ --cov=conda_forge_tick \
294
+ --cov=tests \
295
+ --cov-config=.coveragerc \
296
+ --cov-report=term-missing \
297
+ --cov-report=xml \
298
+ --durations=10 \
299
+ --ignore=tests/model \
300
+ -m "mongodb" \
301
+ tests
302
+ env :
303
+ MONGODB_CONNECTION_STRING : " mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000"
304
+ RUN_URL : " "
305
+ BOT_TOKEN : ${{ secrets.BOT_TOKEN }}
306
+
307
+ - name : upload test durations
308
+ uses : actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
309
+ if : ${{ ! env.CI_SKIP }}
310
+ with :
311
+ name : test-durations-mongodb
312
+ path : .test_durations.mongodb
313
+ include-hidden-files : true
314
+
315
+ - name : upload coverage
316
+ uses : actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
317
+ if : ${{ ! env.CI_SKIP }}
318
+ with :
319
+ name : coverage-mongodb
320
+ path : .coverage
321
+ include-hidden-files : true
322
+
187
323
test-coverage-and-durations :
188
324
name : test-coverage-and-durations
189
- needs : tests
325
+ needs :
326
+ - tests
327
+ - tests-mongodb
190
328
runs-on : " ubuntu-latest"
191
329
defaults :
192
330
run :
@@ -261,7 +399,8 @@ jobs:
261
399
- name : combine test durations
262
400
if : ${{ ! env.CI_SKIP }}
263
401
run : |
264
- jq '. + input' test-durations-*/.test_durations.* > .test_durations
402
+ # see https://stackoverflow.com/a/71416016/1745538
403
+ jq 'reduce inputs as $i (.; . + $i)' test-durations-*/.test_durations.* > .test_durations
265
404
266
405
- name : upload test durations
267
406
uses : actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
0 commit comments