Skip to content

Commit 97c821c

Browse files
authored
Update GHA jobs (#139)
1 parent d340e96 commit 97c821c

File tree

3 files changed

+105
-60
lines changed

3 files changed

+105
-60
lines changed

.github/workflows/tox.yml

Lines changed: 87 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,117 @@
1+
---
12
name: tox
23

34
on:
4-
push: # only publishes pushes to the main branch to TestPyPI
5-
branches: # any integration branch but not tag
6-
- main
7-
tags-ignore:
8-
- "**"
5+
push:
6+
branches:
7+
- "main"
98
pull_request:
9+
branches:
10+
- "main"
11+
schedule:
12+
- cron: "0 0 * * *"
13+
workflow_call:
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
17+
cancel-in-progress: true
18+
19+
env:
20+
FORCE_COLOR: 1 # tox, pytest, ansible-lint
21+
PY_COLORS: 1
1022

1123
jobs:
12-
pre:
13-
name: pre
14-
runs-on: ubuntu-22.04
24+
prepare:
25+
name: prepare
26+
runs-on: ubuntu-24.04
1527
outputs:
1628
matrix: ${{ steps.generate_matrix.outputs.matrix }}
1729
steps:
1830
- name: Determine matrix
1931
id: generate_matrix
20-
uses: coactions/dynamic-matrix@v1
32+
uses: coactions/dynamic-matrix@v4
2133
with:
2234
min_python: "3.9"
2335
other_names: |
2436
lint
2537
docs
2638
pkg
39+
alpine
2740
28-
alpine:
29-
name: alpine
30-
runs-on: ubuntu-22.04
41+
build:
42+
name: ${{ matrix.name }}
43+
runs-on: ${{ matrix.os || 'ubuntu-24.04' }}
44+
needs:
45+
- prepare
46+
strategy:
47+
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
3148
steps:
32-
- name: Check out code
33-
uses: actions/checkout@v4
49+
- uses: actions/checkout@v4
3450
with:
35-
fetch-depth: 0
51+
fetch-depth: 0 # needed by setuptools-scm
52+
submodules: true
3653

37-
- name: Run docker build
38-
run: docker build .
54+
- name: Set pre-commit cache
55+
uses: actions/cache@v4
56+
if: ${{ matrix.name == 'lint' }}
57+
with:
58+
path: |
59+
~/.cache/pre-commit
60+
key: pre-commit-${{ matrix.name }}-${{ hashFiles('.pre-commit-config.yaml') }}
3961

40-
unit:
41-
name: ${{ matrix.name }}
42-
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
43-
needs: pre
44-
strategy:
45-
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}
46-
steps:
62+
- name: Set up Python ${{ matrix.python_version || '3.10' }}
63+
if: "!contains(matrix.shell, 'wsl')"
64+
uses: actions/setup-python@v5
65+
with:
66+
cache: pip
67+
python-version: ${{ matrix.python_version || '3.10' }}
68+
69+
- name: Install tox
70+
run: |
71+
python3 -m pip install --upgrade pip
72+
python3 -m pip install --upgrade "tox>=4.0.0" "tox-uv>=1.16.0" uv
73+
74+
- name: Log installed dists
75+
run: python3 -m pip freeze --all
76+
77+
- run: ${{ matrix.command }}
78+
79+
- run: ${{ matrix.command2 }}
80+
if: ${{ matrix.command2 }}
4781

48-
- uses: actions/checkout@main
49-
with:
50-
fetch-depth: 0
51-
52-
- name: Set up stock Python ${{ matrix.python_version }} from GitHub
53-
uses: actions/setup-python@v5
54-
with:
55-
python-version: ${{ matrix.python_version }}
56-
57-
- name: Log the currently selected Python version info (${{ matrix.python_version }})
58-
run: |
59-
python --version --version
60-
which python
61-
62-
- name: Pip cache
63-
uses: actions/cache@v4
64-
with:
65-
path: ~/.cache/pip
66-
key: ${{ runner.os }}-pip-${{ env.PY_SHA256 }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('tox.ini') }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('pytest.ini') }}
67-
restore-keys: |
68-
${{ runner.os }}-pip-
69-
${{ runner.os }}-
70-
71-
- name: Install tox
72-
run: |
73-
python -m pip install -U pip
74-
pip install tox
75-
- name: Run tox run -e ${{ matrix.passed_name }}
76-
run: tox run -e ${{ matrix.passed_name }}
82+
- run: ${{ matrix.command3 }}
83+
if: ${{ matrix.command3 }}
84+
85+
- run: ${{ matrix.command4 }}
86+
if: ${{ matrix.command4 }}
87+
88+
- run: ${{ matrix.command5 }}
89+
if: ${{ matrix.command5 }}
90+
91+
- name: Archive logs
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: logs-${{ matrix.name }}.zip
95+
include-hidden-files: true
96+
path: |
97+
.tox/**/log/
98+
.tox/**/.coverage*
99+
.tox/**/coverage.xml
77100
101+
- name: Report failure if git reports dirty status
102+
run: |
103+
if [[ -n $(git status -s) ]]; then
104+
# shellcheck disable=SC2016
105+
echo -n '::error file=git-status::'
106+
printf '### Failed as git reported modified and/or untracked files\n```\n%s\n```\n' "$(git status -s)" | tee -a "$GITHUB_STEP_SUMMARY"
107+
exit 99
108+
fi
109+
# https://github.com/actions/toolkit/issues/193
78110
check: # This job does nothing and is only used for the branch protection
79111
if: always()
80112
needs:
81-
- unit
82-
- alpine
83-
runs-on: ubuntu-22.04
113+
- build
114+
runs-on: ubuntu-24.04
84115
steps:
85116
- name: Decide whether the needed jobs succeeded or failed
86117
uses: re-actors/alls-green@release/v1

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ test =[
6868
"enrich>=1.2.6",
6969
"molecule>=3.4.0", # ansible is needed but no direct imports are made
7070
"pytest-cov>=2.12.1",
71+
"pytest-instafail",
7172
"pytest-plus>=0.2",
7273
"pytest-xdist>=2.3.0",
7374
"pytest>=6.2.5",

tox.ini

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
[tox]
2-
minversion = 4.0
2+
minversion = 4.6.3
33
envlist =
44
lint
55
pkg
66
deps
77
py
8+
alpine
89

9-
isolated_build = True
10+
isolated_build = true
1011

1112
requires =
12-
tox>=4.0.12
13+
tox >= 4.6.3
14+
tox-uv >= 1.16.0
15+
setuptools >= 65.3.0 # editable installs
1316

1417
[testenv]
1518
usedevelop = True
@@ -41,6 +44,14 @@ allowlist_externals =
4144
sh
4245
changedir = {toxinidir}
4346

47+
[testenv:alpine]
48+
description = Tests installation on Alpine linux
49+
skip_install = true
50+
commands =
51+
docker build .
52+
allowlist_externals =
53+
docker
54+
4455
[testenv:docs]
4556
description = Build docs
4657
extras =
@@ -53,7 +64,9 @@ description = Runs all linting tasks
5364
commands =
5465
# to run a single linter you can do "pre-commit run flake8"
5566
python -m pre_commit run {posargs:--all}
56-
deps = pre-commit>=1.18.1
67+
deps =
68+
pre-commit>=1.18.1
69+
pre-commit-uv>=0.5.0
5770
extras =
5871
skip_install = true
5972
usedevelop = false

0 commit comments

Comments
 (0)