-
Notifications
You must be signed in to change notification settings - Fork 427
580 lines (503 loc) · 20.3 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
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
name: Tests
on:
# https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#push
push:
branches:
- main
- feature/**
- '[0-9].*.x' # e.g., 3.24.x
- '[0-9][0-9].*.x' # e.g., 23.3.x
# https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request
pull_request:
# https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_dispatch
workflow_dispatch:
# no payload
schedule:
# https://crontab.guru/#37_18_*_*_*
- cron: 37 18 * * *
concurrency:
# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to main will not cancel.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
# https://conda.github.io/conda-libmamba-solver/user-guide/configuration/#advanced-options
CONDA_LIBMAMBA_SOLVER_NO_CHANNELS_FROM_INSTALLED: true
jobs:
# detect whether any code changes are included in this PR
changes:
runs-on: ubuntu-latest
permissions:
# necessary to detect changes
# https://github.com/dorny/paths-filter#supported-workflows
pull-requests: read
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- name: Checkout Source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# dorny/paths-filter needs git clone for non-PR events
# https://github.com/dorny/paths-filter#supported-workflows
if: github.event_name != 'pull_request'
- name: Filter Changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
code:
- 'conda_build/**'
- 'tests/**'
- '*.py'
- 'recipe/**'
- '.github/workflows/tests.yml'
- '.github/condarc'
# linux test suite
linux:
# only run test suite if there are code changes
needs: changes
if: github.event_name == 'schedule' || needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
defaults:
run:
# https://github.com/conda-incubator/setup-miniconda#use-a-default-shell
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
# test all lower versions (w/ stable conda) and upper version (w/ canary conda)
python-version: ['3.9', '3.10', '3.11']
conda-version: [release]
test-type: [serial, parallel]
include:
# minimum Python/conda combo
- python-version: '3.9'
conda-version: 23.7.0
test-type: serial
- python-version: '3.9'
conda-version: 23.7.0
test-type: parallel
# maximum Python/conda combo
- python-version: '3.12'
conda-version: canary
test-type: serial
- python-version: '3.12'
conda-version: canary
test-type: parallel
env:
CONDA_CHANNEL_LABEL: ${{ matrix.conda-version == 'canary' && 'conda-canary/label/dev::' || '' }}
CONDA_VERSION: ${{ contains('canary|release', matrix.conda-version) && 'conda' || format('conda={0}', matrix.conda-version) }}
PYTEST_MARKER: ${{ matrix.test-type == 'serial' && 'serial' || 'not serial' }}
steps:
- name: Checkout Source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Hash + Timestamp
run: echo "HASH=${{ runner.os }}-${{ runner.arch }}-Py${{ matrix.python-version }}-${{ matrix.conda-version }}-${{ matrix.test-type }}-$(date -u "+%Y%m")" >> $GITHUB_ENV
- name: Cache Conda
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: ~/conda_pkgs_dir
key: cache-${{ env.HASH }}
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
with:
condarc-file: .github/condarc
run-post: false # skip post cleanup
- name: Conda Install
run: >
conda install
--yes
--file tests/requirements.txt
--file tests/requirements-${{ runner.os }}.txt
--file tests/requirements-ci.txt
python=${{ matrix.python-version }}
${{ env.CONDA_CHANNEL_LABEL }}${{ env.CONDA_VERSION }}
# TODO: how can we remove this step?
- name: Install Self
run: pip install -e .
- name: Conda Info
# view test env info (not base)
run: python -m conda info --verbose
- name: Conda List
run: conda list --show-channel-urls
- name: Run Tests
run: >
pytest
--cov=conda_build
-n auto
-m "${{ env.PYTEST_MARKER }}"
- name: Upload Coverage
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
with:
flags: ${{ runner.os }},${{ runner.arch }},${{ matrix.python-version }},${{ matrix.test-type }}
- name: Upload Test Results
if: '!cancelled()'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.0
with:
name: test-results-${{ env.HASH }}
path: |
.coverage
test-report.xml
retention-days: 1 # temporary, combined in aggregate below
# linux benchmarks
linux-benchmarks:
# only run test suite if there are code changes
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
defaults:
run:
# https://github.com/conda-incubator/setup-miniconda#use-a-default-shell
shell: bash -el {0} # bash exit immediately on error + login shell
strategy:
fail-fast: false
matrix:
python-version: ['3.12']
steps:
- name: Checkout Source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Hash + Timestamp
run: echo "HASH=${{ runner.os }}-${{ runner.arch }}-Py${{ matrix.python-version }}-benchmark-$(date -u "+%Y%m")" >> $GITHUB_ENV
- name: Cache Conda
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: ~/conda_pkgs_dir
key: cache-${{ env.HASH }}
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
with:
condarc-file: .github/condarc
run-post: false # skip post cleanup
- name: Conda Install
run: >
conda install
--yes
--file tests/requirements.txt
--file tests/requirements-${{ runner.os }}.txt
--file tests/requirements-ci.txt
--file tests/requirements-benchmarks.txt
python=${{ matrix.python-version }}
# TODO: how can we remove this step?
- name: Install Self
run: pip install -e .
- name: Conda Info
# view test env info (not base)
run: python -m conda info --verbose
- name: Conda Config
run: conda config --show-sources
- name: Conda List
run: conda list --show-channel-urls
- name: Run Benchmarks
uses: CodSpeedHQ/action@513a19673a831f139e8717bf45ead67e47f00044 # v3.2.0
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: $CONDA/envs/test/bin/pytest --codspeed
# windows test suite
windows:
# only run test suite if there are code changes
needs: changes
if: github.event_name == 'schedule' || needs.changes.outputs.code == 'true'
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
# test lower version (w/ stable conda) and upper version (w/ canary conda)
python-version: ['3.9']
conda-version: [release]
test-type: [serial, parallel]
include:
- python-version: '3.12'
conda-version: canary
test-type: serial
- python-version: '3.12'
conda-version: canary
test-type: parallel
env:
ErrorActionPreference: Stop # powershell exit on first error
CONDA_CHANNEL_LABEL: ${{ matrix.conda-version == 'canary' && 'conda-canary/label/dev' || 'defaults' }}
PYTEST_MARKER: ${{ matrix.test-type == 'serial' && 'serial' || 'not serial and not slow' }}
steps:
- name: Checkout Source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Hash + Timestamp
shell: bash # use bash to run date command
run: echo "HASH=${{ runner.os }}-${{ runner.arch }}-Py${{ matrix.python-version }}-${{ matrix.conda-version }}-${{ matrix.test-type }}-$(date -u "+%Y%m")" >> $GITHUB_ENV
- name: Cache Conda
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
# Use faster GNU tar for all runners
enableCrossOsArchive: true
path: D:\conda_pkgs_dir
key: cache-${{ env.HASH }}
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
with:
condarc-file: .github\condarc
run-post: false # skip post cleanup
pkgs-dirs: D:\conda_pkgs_dir
installation-dir: D:\conda
- name: Choco Install
run: choco install visualstudio2017-workload-vctools
- name: Conda Install
run: >
conda install
--yes
--file tests\requirements.txt
--file tests\requirements-${{ runner.os }}.txt
--file tests\requirements-ci.txt
python=${{ matrix.python-version }}
${{ env.CONDA_CHANNEL_LABEL }}::conda
# TODO: how can we remove this step?
- name: Install Self
run: pip install -e .
- name: Conda Info
# view test env info (not base)
run: python -m conda info --verbose
- name: Conda List
run: conda list --show-channel-urls
- name: Run Tests
# Windows is sensitive to long paths, using `--basetemp=${{ runner.temp }} to
# keep the test directories shorter
run: >
pytest
--cov=conda_build
--basetemp=${{ runner.temp }}
-n auto
-m "${{ env.PYTEST_MARKER }}"
- name: Upload Coverage
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
with:
flags: ${{ runner.os }},${{ runner.arch }},${{ matrix.python-version }},${{ matrix.test-type }}
- name: Upload Test Results
if: '!cancelled()'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.0
with:
name: test-results-${{ env.HASH }}
path: |
.coverage
test-report.xml
retention-days: 1 # temporary, combined in aggregate below
# macos test suite
macos:
# only run test suite if there are code changes
needs: changes
if: github.event_name == 'schedule' || needs.changes.outputs.code == 'true'
# we still need intel macs so we are stuck on macos-13 (not -14 or -latest)
# the issue is that there are recipes that depend on packages
# that do not exist for osx-arm64 - see #5388
runs-on: macos-13
defaults:
run:
# https://github.com/conda-incubator/setup-miniconda#use-a-default-shell
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
# test lower version (w/ stable conda) and upper version (w/ canary conda)
python-version: ['3.9']
conda-version: [release]
test-type: [serial, parallel]
include:
- python-version: '3.12'
conda-version: canary
test-type: serial
- python-version: '3.12'
conda-version: canary
test-type: parallel
env:
CONDA_CHANNEL_LABEL: ${{ matrix.conda-version == 'canary' && 'conda-canary/label/dev' || 'defaults' }}
PYTEST_MARKER: ${{ matrix.test-type == 'serial' && 'serial' || 'not serial' }}
steps:
- name: Checkout Source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Hash + Timestamp
run: echo "HASH=${{ runner.os }}-${{ runner.arch }}-Py${{ matrix.python-version }}-${{ matrix.conda-version }}-${{ matrix.test-type }}-$(date -u "+%Y%m")" >> $GITHUB_ENV
- name: Cache Conda
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: |
~/conda_pkgs_dir
~/macosx_sdks
key: cache-${{ env.HASH }}
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
with:
condarc-file: .github/condarc
run-post: false # skip post cleanup
- name: SDK Download
run: |
echo "MACOSX_SDK_DIR=${HOME}/macosx_sdks" >> "$GITHUB_ENV"
export MACOSX_SDK_DIR=${HOME}/macosx_sdks
echo "MACOSX_SDK_VERSION=10.15" >> "$GITHUB_ENV"
export MACOSX_SDK_VERSION=10.15
echo "MACOSX_SDK_ROOT=${MACOSX_SDK_DIR}/MacOSX${MACOSX_SDK_VERSION}.sdk" >> "$GITHUB_ENV"
export MACOSX_SDK_ROOT=${MACOSX_SDK_DIR}/MacOSX${MACOSX_SDK_VERSION}.sdk
if [ ! -d ${MACOSX_SDK_DIR} ]; then mkdir ${MACOSX_SDK_DIR}; fi
if [ ! -d ${MACOSX_SDK_ROOT} ]; then
url="https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX${MACOSX_SDK_VERSION}.sdk.tar.xz"
curl -L --output MacOSX${MACOSX_SDK_VERSION}.sdk.tar.xz "${url}"
sdk_sha256=ac75d9e0eb619881f5aa6240689fce862dcb8e123f710032b7409ff5f4c3d18b
echo "${sdk_sha256} *MacOSX${MACOSX_SDK_VERSION}.sdk.tar.xz" | shasum -a 256 -c
tar -xf MacOSX${MACOSX_SDK_VERSION}.sdk.tar.xz -C "${MACOSX_SDK_DIR}"
fi
- name: Conda Install
run: >
conda install
--yes
--file tests/requirements.txt
--file tests/requirements-${{ runner.os }}.txt
--file tests/requirements-ci.txt
python=${{ matrix.python-version }}
${{ env.CONDA_CHANNEL_LABEL }}::conda
# TODO: how can we remove this step?
- name: Install Self
run: pip install -e .
- name: Conda Info
# view test env info (not base)
run: python -m conda info --verbose
- name: Conda List
run: conda list --show-channel-urls
- name: Run Tests
run: >
pytest
--cov=conda_build
-n auto
-m "${{ env.PYTEST_MARKER }}"
env:
CONDA_BUILD_SYSROOT: ${{ env.MACOSX_SDK_ROOT }}
- name: Upload Coverage
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
with:
flags: ${{ runner.os }},${{ runner.arch }},${{ matrix.python-version }},${{ matrix.test-type }}
- name: Upload Test Results
if: '!cancelled()'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.0
with:
name: test-results-${{ env.HASH }}
path: |
.coverage
test-report.xml
retention-days: 1 # temporary, combined in aggregate below
# aggregate and upload
aggregate:
# only aggregate test suite if there are code changes
needs: [changes, linux, linux-benchmarks, windows, macos]
if: >-
!cancelled()
&& (
github.event_name == 'schedule'
|| needs.changes.outputs.code == 'true'
)
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
- name: Upload Combined Test Results
# provides one downloadable archive of all matrix run test results for further analysis
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.0
with:
name: test-results-${{ github.sha }}-all
path: test-results-*
- name: Test Summary
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: test-results-*/test-report.xml
# required check
analyze:
needs: [linux, linux-benchmarks, windows, macos, aggregate]
if: '!cancelled()'
runs-on: ubuntu-latest
steps:
- name: Determine Success
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
# permit jobs to be skipped if there are no code changes (see changes job)
allowed-skips: ${{ toJSON(needs) }}
jobs: ${{ toJSON(needs) }}
# canary builds
build:
needs: [analyze]
# only build canary build if
# - prior steps succeeded,
# - this is the main repo, and
# - we are on the main, feature, or release branch
if: >-
!cancelled()
&& !github.event.repository.fork
&& (
github.ref_name == 'main'
|| startsWith(github.ref_name, 'feature/')
|| endsWith(github.ref_name, '.x')
)
strategy:
matrix:
include:
- runner: ubuntu-latest
subdir: linux-64
- runner: macos-13
subdir: osx-64
- runner: macos-14 # FUTURE: Use -latest
subdir: osx-arm64
- runner: windows-latest
subdir: win-64
runs-on: ${{ matrix.runner }}
steps:
# Clean checkout of specific git ref needed for package metadata version
# which needs env vars GIT_DESCRIBE_TAG and GIT_BUILD_STR:
- name: Checkout Source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.ref }}
clean: true
fetch-depth: 0
# Explicitly use Python 3.12 since each of the OSes has a different default Python
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.12'
- name: Detect Label
shell: python
run: |
import re
from pathlib import Path
from os import environ
from subprocess import check_output
# unless otherwise specified, commits are uploaded to the dev label
# e.g., `main` branch commits
envs = {"ANACONDA_ORG_LABEL": "dev"}
if "${{ github.ref_name }}".startswith("feature/"):
# feature branch commits are uploaded to a custom label
envs["ANACONDA_ORG_LABEL"] = "${{ github.ref_name }}"
elif re.match(r"\d+(\.\d+)+\.x", "${{ github.ref_name }}"):
# release branch commits are added to the rc label
# see https://github.com/conda/infrastructure/issues/760
_, name = "${{ github.repository }}".split("/")
envs["ANACONDA_ORG_LABEL"] = f"rc-{name}-${{ github.ref_name }}"
# if no releases have occurred on this branch yet then `git describe --tag`
# will misleadingly produce a version number relative to the last release
# and not relative to the current release branch, if this is the case we need
# to override the version with a derivative of the branch name
# override the version if `git describe --tag` does not start with the branch version
last_release = check_output(["git", "describe", "--tag"], text=True).strip()
prefix = "${{ github.ref_name }}"[:-1] # without x suffix
if not last_release.startswith(prefix):
envs["VERSION_OVERRIDE"] = "${{ github.ref_name }}"
Path(environ["GITHUB_ENV"]).write_text("\n".join(f"{name}={value}" for name, value in envs.items()))
- name: Create & Upload
uses: conda/actions/canary-release@6e72e0db87e72f0020e493aeb02f864363bd9258 # v24.11.1
with:
package-name: ${{ github.event.repository.name }}
subdir: ${{ matrix.subdir }}
anaconda-org-channel: conda-canary
anaconda-org-label: ${{ env.ANACONDA_ORG_LABEL }}
anaconda-org-token: ${{ secrets.ANACONDA_ORG_CONDA_CANARY_TOKEN }}