Skip to content

Commit 8e20569

Browse files
authored
Use dynamic-matrix for getting list of tox jobs to run (#676)
1 parent a3c8287 commit 8e20569

File tree

6 files changed

+114
-94
lines changed

6 files changed

+114
-94
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: daily
8+
labels:
9+
- "dependencies"
10+
- "skip-changelog"

.github/release-drafter.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
# see https://github.com/ansible/devtools
3+
_extends: ansible/devtools

.github/workflows/ack.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
# See https://github.com/ansible/devtools/blob/main/.github/workflows/ack.yml
3+
name: ack
4+
on:
5+
pull_request_target:
6+
types: [opened, labeled, unlabeled, synchronize]
7+
8+
jobs:
9+
ack:
10+
uses: ansible/devtools/.github/workflows/ack.yml@main

.github/workflows/push.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
# See https://github.com/ansible/devtools/blob/main/.github/workflows/push.yml
3+
name: push
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- "releases/**"
9+
- "stable/**"
10+
11+
jobs:
12+
ack:
13+
uses: ansible/devtools/.github/workflows/push.yml@main

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: release
3+
4+
on:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
pypi:
10+
name: Publish to PyPI registry
11+
environment: release
12+
runs-on: ubuntu-22.04
13+
14+
env:
15+
FORCE_COLOR: 1
16+
PY_COLORS: 1
17+
TOXENV: pkg
18+
19+
steps:
20+
- name: Switch to using Python 3.9 by default
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: 3.9
24+
- name: Install tox
25+
run: python3 -m pip install --user "tox>=4.0.0"
26+
- name: Check out src from Git
27+
uses: actions/checkout@v3
28+
with:
29+
fetch-depth: 0 # needed by setuptools-scm
30+
- name: Build dists
31+
run: python -m tox
32+
- name: Publish to pypi.org
33+
if: >- # "create" workflows run separately from "push" & "pull_request"
34+
github.event_name == 'release'
35+
uses: pypa/gh-action-pypi-publish@release/v1
36+
with:
37+
password: ${{ secrets.pypi_password }}

.github/workflows/tox.yml

Lines changed: 41 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -14,119 +14,66 @@ on:
1414
schedule:
1515
- cron: 1 0 * * * # Run daily at 0:01 UTC
1616

17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
19+
cancel-in-progress: true
20+
1721
jobs:
22+
pre:
23+
name: pre
24+
runs-on: ubuntu-22.04
25+
outputs:
26+
matrix: ${{ steps.generate_matrix.outputs.matrix }}
27+
steps:
28+
- name: Determine matrix
29+
id: generate_matrix
30+
uses: coactions/matrix@main
31+
with:
32+
min_python: "3.8"
33+
max_python: "3.10"
34+
other_names: |
35+
lint
36+
docs
37+
packaging
1838
build:
19-
name: ${{ matrix.tox_env }}
39+
name: ${{ matrix.name }}
2040
runs-on: ubuntu-latest
41+
needs: pre
2142
strategy:
2243
fail-fast: false
23-
matrix:
24-
include:
25-
- tox_env: lint
26-
- tox_env: docs
27-
- tox_env: py38
28-
- tox_env: py39
29-
- tox_env: py310
30-
- tox_env: packaging
31-
44+
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}
3245
steps:
33-
- uses: actions/checkout@v1
34-
- name: Find python version
35-
id: py_ver
36-
shell: python
37-
if: ${{ contains(matrix.tox_env, 'py') }}
38-
run: |
39-
v = '${{ matrix.tox_env }}'.split('-')[0].lstrip('py')
40-
print('::set-output name=version::{0}.{1}'.format(v[0],v[1:]))
46+
- uses: actions/checkout@v3
47+
with:
48+
fetch-depth: 0
49+
4150
# Even our lint and other envs need access to tox
42-
- name: Install a default Python
43-
uses: actions/setup-python@v2
44-
if: ${{ ! contains(matrix.tox_env, 'py') }}
45-
# Be sure to install the version of python needed by a specific test, if necessary
4651
- name: Set up Python version
47-
uses: actions/setup-python@v2
48-
if: ${{ contains(matrix.tox_env, 'py') }}
52+
uses: actions/setup-python@v4
4953
with:
50-
python-version: ${{ steps.py_ver.outputs.version }}
54+
python-version: ${{ matrix.python_version }}
55+
5156
- name: Install dependencies
5257
run: |
5358
docker version
5459
docker info
5560
python -m pip install -U pip
5661
pip install tox
57-
- name: Run tox -e ${{ matrix.tox_env }}
62+
- name: Run tox -e ${{ matrix.passed_name }}
5863
run: |
59-
echo "${{ matrix.PREFIX }} tox -e ${{ matrix.tox_env }}"
60-
${{ matrix.PREFIX }} tox -e ${{ matrix.tox_env }}
64+
echo "${{ matrix.PREFIX }} tox -e ${{ matrix.passed_name }}"
65+
${{ matrix.PREFIX }} tox -e ${{ matrix.passed_name }}
6166
62-
publish:
63-
name: Publish to PyPI registry
67+
check: # This job does nothing and is only used for the branch protection
68+
if: always()
69+
permissions:
70+
pull-requests: write # allow codenotify to comment on pull-request
6471
needs:
6572
- build
66-
runs-on: ubuntu-latest
67-
68-
env:
69-
PY_COLORS: 1
70-
TOXENV: packaging
73+
runs-on: ubuntu-22.04
7174

7275
steps:
73-
- name: Switch to using Python 3.8 by default
74-
uses: actions/setup-python@v2
75-
with:
76-
python-version: 3.8
77-
- name: Install tox
78-
run: python -m pip install --user tox
79-
- name: Check out src from Git
80-
uses: actions/checkout@v2
81-
with:
82-
# Get shallow Git history (default) for release events
83-
# but have a complete clone for any other workflows.
84-
# Both options fetch tags but since we're going to remove
85-
# one from HEAD in non-create-tag workflows, we need full
86-
# history for them.
87-
fetch-depth: >-
88-
${{
89-
(
90-
(
91-
github.event_name == 'create' &&
92-
github.event.ref_type == 'tag'
93-
) ||
94-
github.event_name == 'release'
95-
) &&
96-
1 || 0
97-
}}
98-
- name: Drop Git tags from HEAD for non-tag-create and non-release events
99-
if: >-
100-
(
101-
github.event_name != 'create' ||
102-
github.event.ref_type != 'tag'
103-
) &&
104-
github.event_name != 'release'
105-
run: >-
106-
git tag --points-at HEAD
107-
|
108-
xargs git tag --delete
109-
- name: Build dists
110-
run: python -m tox
111-
- name: Publish to test.pypi.org
112-
if: >-
113-
(
114-
github.event_name == 'push' &&
115-
github.ref == format(
116-
'refs/heads/{0}', github.event.repository.default_branch
117-
)
118-
) ||
119-
(
120-
github.event_name == 'create' &&
121-
github.event.ref_type == 'tag'
122-
)
123-
uses: pypa/gh-action-pypi-publish@master
124-
with:
125-
password: ${{ secrets.testpypi_password }}
126-
repository_url: https://test.pypi.org/legacy/
127-
- name: Publish to pypi.org
128-
if: >- # "create" workflows run separately from "push" & "pull_request"
129-
github.event_name == 'release'
130-
uses: pypa/gh-action-pypi-publish@master
76+
- name: Decide whether the needed jobs succeeded or failed
77+
uses: re-actors/alls-green@release/v1
13178
with:
132-
password: ${{ secrets.pypi_password }}
79+
jobs: ${{ toJSON(needs) }}

0 commit comments

Comments
 (0)