1
+ ---
1
2
name : tox
2
3
3
4
on :
5
+ merge_group :
4
6
push :
5
7
branches :
6
- - main
8
+ - " main"
7
9
8
10
pull_request :
9
11
branches :
10
- - main
12
+ - " main"
13
+ schedule :
14
+ - cron : " 0 0 * * *"
15
+ workflow_call :
16
+
17
+ concurrency :
18
+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
19
+ cancel-in-progress : true
20
+
21
+ env :
22
+ FORCE_COLOR : 1 # tox, pytest, ansible-lint
23
+ PY_COLORS : 1
11
24
12
25
jobs :
13
- pre :
14
- name : pre
15
- runs-on : ubuntu-22 .04
26
+ prepare :
27
+ name : prepare
28
+ runs-on : ubuntu-24 .04
16
29
outputs :
17
30
matrix : ${{ steps.generate_matrix.outputs.matrix }}
18
31
steps :
19
32
- name : Determine matrix
20
33
id : generate_matrix
21
- uses : coactions/matrix@v4
34
+ uses : coactions/dynamic- matrix@v4
22
35
with :
23
36
min_python : " 3.10"
24
37
max_python : " 3.14"
@@ -29,37 +42,120 @@ jobs:
29
42
docs
30
43
build :
31
44
name : ${{ matrix.name }}
32
- needs : pre
33
- runs-on : ${{ matrix.os || 'ubuntu-22.04' }}
45
+ runs-on : ${{ matrix.os || 'ubuntu-24.04' }}
46
+ needs :
47
+ - prepare
34
48
35
49
strategy :
36
50
fail-fast : false
37
- matrix : ${{ fromJson(needs.pre .outputs.matrix) }}
51
+ matrix : ${{ fromJson(needs.prepare .outputs.matrix) }}
38
52
39
53
steps :
40
54
- uses : actions/checkout@v4
41
55
with :
42
56
fetch-depth : 0 # needed by setuptools-scm
57
+ submodules : true
43
58
44
- - name : Set up Python ${{ matrix.python_version }}
59
+ - name : Set pre-commit cache
60
+ uses : actions/cache@v4
61
+ if : ${{ matrix.name == 'lint' }}
62
+ with :
63
+ path : |
64
+ ~/.cache/pre-commit
65
+ key : pre-commit-${{ matrix.name }}-${{ hashFiles('.pre-commit-config.yaml') }}
66
+
67
+ - name : Set up Python ${{ matrix.python_version || '3.10' }}
68
+ if : " !contains(matrix.shell, 'wsl')"
45
69
uses : actions/setup-python@v5
46
70
with :
47
- python-version : ${{ matrix.python_version }}
71
+ cache : pip
72
+ python-version : ${{ matrix.python_version || '3.10' }}
73
+
48
74
49
- - name : Install dependencies
75
+ - name : Install tox
50
76
run : |
51
- python -m pip install --upgrade pip
52
- pip install tox>=4.0
77
+ python3 -m pip install --upgrade pip
78
+ python3 -m pip install --upgrade "tox>=4.0.0" "tox-uv>=1.25.0" "uv>=0.6.6"
79
+
80
+ - name : Log installed dists
81
+ run : python3 -m pip freeze --all
53
82
54
- - name : ${{ matrix.name }}
55
- run : ${{ matrix.command }}
83
+ - run : ${{ matrix.command }}
56
84
57
- check : # This job does nothing and is only used for the branch protection
85
+ - run : ${{ matrix.command2 }}
86
+ if : ${{ matrix.command2 }}
87
+
88
+ - run : ${{ matrix.command3 }}
89
+ if : ${{ matrix.command3 }}
90
+
91
+ - run : ${{ matrix.command4 }}
92
+ if : ${{ matrix.command4 }}
93
+
94
+ - run : ${{ matrix.command5 }}
95
+ if : ${{ matrix.command5 }}
96
+
97
+ - name : Archive logs
98
+ uses : coactions/upload-artifact@v4
99
+ with :
100
+ name : logs-${{ matrix.name }}.zip
101
+ include-hidden-files : true
102
+ path : |
103
+ .tox/**/.coverage*
104
+ .tox/**/coverage.xml
105
+
106
+ - name : Report failure if git reports dirty status
107
+ run : |
108
+ if [[ -n $(git status -s) ]]; then
109
+ # shellcheck disable=SC2016
110
+ echo -n '::error file=git-status::'
111
+ printf '### Failed as git reported modified and/or untracked files\n```\n%s\n```\n' "$(git status -s)" | tee -a "$GITHUB_STEP_SUMMARY"
112
+ exit 99
113
+ fi
114
+ check :
58
115
if : always()
116
+ permissions :
117
+ id-token : write
118
+ checks : read
59
119
needs :
60
120
- build
61
- runs-on : ubuntu-22.04
121
+ runs-on : ubuntu-24.04
122
+
62
123
steps :
124
+ # checkout needed for codecov action which needs codecov.yml file
125
+ - uses : actions/checkout@v4
126
+
127
+ - name : Set up Python # likely needed for coverage
128
+ uses : actions/setup-python@v5
129
+ with :
130
+ python-version : " 3.13"
131
+
132
+ - run : pip3 install 'coverage>=7.5.1'
133
+
134
+ - name : Merge logs into a single archive
135
+ uses : actions/upload-artifact/merge@v4
136
+ with :
137
+ name : logs.zip
138
+ include-hidden-files : true
139
+ pattern : logs-*.zip
140
+ # artifacts like py312.zip and py312-macos do have overlapping files
141
+ separate-directories : true
142
+
143
+ - name : Download artifacts
144
+ uses : actions/download-artifact@v4
145
+ continue-on-error : true # to allow rerunning this job
146
+ with :
147
+ name : logs.zip
148
+ path : .
149
+
150
+
151
+ - name : Upload coverage data
152
+
153
+ with :
154
+ name : ${{ matrix.name }}
155
+ # verbose: true # optional (default = false)
156
+ fail_ci_if_error : true
157
+ use_oidc : ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} # cspell:ignore oidc
158
+
63
159
- name : Decide whether the needed jobs succeeded or failed
64
160
uses : re-actors/alls-green@release/v1
65
161
with :
0 commit comments