Skip to content

Commit 9e96530

Browse files
authored
Update GHA pipelines (#38)
1 parent ad5d88a commit 9e96530

File tree

5 files changed

+95
-58
lines changed

5 files changed

+95
-58
lines changed

.github/workflows/ack.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ on:
77

88
jobs:
99
ack:
10-
uses: ansible/devtools/.github/workflows/ack.yml@main
10+
uses: ansible/team-devtools/.github/workflows/ack.yml@main
11+
secrets: inherit

.github/workflows/push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ on:
1010

1111
jobs:
1212
ack:
13-
uses: ansible/devtools/.github/workflows/push.yml@main
13+
uses: ansible/team-devtools/.github/workflows/push.yml@main

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
pypi:
1111
name: Publish to PyPI registry
1212
environment: release
13-
runs-on: ubuntu-22.04
13+
runs-on: ubuntu-24.04
1414
permissions:
1515
id-token: write
1616

@@ -26,7 +26,7 @@ jobs:
2626
python-version: "3.10"
2727

2828
- name: Install tox
29-
run: python3 -m pip install --user "tox>=4.0.8"
29+
run: python3 -m pip install --user "tox>=4.0.0"
3030

3131
- name: Check out src from Git
3232
uses: actions/checkout@v4
@@ -35,7 +35,7 @@ jobs:
3535
submodules: true
3636

3737
- name: Build dists
38-
run: python -m tox
38+
run: python3 -m tox
3939

4040
- name: Publish to pypi.org
4141
if: >- # "create" workflows run separately from "push" & "pull_request"

.github/workflows/tox.yml

Lines changed: 79 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
name: tox
33

44
on:
5-
push: # only publishes pushes to the main branch to TestPyPI
6-
branches: # any integration branch but not tag
5+
push:
6+
branches:
77
- "main"
88
pull_request:
99
branches:
1010
- "main"
11+
schedule:
12+
- cron: "0 0 * * *"
13+
workflow_call:
1114

1215
concurrency:
1316
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
@@ -20,24 +23,26 @@ env:
2023
jobs:
2124
prepare:
2225
name: prepare
23-
runs-on: ubuntu-22.04
26+
runs-on: ubuntu-24.04
2427
outputs:
2528
matrix: ${{ steps.generate_matrix.outputs.matrix }}
2629
steps:
2730
- name: Determine matrix
2831
id: generate_matrix
29-
uses: coactions/dynamic-matrix@v1
32+
uses: coactions/dynamic-matrix@v4
3033
with:
31-
min_python: "3.9"
32-
max_python: "3.12"
34+
min_python: "3.10"
35+
max_python: "3.13"
36+
default_python: "3.10"
3337
other_names: |
3438
lint
3539
pkg
3640
devel
41+
platforms: linux,macos
3742
build:
3843
name: ${{ matrix.name }}
3944
environment: test
40-
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
45+
runs-on: ${{ matrix.os || 'ubuntu-24.04' }}
4146
needs:
4247
- prepare
4348
defaults:
@@ -53,56 +58,54 @@ jobs:
5358
- uses: actions/checkout@v4
5459
with:
5560
fetch-depth: 0 # needed by setuptools-scm
61+
submodules: true
5662

5763
- name: Set pre-commit cache
5864
uses: actions/cache@v4
59-
if: ${{ matrix.passed_name == 'lint' }}
65+
if: ${{ matrix.name == 'lint' }}
6066
with:
6167
path: |
6268
~/.cache/pre-commit
63-
key: pre-commit-${{ matrix.name || matrix.passed_name }}-${{ hashFiles('.pre-commit-config.yaml') }}
69+
key: pre-commit-${{ matrix.name }}-${{ hashFiles('.pre-commit-config.yaml') }}
6470

65-
- name: Set up Python ${{ matrix.python_version || '3.9' }}
71+
- name: Set up Python ${{ matrix.python_version || '3.10' }}
72+
if: "!contains(matrix.shell, 'wsl')"
6673
uses: actions/setup-python@v5
6774
with:
6875
cache: pip
69-
python-version: ${{ matrix.python_version || '3.9' }}
76+
python-version: ${{ matrix.python_version || '3.10' }}
7077

7178
- name: Install tox
7279
run: |
7380
python3 -m pip install --upgrade pip
74-
python3 -m pip install --upgrade "tox>=4.0.8"
81+
python3 -m pip install --upgrade "tox>=4.0.0" "tox-uv>=1.20.2" uv
7582
7683
- name: Log installed dists
7784
run: python3 -m pip freeze --all
7885

79-
- name: Initialize tox envs ${{ matrix.passed_name }}
80-
run: python3 -m tox --notest --skip-missing-interpreters false -vv -e ${{ matrix.passed_name }}
81-
timeout-minutes: 5 # average is under 1, but macos can be over 3
86+
- run: ${{ matrix.command }}
8287

83-
# sequential run improves browsing experience (almost no speed impact)
84-
- name: tox -e ${{ matrix.passed_name }}
85-
run: python3 -m tox -e ${{ matrix.passed_name }}
88+
- run: ${{ matrix.command2 }}
89+
if: ${{ matrix.command2 }}
8690

87-
- name: Combine coverage data
88-
if: ${{ startsWith(matrix.passed_name, 'py') }}
89-
# produce a single .coverage file at repo root
90-
run: tox -e coverage
91+
- run: ${{ matrix.command3 }}
92+
if: ${{ matrix.command3 }}
9193

92-
- name: Upload coverage data
93-
if: ${{ startsWith(matrix.passed_name, 'py') }}
94-
uses: codecov/codecov-action@v4
95-
with:
96-
name: ${{ matrix.passed_name }}
97-
token: ${{ secrets.CODECOV_TOKEN }}
98-
verbose: true # optional (default = false)
99-
fail_ci_if_error: true
94+
- run: ${{ matrix.command4 }}
95+
if: ${{ matrix.command4 }}
96+
97+
- run: ${{ matrix.command5 }}
98+
if: ${{ matrix.command5 }}
10099

101100
- name: Archive logs
102101
uses: actions/upload-artifact@v4
103102
with:
104103
name: logs-${{ matrix.name }}.zip
105-
path: .tox/**/log/
104+
include-hidden-files: true
105+
path: |
106+
.tox/**/log/
107+
.tox/**/.coverage*
108+
.tox/**/coverage.xml
106109
107110
- name: Report failure if git reports dirty status
108111
run: |
@@ -118,35 +121,64 @@ jobs:
118121
if: always()
119122
permissions:
120123
pull-requests: write # allow codenotify to comment on pull-request
121-
124+
id-token: write
125+
checks: read
122126
needs:
123127
- build
124128

125-
runs-on: ubuntu-latest
129+
runs-on: ubuntu-24.04
126130

127131
steps:
132+
# checkout needed for codecov action which needs codecov.yml file
133+
- uses: actions/checkout@v4
134+
135+
- name: Set up Python # likely needed for coverage
136+
uses: actions/setup-python@v5
137+
with:
138+
python-version: "3.13"
139+
140+
- run: pip3 install 'coverage>=7.5.1'
141+
128142
- name: Merge logs into a single archive
129143
uses: actions/upload-artifact/merge@v4
130144
with:
131145
name: logs.zip
132-
pattern: logs*.zip
133-
delete-merged: true
146+
include-hidden-files: true
147+
pattern: logs-*.zip
148+
# artifacts like py312.zip and py312-macos do have overlapping files
149+
separate-directories: true
150+
151+
- name: Download artifacts
152+
uses: actions/download-artifact@v4
153+
continue-on-error: true # to allow rerunning this job
154+
with:
155+
name: logs.zip
156+
path: .
134157

135-
- name: Check codecov.io status
136-
if: github.event_name == 'pull_request'
137-
uses: coactions/codecov-status@main
158+
- name: Check for expected number of coverage.xml reports
159+
run: |
160+
JOBS_PRODUCING_COVERAGE=6
161+
if [ "$(find . -name coverage.xml | wc -l | bc)" -ne "${JOBS_PRODUCING_COVERAGE}" ]; then
162+
echo "::error::Number of coverage.xml files was not the expected one (${JOBS_PRODUCING_COVERAGE}): $(find . -name coverage.xml |xargs echo)"
163+
exit 1
164+
fi
165+
166+
- name: Upload coverage data
167+
uses: codecov/[email protected]
168+
with:
169+
name: ${{ matrix.name }}
170+
# verbose: true # optional (default = false)
171+
fail_ci_if_error: true
172+
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} # cspell:ignore oidc
138173

139174
- name: Decide whether the needed jobs succeeded or failed
140175
uses: re-actors/alls-green@release/v1
141176
with:
142177
jobs: ${{ toJSON(needs) }}
143178

144-
- name: Check out src from Git
145-
uses: actions/checkout@v4
146-
147-
- name: Notify repository owners about lint change affecting them
148-
uses: sourcegraph/[email protected]
149-
env:
150-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151-
# https://github.com/sourcegraph/codenotify/issues/19
152-
continue-on-error: true
179+
- name: Delete Merged Artifacts
180+
uses: actions/upload-artifact/merge@v4
181+
with:
182+
include-hidden-files: true
183+
delete-merged: true
184+
pattern: logs-*.zip

tox.ini

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,24 @@ commands_pre =
1717
sh -c "rm -f .tox/.coverage.* 2>/dev/null || true"
1818
commands =
1919
pytest --collect-only
20-
# Do not use PYTEST_REQPASS as here, read README.md for details
21-
sh -c "PYTEST_REQPASS=4 coverage run -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s}"
2220
# We want to fail if result code is zero:
2321
sh -c "PYTEST_REQPASS=100 pytest >/dev/null && exit 1 || true"
24-
sh -c "coverage combine -a -q --data-file=.coverage .tox/.coverage.*"
25-
sh -c "COVERAGE_FILE=.coverage python3 -m coverage report"
22+
# Do not use PYTEST_REQPASS as here, read README.md for details
23+
sh -c "PYTEST_REQPASS=4 coverage run -m pytest {posargs: \
24+
-ra \
25+
--showlocals \
26+
--doctest-modules \
27+
--durations=10 \
28+
}"
29+
{py,py310,py311,py312,py313}: sh -c "coverage combine -a -q --data-file={env_dir}/.coverage {work_dir}/*/.coverage.* && coverage xml --data-file={env_dir}/.coverage -o {env_dir}/coverage.xml --fail-under=0"
2630
deps =
2731
-e .[test]
2832
devel: git+https://github.com/pytest-dev/pytest.git
2933
extras =
3034
test
3135
setenv =
32-
COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
33-
COVERAGE_PROCESS_START={toxinidir}/pyproject.toml
36+
COVERAGE_FILE = {env:COVERAGE_FILE:{env_dir}/.coverage.{env_name}}
37+
COVERAGE_PROCESS_START = {tox_root}/pyproject.toml
3438
PIP_DISABLE_PIP_VERSION_CHECK=1
3539
PRE_COMMIT_COLOR=always
3640
PY_COLORS={env:PY_COLORS:1}

0 commit comments

Comments
 (0)