Skip to content

Commit b957103

Browse files
committed
ci: swap to use tox gh actions instead of the archived coactions dynamic-matrix which wasnt working anymore
1 parent cee2393 commit b957103

File tree

2 files changed

+15
-205
lines changed

2 files changed

+15
-205
lines changed

.github/workflows/tox.yml

Lines changed: 13 additions & 205 deletions
Original file line numberDiff line numberDiff line change
@@ -1,216 +1,24 @@
1-
---
2-
name: tox
3-
on:
4-
merge_group:
5-
branches:
6-
- "main"
7-
push:
8-
branches:
9-
- "main"
10-
pull_request:
11-
branches:
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
1+
name: Python package
202

21-
env:
22-
FORCE_COLOR: 1 # tox, pytest
23-
PY_COLORS: 1
3+
on:
4+
- pull_request
245

256
jobs:
26-
prepare:
27-
name: prepare
28-
runs-on: ubuntu-24.04
29-
outputs:
30-
matrix: ${{ steps.generate_matrix.outputs.matrix }}
31-
steps:
32-
- name: Determine matrix
33-
id: generate_matrix
34-
uses: coactions/dynamic-matrix@v4
35-
with:
36-
min_python: "3.10"
37-
max_python: "3.12"
38-
default_python: "3.10"
39-
other_names: |
40-
lint
41-
docs
42-
pkg
43-
devel:tox -e devel -- -k test_unit
44-
py310:tox -e py310 -- -k test_unit
45-
py311:tox -e py311 -- -k test_unit
46-
py312:tox -e py312 -- -k test_unit
47-
py310-macos:tox -e py310 -- -k test_unit
48-
py312-macos:tox -e py312 -- -k test_unit
49-
# ^ macos is also used to validate arm64 building
50-
platforms: linux,macos
51-
skip_explode: "1"
527
build:
53-
name: ${{ matrix.name }}
54-
runs-on: ${{ matrix.os || 'ubuntu-24.04' }}
55-
needs:
56-
- prepare
8+
runs-on: ubuntu-latest
579
strategy:
58-
fail-fast: false
59-
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
60-
steps:
61-
62-
- name: Install package dependencies (ubuntu)
63-
if: ${{ contains(matrix.os, 'ubuntu') }}
64-
run: |
65-
sudo apt remove -y docker-compose
66-
sudo apt-get update -y
67-
sudo apt-get --assume-yes --no-install-recommends install -y \
68-
apt-transport-https \
69-
curl \
70-
libkrb5-dev \
71-
build-essential \
72-
libffi-dev \
73-
libssl-dev \
74-
pkg-config \
75-
python3-dev
76-
python3 -m pip install --upgrade pip setuptools wheel
77-
sudo rm -rf /var/lib/apt/lists/*
78-
79-
- uses: actions/checkout@v5
80-
with:
81-
fetch-depth: 0 # needed by setuptools-scm
82-
submodules: true
83-
84-
- name: Set pre-commit cache
85-
uses: actions/cache@v4
86-
if: ${{ contains(matrix.name, 'lint') }}
87-
with:
88-
path: |
89-
~/.cache/pre-commit
90-
key: pre-commit-${{ matrix.name }}-${{ hashFiles('.pre-commit-config.yaml') }}
91-
92-
- name: Set up Python ${{ matrix.python_version || '3.10' }}
93-
uses: actions/setup-python@v6
94-
with:
95-
cache: pip
96-
python-version: ${{ matrix.python_version || '3.10' }}
97-
cache-dependency-path: "*requirements*.txt"
98-
99-
- name: Install tox
100-
run: |
101-
python3 -m pip install --upgrade pip
102-
python3 -m pip install --upgrade "tox>=4.0.0" "tox-uv>=1.25.0" "uv>=0.6.6"
103-
104-
- run: ${{ matrix.command }}
105-
106-
- run: ${{ matrix.command2 }}
107-
if: ${{ matrix.command2 }}
108-
109-
- run: ${{ matrix.command3 }}
110-
if: ${{ matrix.command3 }}
111-
112-
- run: ${{ matrix.command4 }}
113-
if: ${{ matrix.command4 }}
114-
115-
- run: ${{ matrix.command5 }}
116-
if: ${{ matrix.command5 }}
117-
118-
- name: Archive logs
119-
uses: actions/upload-artifact@v4
120-
with:
121-
name: logs-${{ matrix.name }}.zip
122-
include-hidden-files: true
123-
path: |
124-
.tox/**/log/
125-
.tox/**/.coverage*
126-
.tox/**/coverage.xml
127-
128-
- name: Report failure if git reports dirty status
129-
run: |
130-
if [[ -n $(git status -s) ]]; then
131-
# shellcheck disable=SC2016
132-
echo -n '::error file=git-status::'
133-
printf '### Failed as git reported modified and/or untracked files\n```\n%s\n```\n' "$(git status -s)" | tee -a "$GITHUB_STEP_SUMMARY"
134-
exit 99
135-
fi
136-
# https://github.com/actions/toolkit/issues/193
137-
check:
138-
if: always()
139-
environment: check
140-
permissions:
141-
id-token: write
142-
checks: read
143-
144-
needs:
145-
- build
146-
147-
runs-on: ubuntu-24.04
10+
matrix:
11+
python-version: ['3.10', '3.11', '3.12', '3.14']
14812

14913
steps:
150-
# checkout needed for codecov action which needs codecov.yml file
15114
- uses: actions/checkout@v5
152-
153-
- name: Set up Python # likely needed for coverage
15+
- name: Set up Python ${{ matrix.python-version }}
15416
uses: actions/setup-python@v6
15517
with:
156-
python-version: "3.12"
157-
158-
- run: pip3 install 'coverage>=7.5.1'
159-
160-
- name: Merge logs into a single archive
161-
uses: actions/upload-artifact/merge@v4
162-
with:
163-
name: logs.zip
164-
include-hidden-files: true
165-
pattern: logs-*.zip
166-
# artifacts like py312.zip and py312-macos do have overlapping files
167-
separate-directories: true
168-
169-
- name: Download artifacts
170-
uses: actions/download-artifact@v5
171-
continue-on-error: true # to allow rerunning this job
172-
with:
173-
name: logs.zip
174-
path: .
175-
176-
- name: Check for expected number of coverage.xml reports
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
17720
run: |
178-
JOBS_PRODUCING_COVERAGE=5
179-
if [ "$(find . -name coverage.xml | wc -l | bc)" -ne "${JOBS_PRODUCING_COVERAGE}" ]; then
180-
echo "::error::Number of coverage.xml files was not the expected one (${JOBS_PRODUCING_COVERAGE}): $(find . -name coverage.xml |xargs echo)"
181-
exit 1
182-
fi
183-
184-
# Single uploads inside check job for codecov to allow use to retry
185-
# it when it fails without running tests again. Fails often enough!
186-
- name: Upload junit xml reports
187-
# PRs from forks might not have access to the secret
188-
if: env.CODECOV_TOKEN
189-
env:
190-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN || env.CODECOV_TOKEN }}
191-
uses: codecov/test-results-action@v1
192-
with:
193-
name: ${{ matrix.name }}
194-
files: "*/tests/output/junit/*.xml"
195-
fail_ci_if_error: true
196-
token: ${{ secrets.CODECOV_TOKEN }}
197-
198-
- name: Upload coverage data
199-
uses: codecov/codecov-action@v5
200-
with:
201-
name: ${{ matrix.name }}
202-
# verbose: true # optional (default = false)
203-
fail_ci_if_error: true
204-
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} # cspell:ignore oidc
205-
206-
- name: Decide whether the needed jobs succeeded or failed
207-
uses: re-actors/alls-green@release/v1
208-
with:
209-
jobs: ${{ toJSON(needs) }}
210-
211-
- name: Delete Merged Artifacts
212-
uses: actions/upload-artifact/merge@v4
213-
with:
214-
include-hidden-files: true
215-
delete-merged: true
216-
pattern: logs-*.zip
21+
python -m pip install --upgrade pip
22+
python -m pip install tox tox-gh-actions
23+
- name: Test with tox
24+
run: tox

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ requires =
55
tox-extra>=2.1
66
tox-uv>=1.25
77
env_list =
8+
py314
89
py312
910
py311
1011
py310
@@ -173,3 +174,4 @@ python =
173174
3.10: py310
174175
3.11: py311
175176
3.12: py312
177+
3.14: py314, mypy, lint, pkg, docs

0 commit comments

Comments
 (0)