Skip to content

Commit eafb43d

Browse files
authored
Update project metadata and refactor build pipelines (#179)
1 parent 62c68c5 commit eafb43d

File tree

9 files changed

+347
-134
lines changed

9 files changed

+347
-134
lines changed

.github/workflows/tox.yml

Lines changed: 115 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
1+
---
12
name: tox
23

34
on:
5+
merge_group:
46
push:
57
branches:
6-
- main
8+
- "main"
79

810
pull_request:
911
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
1124

1225
jobs:
13-
pre:
14-
name: pre
15-
runs-on: ubuntu-22.04
26+
prepare:
27+
name: prepare
28+
runs-on: ubuntu-24.04
1629
outputs:
1730
matrix: ${{ steps.generate_matrix.outputs.matrix }}
1831
steps:
1932
- name: Determine matrix
2033
id: generate_matrix
21-
uses: coactions/matrix@v4
34+
uses: coactions/dynamic-matrix@v4
2235
with:
2336
min_python: "3.10"
2437
max_python: "3.14"
@@ -29,37 +42,121 @@ jobs:
2942
docs
3043
build:
3144
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
3448

3549
strategy:
3650
fail-fast: false
37-
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}
51+
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
3852

3953
steps:
4054
- uses: actions/checkout@v4
4155
with:
4256
fetch-depth: 0 # needed by setuptools-scm
57+
submodules: true
4358

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')"
4569
uses: actions/setup-python@v5
4670
with:
47-
python-version: ${{ matrix.python_version }}
71+
cache: pip
72+
python-version: ${{ matrix.python_version || '3.10' }}
73+
4874

49-
- name: Install dependencies
75+
- name: Install tox
5076
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
5382

54-
- name: ${{ matrix.name }}
55-
run: ${{ matrix.command }}
83+
- run: ${{ matrix.command }}
5684

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:
58116
if: always()
117+
permissions:
118+
id-token: write
119+
checks: read
59120
needs:
60121
- build
61-
runs-on: ubuntu-22.04
122+
runs-on: ubuntu-24.04
123+
62124
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+
uses: codecov/[email protected]
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+
63160
- name: Decide whether the needed jobs succeeded or failed
64161
uses: re-actors/alls-green@release/v1
65162
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ src/doc8/_version.py
5656
# IDE caches
5757
.idea/
5858
.vscode/
59+
junit.xml

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ repos:
1212
rev: v3.20.0
1313
hooks:
1414
- id: pyupgrade
15+
- repo: https://github.com/pappasam/toml-sort
16+
rev: v0.24.2
17+
hooks:
18+
- id: toml-sort-fix
19+
alias: toml
20+
21+
- repo: https://github.com/tox-dev/tox-ini-fmt
22+
rev: 1.5.0
23+
hooks:
24+
- id: tox-ini-fmt
25+
1526
- repo: https://github.com/psf/black
1627
rev: 25.1.0
1728
hooks:

.taplo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[formatting]
2+
# cspell: disable-next-line
3+
# compatibility between toml-sort-fix pre-commit hook and panekj.even-betterer-toml extension
4+
align_comments = false
5+
array_trailing_comma = false
6+
compact_arrays = true
7+
compact_entries = false
8+
compact_inline_tables = true
9+
inline_table_expand = false
10+
reorder_keys = true

codecov.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
comment: false
3+
coverage:
4+
status:
5+
patch: true
6+
project:
7+
default:
8+
threshold: 0.5%

0 commit comments

Comments
 (0)