|
14 | 14 | schedule:
|
15 | 15 | - cron: 1 0 * * * # Run daily at 0:01 UTC
|
16 | 16 |
|
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
17 | 21 | 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 |
18 | 38 | build:
|
19 |
| - name: ${{ matrix.tox_env }} |
| 39 | + name: ${{ matrix.name }} |
20 | 40 | runs-on: ubuntu-latest
|
| 41 | + needs: pre |
21 | 42 | strategy:
|
22 | 43 | 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) }} |
32 | 45 | 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 | + |
41 | 50 | # 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 |
46 | 51 | - name: Set up Python version
|
47 |
| - uses: actions/setup-python@v2 |
48 |
| - if: ${{ contains(matrix.tox_env, 'py') }} |
| 52 | + uses: actions/setup-python@v4 |
49 | 53 | with:
|
50 |
| - python-version: ${{ steps.py_ver.outputs.version }} |
| 54 | + python-version: ${{ matrix.python_version }} |
| 55 | + |
51 | 56 | - name: Install dependencies
|
52 | 57 | run: |
|
53 | 58 | docker version
|
54 | 59 | docker info
|
55 | 60 | python -m pip install -U pip
|
56 | 61 | pip install tox
|
57 |
| - - name: Run tox -e ${{ matrix.tox_env }} |
| 62 | + - name: Run tox -e ${{ matrix.passed_name }} |
58 | 63 | 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 }} |
61 | 66 |
|
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 |
64 | 71 | needs:
|
65 | 72 | - build
|
66 |
| - runs-on: ubuntu-latest |
67 |
| - |
68 |
| - env: |
69 |
| - PY_COLORS: 1 |
70 |
| - TOXENV: packaging |
| 73 | + runs-on: ubuntu-22.04 |
71 | 74 |
|
72 | 75 | 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 |
131 | 78 | with:
|
132 |
| - password: ${{ secrets.pypi_password }} |
| 79 | + jobs: ${{ toJSON(needs) }} |
0 commit comments