|
73 | 73 | description: Python version whose leg uploads the coverage report. It must be one of python-versions. |
74 | 74 | type: string |
75 | 75 | default: "3.14" |
| 76 | + coverage-flag: |
| 77 | + description: >- |
| 78 | + Name for this coverage report. When set, it is uploaded as a named |
| 79 | + parallel build and the caller must close it with ci-coveralls-finish. |
| 80 | + Leave empty for a single, self-contained report. |
| 81 | + type: string |
| 82 | + default: "" |
76 | 83 | timeout-minutes: |
77 | 84 | description: Timeout for each job. |
78 | 85 | type: number |
|
93 | 100 | defaults: |
94 | 101 | run: |
95 | 102 | shell: bash -el {0} |
| 103 | + env: |
| 104 | + COVERAGE_LEG: ${{ inputs.coverage && matrix.python-version == inputs.coverage-python-version && matrix.os == fromJSON(inputs.os)[0] }} |
96 | 105 | strategy: |
97 | 106 | fail-fast: false |
98 | 107 | matrix: |
@@ -154,27 +163,24 @@ jobs: |
154 | 163 | TEST_PATH: ${{ inputs.test-path }} |
155 | 164 | PYTEST_ARGS: ${{ inputs.pytest-args }} |
156 | 165 | PRE_TEST_COMMAND: ${{ inputs.pre-test-command }} |
157 | | - COVERAGE: ${{ inputs.coverage }} |
158 | 166 | run: | |
159 | 167 | if [ -n "${PRE_TEST_COMMAND}" ]; then |
160 | 168 | eval "${PRE_TEST_COMMAND}" |
161 | 169 | fi |
162 | 170 |
|
163 | 171 | read -r -a extra_args <<< "${PYTEST_ARGS}" |
164 | 172 | cov_args=() |
165 | | - if [ "${COVERAGE}" = "true" ]; then |
| 173 | + if [ "${COVERAGE_LEG}" = "true" ]; then |
166 | 174 | cov_args=(--cov "${PACKAGE}" --cov-report term-missing --cov-report "xml:${GITHUB_WORKSPACE}/coverage.xml") |
167 | 175 | fi |
168 | 176 | python -m pytest "${extra_args[@]}" "${cov_args[@]}" "${TEST_PATH}" |
169 | 177 |
|
170 | | - - name: Upload coverage to Coveralls |
171 | | - if: inputs.coverage && matrix.python-version == inputs.coverage-python-version && matrix.os == fromJSON(inputs.os)[0] |
172 | | - uses: coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8 |
| 178 | + - name: Save the coverage report |
| 179 | + if: env.COVERAGE_LEG == 'true' |
| 180 | + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
173 | 181 | with: |
174 | | - github-token: ${{ github.token }} |
175 | | - file: ${{ github.workspace }}/coverage.xml |
176 | | - format: cobertura |
177 | | - fail-on-error: false |
| 182 | + name: coverage-${{ inputs.package }} |
| 183 | + path: ${{ github.workspace }}/coverage.xml |
178 | 184 |
|
179 | 185 | - name: Install the lowest dependencies |
180 | 186 | if: inputs.lowest-dependencies-check |
@@ -203,3 +209,30 @@ jobs: |
203 | 209 |
|
204 | 210 | read -r -a extra_args <<< "${PYTEST_ARGS}" |
205 | 211 | python -m pytest "${extra_args[@]}" "${TEST_PATH}" |
| 212 | +
|
| 213 | + coverage: |
| 214 | + name: Coverage |
| 215 | + if: inputs.coverage |
| 216 | + needs: test |
| 217 | + runs-on: ubuntu-26.04 |
| 218 | + timeout-minutes: 10 |
| 219 | + permissions: |
| 220 | + contents: read |
| 221 | + checks: write |
| 222 | + statuses: write |
| 223 | + |
| 224 | + steps: |
| 225 | + - name: Get the coverage report |
| 226 | + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 |
| 227 | + with: |
| 228 | + name: coverage-${{ inputs.package }} |
| 229 | + |
| 230 | + - name: Upload coverage to Coveralls |
| 231 | + uses: coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8 |
| 232 | + with: |
| 233 | + github-token: ${{ github.token }} |
| 234 | + file: coverage.xml |
| 235 | + format: cobertura |
| 236 | + flag-name: ${{ inputs.coverage-flag }} |
| 237 | + parallel: ${{ inputs.coverage-flag != '' }} |
| 238 | + fail-on-error: false |
0 commit comments