1
+ ---
1
2
name : tox
2
3
3
4
on :
4
- create : # is used for publishing to PyPI and TestPyPI
5
- tags : # any tag regardless of its name, no branches
6
5
push : # only publishes pushes to the main branch to TestPyPI
7
6
branches : # any integration branch but not tag
8
7
- " main"
9
- tags-ignore :
10
- - " **"
11
8
pull_request :
12
- schedule :
13
- - cron : 1 0 * * * # Run daily at 0:01 UTC
9
+ branches :
10
+ - " main"
11
+
12
+ concurrency :
13
+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
14
+ cancel-in-progress : true
15
+
16
+ env :
17
+ FORCE_COLOR : 1 # tox, pytest, ansible-lint
18
+ PY_COLORS : 1
14
19
15
20
jobs :
16
21
pre :
@@ -30,26 +35,36 @@ jobs:
30
35
docs
31
36
pkg
32
37
eco
33
- py39-devel
34
- py310-devel
38
+ py311-devel
35
39
36
40
build :
37
41
name : ${{ matrix.name }}
38
- runs-on : ubuntu-latest
42
+ runs-on : ${{ matrix.os || ' ubuntu-22.04' }}
39
43
needs : pre
40
- env :
41
- PYTEST_REQPASS : 454
44
+ defaults :
45
+ run :
46
+ shell : ${{ matrix.shell || 'bash'}}
42
47
# limit potential endless looks like we had with build-containers
43
48
timeout-minutes : 20
44
49
strategy :
45
50
fail-fast : false
46
51
matrix : ${{ fromJson(needs.pre.outputs.matrix) }}
47
52
53
+ env :
54
+ PYTEST_REQPASS : 454
48
55
steps :
49
- - name : Check out src from Git
50
- uses : actions/checkout@v3
56
+ - uses : actions/checkout@v3
51
57
with :
52
58
fetch-depth : 0 # needed by setuptools-scm
59
+ submodules : true
60
+
61
+ - name : Set pre-commit cache
62
+ uses : actions/cache@v3
63
+ if : ${{ matrix.passed_name == 'lint' }}
64
+ with :
65
+ path : |
66
+ ~/.cache/pre-commit
67
+ key : pre-commit-${{ matrix.name || matrix.passed_name }}-${{ hashFiles('.pre-commit-config.yaml') }}
53
68
- name : Install system dependencies
54
69
# remove broken .deb ansible and replace with pip version:
55
70
# https://github.com/actions/virtual-environments/issues/3001
@@ -66,18 +81,28 @@ jobs:
66
81
&& virtualenv foo \
67
82
&& source foo/bin/activate \
68
83
&& ansible --version
69
- - name : Install a default Python
84
+ - name : Set up Python ${{ matrix.python_version || '3.9' }}
85
+ if : " !contains(matrix.shell, 'wsl')"
70
86
uses : actions/setup-python@v4
71
87
with :
72
- python-version : ${{ matrix.python_version }}
73
- - name : Install dependencies
74
- run : |
75
- python3 -m pip install -U pip 'coverage[toml]'
76
- python3 -m pip install 'tox>=4.0.0'
77
- - name : Run tox -e ${{ matrix.passed_name }}
88
+ cache : pip
89
+ python-version : ${{ matrix.python_version || '3.9' }}
90
+
91
+ - name : Install tox
78
92
run : |
79
- ${{ matrix.PREFIX }} tox -e ${{ matrix.passed_name }}
80
- continue-on-error : ${{ matrix.experimental || false }}
93
+ python3 -m pip install --upgrade pip
94
+ python3 -m pip install --upgrade "tox>=4.0.0"
95
+
96
+ - name : Log installed dists
97
+ run : python3 -m pip freeze --all
98
+
99
+ - name : Initialize tox envs ${{ matrix.passed_name }}
100
+ run : python3 -m tox --notest --skip-missing-interpreters false -vv -e ${{ matrix.passed_name }}
101
+ timeout-minutes : 5 # average is under 1, but macos can be over 3
102
+
103
+ # sequential run improves browsing experience (almost no speed impact)
104
+ - name : tox -e ${{ matrix.passed_name }}
105
+ run : python3 -m tox -e ${{ matrix.passed_name }}
81
106
82
107
- name : Combine coverage data
83
108
if : ${{ startsWith(matrix.passed_name, 'py') }}
@@ -93,6 +118,15 @@ jobs:
93
118
token : ${{ secrets.CODECOV_TOKEN }}
94
119
verbose : true # optional (default = false)
95
120
121
+ - name : Report failure if git reports dirty status
122
+ run : |
123
+ if [[ -n $(git status -s) ]]; then
124
+ # shellcheck disable=SC2016
125
+ echo -n '::error file=git-status::'
126
+ printf '### Failed as git reported modified and/or untracked files\n```\n%s\n```\n' "$(git status -s)" | tee -a "$GITHUB_STEP_SUMMARY"
127
+ exit 99
128
+ fi
129
+ # https://github.com/actions/toolkit/issues/193
96
130
check :
97
131
if : always()
98
132
0 commit comments