|
2 | 2 | name: tox
|
3 | 3 |
|
4 | 4 | on:
|
5 |
| - push: # only publishes pushes to the main branch to TestPyPI |
6 |
| - branches: # any integration branch but not tag |
| 5 | + push: |
| 6 | + branches: |
7 | 7 | - "main"
|
8 | 8 | pull_request:
|
9 | 9 | branches:
|
10 | 10 | - "main"
|
| 11 | + workflow_call: |
11 | 12 |
|
12 | 13 | concurrency:
|
13 | 14 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
|
14 | 15 | cancel-in-progress: true
|
15 | 16 |
|
16 |
| -env: |
17 |
| - FORCE_COLOR: 1 |
18 |
| - PY_COLORS: 1 |
19 |
| - |
20 | 17 | jobs:
|
21 |
| - prepare: |
22 |
| - name: prepare |
23 |
| - runs-on: ubuntu-22.04 |
24 |
| - outputs: |
25 |
| - matrix: ${{ steps.generate_matrix.outputs.matrix }} |
26 |
| - steps: |
27 |
| - - name: Determine matrix |
28 |
| - id: generate_matrix |
29 |
| - uses: coactions/dynamic-matrix@v2 |
30 |
| - with: |
31 |
| - default_python: "3.10" |
32 |
| - min_python: "3.10" |
33 |
| - max_python: "3.12" |
34 |
| - other_names: | |
35 |
| - lint |
36 |
| - docs |
37 |
| - platforms: linux,macos |
38 |
| - |
39 |
| - build: |
40 |
| - name: ${{ matrix.name }} |
41 |
| - runs-on: ${{ matrix.os || 'ubuntu-22.04' }} |
42 |
| - needs: |
43 |
| - - prepare |
44 |
| - defaults: |
45 |
| - run: |
46 |
| - shell: ${{ matrix.shell || 'bash'}} |
47 |
| - strategy: |
48 |
| - fail-fast: false |
49 |
| - matrix: ${{ fromJson(needs.prepare.outputs.matrix) }} |
50 |
| - env: |
51 |
| - # Number of expected test passes, safety measure for accidental skip of |
52 |
| - # tests. Update value if you add/remove tests. |
53 |
| - PYTEST_REQPASS: 1 |
54 |
| - steps: |
55 |
| - - uses: actions/checkout@v4 |
56 |
| - with: |
57 |
| - fetch-depth: 0 # needed by setuptools-scm |
58 |
| - submodules: true |
59 |
| - |
60 |
| - - name: Set pre-commit cache |
61 |
| - uses: actions/cache@v4 |
62 |
| - if: ${{ matrix.passed_name == 'lint' }} |
63 |
| - with: |
64 |
| - path: | |
65 |
| - ~/.cache/pre-commit |
66 |
| - key: pre-commit-${{ matrix.name || matrix.passed_name }}-${{ hashFiles('.pre-commit-config.yaml') }} |
67 |
| - |
68 |
| - - name: Set galaxy cache |
69 |
| - uses: actions/cache@v4 |
70 |
| - if: ${{ startsWith(matrix.passed_name, 'py') }} |
71 |
| - with: |
72 |
| - path: | |
73 |
| - examples/playbooks/collections/*.tar.gz |
74 |
| - examples/playbooks/collections/ansible_collections |
75 |
| - key: galaxy-${{ hashFiles('examples/playbooks/collections/requirements.yml') }} |
76 |
| - |
77 |
| - - name: Set up Python ${{ matrix.python_version || '3.10' }} |
78 |
| - uses: actions/setup-python@v5 |
79 |
| - with: |
80 |
| - cache: pip |
81 |
| - python-version: ${{ matrix.python_version || '3.10' }} |
82 |
| - |
83 |
| - - name: Install tox |
84 |
| - run: | |
85 |
| - python3 -m pip install --upgrade pip |
86 |
| - python3 -m pip install --upgrade "tox>=4.0.0" |
87 |
| -
|
88 |
| - - name: Log installed dists |
89 |
| - run: python3 -m pip freeze --all |
90 |
| - |
91 |
| - - name: Initialize tox envs ${{ matrix.passed_name }} |
92 |
| - run: python3 -m tox --notest --skip-missing-interpreters false -vv -e ${{ matrix.passed_name }} |
93 |
| - timeout-minutes: 5 # average is under 1, but macos can be over 3 |
94 |
| - |
95 |
| - # sequential run improves browsing experience (almost no speed impact) |
96 |
| - - name: tox -e ${{ matrix.passed_name }} |
97 |
| - run: python3 -m tox -e ${{ matrix.passed_name }} |
98 |
| - |
99 |
| - - name: Archive logs |
100 |
| - uses: actions/upload-artifact@v4 |
101 |
| - with: |
102 |
| - name: logs-${{ matrix.name }}.zip |
103 |
| - include-hidden-files: true |
104 |
| - path: | |
105 |
| - .tox/**/log/ |
106 |
| - .tox/**/.coverage* |
107 |
| - .tox/**/coverage.xml |
108 |
| -
|
109 |
| - - name: Report failure if git reports dirty status |
110 |
| - run: | |
111 |
| - if [[ -n $(git status -s) ]]; then |
112 |
| - # shellcheck disable=SC2016 |
113 |
| - echo -n '::error file=git-status::' |
114 |
| - printf '### Failed as git reported modified and/or untracked files\n```\n%s\n```\n' "$(git status -s)" | tee -a "$GITHUB_STEP_SUMMARY" |
115 |
| - exit 99 |
116 |
| - fi |
117 |
| - # https://github.com/actions/toolkit/issues/193 |
118 |
| - |
119 |
| - codeql: |
120 |
| - name: codeql |
121 |
| - runs-on: ubuntu-latest |
122 |
| - permissions: |
123 |
| - actions: read |
124 |
| - contents: read |
125 |
| - security-events: write |
126 |
| - |
127 |
| - strategy: |
128 |
| - fail-fast: false |
129 |
| - matrix: |
130 |
| - language: ["python"] |
131 |
| - |
132 |
| - steps: |
133 |
| - - name: Checkout repository |
134 |
| - uses: actions/checkout@v4 |
135 |
| - |
136 |
| - # Initializes the CodeQL tools for scanning. |
137 |
| - - name: Initialize CodeQL |
138 |
| - uses: github/codeql-action/init@v3 |
139 |
| - with: |
140 |
| - languages: ${{ matrix.language }} |
141 |
| - # If you wish to specify custom queries, you can do so here or in a config file. |
142 |
| - # By default, queries listed here will override any specified in a config file. |
143 |
| - # Prefix the list here with "+" to use these queries and those in the config file. |
144 |
| - |
145 |
| - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs |
146 |
| - # queries: security-extended,security-and-quality |
147 |
| - |
148 |
| - - name: Autobuild |
149 |
| - uses: github/codeql-action/autobuild@v3 |
150 |
| - |
151 |
| - - name: Perform CodeQL Analysis |
152 |
| - uses: github/codeql-action/analyze@v3 |
153 |
| - with: |
154 |
| - category: "/language:${{matrix.language}}" |
155 |
| - |
156 |
| - check: # This job does nothing and is only used for the branch protection |
157 |
| - if: always() |
158 |
| - permissions: |
159 |
| - id-token: write # codecov |
160 |
| - pull-requests: write # allow codenotify to comment on pull-request |
161 |
| - |
162 |
| - needs: |
163 |
| - - build |
164 |
| - - codeql |
165 |
| - |
166 |
| - runs-on: ubuntu-latest |
167 |
| - |
168 |
| - steps: |
169 |
| - # checkout needed for codecov action which needs codecov.yml file |
170 |
| - - uses: actions/checkout@v4 |
171 |
| - |
172 |
| - - name: Set up Python # likely needed for coverage |
173 |
| - uses: actions/setup-python@v5 |
174 |
| - with: |
175 |
| - python-version: "3.12" |
176 |
| - |
177 |
| - - run: pip3 install 'coverage>=7.5.1' |
178 |
| - |
179 |
| - - name: Merge logs into a single archive |
180 |
| - uses: actions/upload-artifact/merge@v4 |
181 |
| - with: |
182 |
| - name: logs.zip |
183 |
| - include-hidden-files: true |
184 |
| - pattern: logs-*.zip |
185 |
| - # artifacts like py312.zip and py312-macos do have overlapping files |
186 |
| - separate-directories: true |
187 |
| - |
188 |
| - - name: Download artifacts |
189 |
| - uses: actions/download-artifact@v4 |
190 |
| - with: |
191 |
| - name: logs.zip |
192 |
| - path: . |
193 |
| - |
194 |
| - - name: Check for expected number of coverage.xml reports |
195 |
| - run: | |
196 |
| - JOBS_PRODUCING_COVERAGE=5 |
197 |
| - if [ "$(find . -name coverage.xml | wc -l | bc)" -ne "${JOBS_PRODUCING_COVERAGE}" ]; then |
198 |
| - echo "::error::Number of coverage.xml files was not the expected one (${JOBS_PRODUCING_COVERAGE}): $(find . -name coverage.xml |xargs echo)" |
199 |
| - exit 1 |
200 |
| - fi |
201 |
| -
|
202 |
| - - name: Upload coverage data |
203 |
| - uses: codecov/codecov-action@v4 |
204 |
| - with: |
205 |
| - name: ${{ matrix.passed_name }} |
206 |
| - # verbose: true # optional (default = false) |
207 |
| - fail_ci_if_error: true |
208 |
| - use_oidc: true # cspell:ignore oidc |
209 |
| - |
210 |
| - - name: Check codecov.io status |
211 |
| - if: github.event_name == 'pull_request' |
212 |
| - uses: coactions/codecov-status@main |
213 |
| - |
214 |
| - - name: Decide whether the needed jobs succeeded or failed |
215 |
| - uses: re-actors/alls-green@release/v1 |
216 |
| - with: |
217 |
| - jobs: ${{ toJSON(needs) }} |
218 |
| - |
219 |
| - - name: Delete Merged Artifacts |
220 |
| - uses: actions/upload-artifact/merge@v4 |
221 |
| - with: |
222 |
| - include-hidden-files: true |
223 |
| - delete-merged: true |
| 18 | + tox: |
| 19 | + uses: ansible/team-devtools/.github/workflows/tox.yml@main |
| 20 | + with: |
| 21 | + jobs_producing_coverage: 7 |
| 22 | + other_names: | |
| 23 | + docs |
| 24 | + lint |
| 25 | + pkg |
| 26 | + devel |
0 commit comments