Repository navigation
105 lines (97 loc) · 4.13 KB
/
Copy pathtests.yml
File metadata and controls
105 lines (97 loc) · 4.13 KB
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
# For documentation on GitHub Actions Workflows, see:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Tests
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [main]
permissions:
contents: read
# A push to a pull request cancels the run of the push before it, so a run nobody is waiting for
# doesn't hold runners. A push to main has a group of its own, so every commit on main is tested.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
tests:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13", "3.14", "3.15", "3.15t"]
# GitHub's macOS runners are scarce. A job that waits about 15 minutes for one is cancelled
# before any step runs, and that fails the whole run. So macOS tests only the oldest and
# newest supported Python versions. Update these two entries when either of those changes.
include:
- os: macos
python-version: "3.11"
- os: macos
python-version: "3.15"
fail-fast: false
# The Apple silicon runners (macos-latest) are the ones short of capacity, so macOS jobs use
# the Intel ones, which are a separate pool. cmd2 is pure Python, so the tests don't depend on
# the processor. In case the Intel pool has no runner to give either, every second attempt
# of a run uses Apple silicon: rerun-unacquired.yml re-runs a job which no runner took.
runs-on: >-
${{
matrix.os != 'macos' && matrix.os
|| contains(fromJSON('[2, 4, 6, 8, 10]'), github.run_attempt) && 'macos-latest'
|| 'macos-26-intel'
}}
# A job takes two to five minutes. Without a limit, one whose test hangs runs for six hours.
# The time a job waits for a runner doesn't count towards this.
timeout-minutes: 10
permissions:
contents: read
# Lets the Codecov steps authenticate with a short-lived OIDC token instead of the
# CODECOV_TOKEN secret, which Dependabot-triggered runs are not given.
id-token: write
defaults:
run:
shell: bash
steps:
- name: Check out
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # Needed for setuptools_scm to work correctly
- name: Install uv
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install the project
run: uv sync --no-default-groups --group test
# faulthandler_timeout in pyproject.toml makes pytest print the stack of every thread once a
# test has run for a minute. A test which hangs keeps the job going until its timeout, above.
- name: Run tests
run: uv run --no-default-groups --group test python -Xutf8 -m pytest tests
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
flags: python${{ matrix.python-version }}
name: codecov-umbrella-test-results
report_type: test_results
use_oidc: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
env_vars: OS,PYTHON
fail_ci_if_error: true
flags: unittests
name: codecov-umbrella
use_oidc: true
verbose: true
# Single stable status check for the whole test matrix, so branch protection
# doesn't need updating every time the OS/Python matrix changes.
all-tests-passed:
name: All Tests Passed
if: always()
needs: [tests]
runs-on: ubuntu-latest
steps:
- name: Fail if any matrix job did not succeed
if: needs.tests.result != 'success'
run: exit 1