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,121 @@ 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
+ if-no-files-found : ignore
103
+ path : |
104
+ .tox/**/.coverage*
105
+ .tox/**/coverage.xml
106
+
107
+ - name : Report failure if git reports dirty status
108
+ run : |
109
+ if [[ -n $(git status -s) ]]; then
110
+ # shellcheck disable=SC2016
111
+ echo -n '::error file=git-status::'
112
+ printf '### Failed as git reported modified and/or untracked files\n```\n%s\n```\n' "$(git status -s)" | tee -a "$GITHUB_STEP_SUMMARY"
113
+ exit 99
114
+ fi
115
+ check :
58
116
if : always()
117
+ permissions :
118
+ id-token : write
119
+ checks : read
59
120
needs :
60
121
- build
61
- runs-on : ubuntu-22.04
122
+ runs-on : ubuntu-24.04
123
+
62
124
steps :
125
+ # checkout needed for codecov action which needs codecov.yml file
126
+ - uses : actions/checkout@v4
127
+
128
+ - name : Set up Python # likely needed for coverage
129
+ uses : actions/setup-python@v5
130
+ with :
131
+ python-version : " 3.13"
132
+
133
+ - run : pip3 install 'coverage>=7.5.1'
134
+
135
+ - name : Merge logs into a single archive
136
+ uses : actions/upload-artifact/merge@v4
137
+ with :
138
+ name : logs.zip
139
+ include-hidden-files : true
140
+ pattern : logs-*.zip
141
+ # artifacts like py312.zip and py312-macos do have overlapping files
142
+ separate-directories : true
143
+
144
+ - name : Download artifacts
145
+ uses : actions/download-artifact@v4
146
+ continue-on-error : true # to allow rerunning this job
147
+ with :
148
+ name : logs.zip
149
+ path : .
150
+
151
+
152
+ - name : Upload coverage data
153
+
154
+ with :
155
+ name : ${{ matrix.name }}
156
+ # verbose: true # optional (default = false)
157
+ fail_ci_if_error : true
158
+ use_oidc : ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} # cspell:ignore oidc
159
+
63
160
- name : Decide whether the needed jobs succeeded or failed
64
161
uses : re-actors/alls-green@release/v1
65
162
with :
0 commit comments