add option to generate test coverage report without codecov #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Python package | ||
on: | ||
workflow_call: | ||
inputs: | ||
envs: | ||
description: Array of tox environments to test | ||
required: true | ||
type: string | ||
libraries: | ||
description: Additional packages to install | ||
required: false | ||
default: '' | ||
type: string | ||
posargs: | ||
description: Positional arguments for the underlying tox test command | ||
required: false | ||
default: '' | ||
type: string | ||
toxdeps: | ||
description: Tox dependencies | ||
required: false | ||
default: '' | ||
type: string | ||
toxargs: | ||
description: Positional arguments for tox | ||
required: false | ||
default: '' | ||
type: string | ||
pytest: | ||
description: Whether pytest is run | ||
required: false | ||
default: true | ||
type: boolean | ||
pytest-results-summary: | ||
description: Whether to report test summary | ||
required: false | ||
default: false | ||
type: boolean | ||
coverage: | ||
description: Coverage providers to upload to | ||
required: false | ||
default: '' | ||
type: string | ||
conda: | ||
description: Whether to test with conda | ||
required: false | ||
default: 'auto' | ||
type: string | ||
setenv: | ||
description: A map of environment variables to be available when testing | ||
required: false | ||
default: '' | ||
type: string | ||
display: | ||
description: Whether to setup a headless display | ||
required: false | ||
default: false | ||
type: boolean | ||
cache-path: | ||
description: A list of files, directories, and wildcard patterns to cache and restore | ||
required: false | ||
default: '' | ||
type: string | ||
cache-key: | ||
description: An explicit key for restoring and saving the cache | ||
required: false | ||
default: '' | ||
type: string | ||
cache-restore-keys: | ||
description: An ordered list of keys to use for restoring the cache if no cache hit occurred for key | ||
required: false | ||
default: '' | ||
type: string | ||
artifact-path: | ||
description: A list of files, directories, and wildcard patterns to upload as artifacts | ||
required: false | ||
default: '' | ||
type: string | ||
runs-on: | ||
description: Which runner image to use for each OS | ||
required: false | ||
default: '' | ||
type: string | ||
default_python: | ||
description: Default version of Python | ||
required: false | ||
default: '3.x' | ||
type: string | ||
fail-fast: | ||
description: Whether to cancel all in-progress jobs if any job fails | ||
required: false | ||
default: false | ||
type: boolean | ||
timeout-minutes: | ||
description: The maximum number of minutes to let a job run before GitHub automatically cancels it | ||
required: false | ||
default: 360 | ||
type: number | ||
submodules: | ||
description: Whether to checkout submodules | ||
required: false | ||
default: true | ||
type: boolean | ||
checkout_ref: | ||
description: The ref to checkout | ||
required: false | ||
default: '' | ||
type: string | ||
secrets: | ||
CODECOV_TOKEN: | ||
description: Codecov upload token | ||
required: false | ||
jobs: | ||
envs: | ||
name: Load tox environments | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 | ||
with: | ||
python-version: '3.12' | ||
- run: python -m pip install PyYAML click packaging | ||
- run: echo $TOX_MATRIX_SCRIPT | base64 --decode > tox_matrix.py | ||
env: | ||
TOX_MATRIX_SCRIPT: aW1wb3J0IGpzb24KaW1wb3J0IG9zCmltcG9ydCByZQoKaW1wb3J0IGNsaWNrCmltcG9ydCB5YW1sCmZyb20gcGFja2FnaW5nLnZlcnNpb24gaW1wb3J0IEludmFsaWRWZXJzaW9uLCBWZXJzaW9uCgoKQGNsaWNrLmNvbW1hbmQoKQpAY2xpY2sub3B0aW9uKCItLWVudnMiLCBkZWZhdWx0PSIiKQpAY2xpY2sub3B0aW9uKCItLWxpYnJhcmllcyIsIGRlZmF1bHQ9IiIpCkBjbGljay5vcHRpb24oIi0tcG9zYXJncyIsIGRlZmF1bHQ9IiIpCkBjbGljay5vcHRpb24oIi0tdG94ZGVwcyIsIGRlZmF1bHQ9IiIpCkBjbGljay5vcHRpb24oIi0tdG94YXJncyIsIGRlZmF1bHQ9IiIpCkBjbGljay5vcHRpb24oIi0tcHl0ZXN0IiwgZGVmYXVsdD0idHJ1ZSIpCkBjbGljay5vcHRpb24oIi0tcHl0ZXN0LXJlc3VsdHMtc3VtbWFyeSIsIGRlZmF1bHQ9ImZhbHNlIikKQGNsaWNrLm9wdGlvbigiLS1jb3ZlcmFnZSIsIGRlZmF1bHQ9IiIpCkBjbGljay5v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nkgZWFjaCBlbnYKICAgIHN0cmluZ19wYXJhbWV0ZXJzID0gewogICAgICAgICJwb3NhcmdzIjogcG9zYXJncywKICAgICAgICAidG94ZGVwcyI6IHRveGRlcHMsCiAgICAgICAgInRveGFyZ3MiOiB0b3hhcmdzLAogICAgICAgICJweXRlc3QiOiBweXRlc3QsCiAgICAgICAgInB5dGVzdC1yZXN1bHRzLXN1bW1hcnkiOiBweXRlc3RfcmVzdWx0c19zdW1tYXJ5LAogICAgICAgICJjb3ZlcmFnZSI6IGNvdmVyYWdlLAogICAgICAgICJjb25kYSI6IGNvbmRhLAogICAgICAgICJzZXRlbnYiOiBzZXRlbnYsCiAgICAgICAgImRpc3BsYXkiOiBkaXNwbGF5LAogICAgICAgICJjYWNoZS1wYXRoIjogY2FjaGVfcGF0aCwKICAgICAgICAiY2FjaGUta2V5IjogY2FjaGVfa2V5LAogICAgICAgICJjYWNoZS1yZXN0b3JlLWtleXMiOiBjYWNoZV9yZXN0b3JlX2tleXMsCiAgICAgICAgImFydGlmYWN0LXBhdGgiOiBhcnRpZmFjdF9wYXRoLAogICAgICAgICJ0aW1lb3V0LW1pbnV0ZXMiOiB0aW1lb3V0X21pbnV0ZXMsCiAgICB9CgogICAgIyBDcmVhdGUgbWF0cml4CiAgICBtYXRyaXggPSB7ImluY2x1ZGUiOiBbXX0KICAgIGZvciBlbnYgaW4gZW52czoKICAgICAgICBtYXRyaXhbImluY2x1ZGUiXS5hcHBlbmQoZ2V0X21hdHJpeF9pdGVtKAogICAgICAgICAgICBlbnYsCiAgICAgICAgICAgIGdsb2JhbF9saWJyYXJpZXM9Z2xvYmFsX2xpYnJhcmllcywKICAgICAgICAgICAgZ2xvYmFsX3N0cmluZ19wYXJhbWV0ZXJzPXN0cmluZ19wYXJhbWV0ZXJzLAogICAgICAgICAgICBydW5zX29uPWRlZmF1bHRfcnVuc19vbiwKICAgICAgICAgICAgZGVmYXVsdF9weXRob249ZGVmYXVsdF9weXRob24sCiAgICAgICAgKSkKCiAgICAjIE91dHB1dCBtYXRyaXgKICAgIHByaW50KGpzb24uZHVtcHMobWF0cml4LCBpbmRlbnQ9MikpCiAgICB3aXRoIG9wZW4ob3MuZW52aXJvblsiR0lUSFVCX09VVFBVVCJdLCAiYSIpIGFzIGY6CiAgICAgICAgZi53cml0ZShmIm1hdHJpeD17anNvbi5kdW1wcyhtYXRyaXgpfVxuIikKCgpkZWYgZ2V0X21hdHJpeF9pdGVtKGVudiwgZ2xvYmFsX2xpYnJhcmllcywgZ2xvYmFsX3N0cmluZ19wYXJhbWV0ZXJzLAogICAgICAgICAgICAgICAgICAgIHJ1bnNfb24sIGRlZmF1bHRfcHl0aG9uKToKCiAgICAjIGRlZmluZSBzcGVjIGZvciBlYWNoIG1hdHJpeCBpbmNsdWRlICgrIGdsb2JhbF9zdHJpbmdfcGFyYW1ldGVycykKICAgIGl0ZW0gPSB7CiAgICAgICAgIm9zIjogTm9uZSwKICAgICAgICAidG94ZW52IjogTm9uZSwKICAgICAgICAicHl0aG9uX3ZlcnNpb24iOiBOb25lLAogICAgICAgICJuYW1lIjogTm9uZSwKICAgICAgICAicHl0ZXN0X2ZsYWciOiBOb25lLAogICAgICAgICJsaWJyYXJpZXNfYnJldyI6IE5vbmUsCiAgICAgICAgImxpYnJhcmllc19icmV3X2Nhc2siOiBOb25lLAogICAgICAgICJsaWJyYXJpZXNfYXB0IjogTm9uZSwKICAgICAgICAibGlicmFyaWVzX2Nob2NvIjogTm9uZSwKICAgICAgICAiY2FjaGUtcGF0aCI6IE5vbmUsCiAgICAgICAgImNhY2hlLWtleSI6IE5vbmUsCiAgICAgICAgImNhY2hlLXJlc3RvcmUta2V5cyI6IE5vbmUsCiAgICAgICAgImFydGlmYWN0LW5hbWUiOiBOb25lLAogICAgICAgICJhcnRpZmFjdC1wYXRoIjogTm9uZSwKICAgICAgICAidGltZW91dC1taW51dGVzIjogTm9uZSwKICAgIH0KICAgIGZvciBzdHJpbmdfcGFyYW0sIGRlZmF1bHQgaW4gZ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NvbmRhIl0gPSAidHJ1ZSIgaWYgImNvbmRhIiBpbiBpdGVtWyJ0b3hlbnYiXSBlbHNlICJmYWxzZSIKCiAgICAjIGluamVjdCB0b3hkZXBzIGZvciBjb25kYQogICAgaWYgaXRlbVsiY29uZGEiXSA9PSAidHJ1ZSIgYW5kICJ0b3gtY29uZGEiIG5vdCBpbiBpdGVtWyJ0b3hkZXBzIl0ubG93ZXIoKToKICAgICAgICBpdGVtWyJ0b3hkZXBzIl0gPSAoInRveC1jb25kYSAiICsgaXRlbVsidG94ZGVwcyJdKS5zdHJpcCgpCgogICAgIyBtYWtlIHRpbWVvdXQtbWludXRlcyBhIG51bWJlcgogICAgaXRlbVsidGltZW91dC1taW51dGVzIl0gPSBpbnQoaXRlbVsidGltZW91dC1taW51dGVzIl0pCgogICAgIyB2ZXJpZnkgdmFsdWVzCiAgICBhc3NlcnQgaXRlbVsicHl0ZXN0Il0gaW4geyJ0cnVlIiwgImZhbHNlIn0KICAgIGFzc2VydCBpdGVtWyJjb25kYSJdIGluIHsidHJ1ZSIsICJmYWxzZSJ9CiAgICBhc3NlcnQgaXRlbVsiZGlzcGxheSJdIGluIHsidHJ1ZSIsICJmYWxzZSJ9CgogICAgcmV0dXJuIGl0ZW0KCgppZiBfX25hbWVfXyA9PSAiX19tYWluX18iOgogICAgbG9hZF90b3hfdGFyZ2V0cygpCg== | ||
- run: cat tox_matrix.py | ||
- id: set-outputs | ||
run: | | ||
python tox_matrix.py --envs "${{ inputs.envs }}" --libraries "${{ inputs.libraries }}" \ | ||
--posargs "${{ inputs.posargs }}" --toxdeps "${{ inputs.toxdeps }}" \ | ||
--toxargs "${{ inputs.toxargs }}" --pytest "${{ inputs.pytest }}" \ | ||
--pytest-results-summary "${{ inputs.pytest-results-summary }}" \ | ||
--coverage "${{ inputs.coverage }}" --conda "${{ inputs.conda }}" \ | ||
--setenv "${{ inputs.setenv }}" \ | ||
--display "${{ inputs.display }}" --cache-path "${{ inputs.cache-path }}" \ | ||
--cache-key "${{ inputs.cache-key }}" --cache-restore-keys "${{ inputs.cache-restore-keys }}" \ | ||
--artifact-path "${{ inputs.artifact-path }}" \ | ||
--runs-on "${{ inputs.runs-on }}" --default-python "${{ inputs.default_python }}" \ | ||
--timeout-minutes "${{ inputs.timeout-minutes }}" | ||
shell: sh | ||
outputs: | ||
matrix: ${{ steps.set-outputs.outputs.matrix }} | ||
tox: | ||
name: ${{ matrix.name }} | ||
needs: [envs] | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: ${{ matrix.timeout-minutes }} | ||
strategy: | ||
fail-fast: ${{ inputs.fail-fast }} | ||
matrix: ${{fromJSON(needs.envs.outputs.matrix)}} | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
fetch-depth: 0 | ||
lfs: true | ||
submodules: ${{ inputs.submodules }} | ||
ref: ${{ inputs.checkout_ref }} | ||
- name: Cache ${{ matrix.cache_key }} | ||
if: ${{ matrix.cache-path != '' && matrix.cache-key != '' }} | ||
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | ||
with: | ||
path: ${{ matrix.cache-path }} | ||
key: ${{ matrix.cache-key }} | ||
restore-keys: ${{ matrix.cache-restore-keys }} | ||
- name: Install dependencies | ||
uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 # v1.1.0 | ||
with: | ||
brew: ${{ matrix.libraries_brew }} | ||
brew-cask: ${{ matrix.libraries_brew_cask }} | ||
apt: ${{ matrix.libraries_apt }} | ||
choco: ${{ matrix.libraries_choco }} | ||
- name: Setup Python ${{ matrix.python_version }} | ||
if: ${{ matrix.conda != 'true' }} | ||
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 | ||
with: | ||
python-version: ${{ matrix.python_version }} | ||
allow-prereleases: true | ||
- name: Setup conda | ||
if: ${{ matrix.conda == 'true' }} | ||
uses: mamba-org/setup-micromamba@06375d89d211a1232ef63355742e9e2e564bc7f7 # v2.0.2 | ||
with: | ||
environment-name: test | ||
condarc: | | ||
channels: | ||
- conda-forge | ||
create-args: >- | ||
conda | ||
python=${{ matrix.python_version }} | ||
tox | ||
init-shell: bash | ||
cache-environment: true | ||
cache-downloads: true | ||
- id: set-env | ||
if: ${{ matrix.setenv != '' }} | ||
run: | | ||
python -m pip install PyYAML | ||
echo $SET_ENV_SCRIPT | base64 --decode > set_env.py | ||
python set_env.py "${{ matrix.setenv }}" | ||
rm set_env.py | ||
env: | ||
SET_ENV_SCRIPT: aW1wb3J0IGpzb24KaW1wb3J0IG9zCmltcG9ydCBzeXMKCmltcG9ydCB5YW1sCgpHSVRIVUJfRU5WID0gb3MuZ2V0ZW52KCJHSVRIVUJfRU5WIikKaWYgR0lUSFVCX0VOViBpcyBOb25lOgogICAgcmFpc2UgVmFsdWVFcnJvcigiR0lUSFVCX0VOViBub3Qgc2V0LiBNdXN0IGJlIHJ1biBpbnNpZGUgR2l0SHViIEFjdGlvbnMuIikKCkRFTElNSVRFUiA9ICJFT0YiCgoKZGVmIHNldF9lbnYoZW52KToKCiAgICBlbnYgPSB5YW1sLmxvYWQoZW52LCBMb2FkZXI9eWFtbC5CYXNlTG9hZGVyKQogICAgcHJpbnQoanNvbi5kdW1wcyhlbnYsIGluZGVudD0yKSkKCiAgICBpZiBub3QgaXNpbnN0YW5jZShlbnYsIGRpY3QpOgogICAgICAgIHRpdGxlID0gImBlbnZgIG11c3QgYmUgbWFwcGluZyIKICAgICAgICBtZXNzYWdlID0gZiJgZW52YCBtdXN0IGJlIG1hcHBpbmcgb2YgZW52IHZhcmlhYmxlcyB0byB2YWx1ZXMsIGdvdCB0eXBlIHt0eXBlKGVudil9IgogICAgICAgIHByaW50KGYiOjplcnJvciB0aXRsZT17dGl0bGV9Ojp7bWVzc2FnZX0iKQogICAgICAgIGV4aXQoMSkKCiAgICBmb3IgaywgdiBpbiBlbnYuaXRlbXMoKToKCiAgICAgICAgaWYgbm90IGlzaW5zdGFuY2Uodiwgc3RyKToKICAgICAgICAgICAgdGl0bGUgPSAiYGVudmAgdmFsdWVzIG11c3QgYmUgc3RyaW5ncyIKICAgICAgICAgICAgbWVzc2FnZSA9IGYiYGVudmAgdmFsdWVzIG11c3QgYmUgc3RyaW5ncywgYnV0IHZhbHVlIG9mIHtrfSBoYXMgdHlwZSB7dHlwZSh2KX0iCiAgICAgICAgICAgIHByaW50KGYiOjplcnJvciB0aXRsZT17dGl0bGV9Ojp7bWVzc2FnZX0iKQogICAgICAgICAgICBleGl0KDEpCgogICAgICAgIHYgPSB2LnNwbGl0KCJcbiIpCgogICAgICAgIHdpdGggb3BlbihHSVRIVUJfRU5WLCAiYSIpIGFzIGY6CiAgICAgICAgICAgIGlmIGxlbih2KSA9PSAxOgogICAgICAgICAgICAgICAgZi53cml0ZShmIntrfT17dlswXX1cbiIpCiAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICBmb3IgbGluZSBpbiB2OgogICAgICAgICAgICAgICAgICAgIGFzc2VydCBsaW5lLnN0cmlwKCkgIT0gREVMSU1JVEVSCiAgICAgICAgICAgICAgICBmLndyaXRlKGYie2t9PDx7REVMSU1JVEVSfVxuIikKICAgICAgICAgICAgICAgIGZvciBsaW5lIGluIHY6CiAgICAgICAgICAgICAgICAgICAgZi53cml0ZShmIntsaW5lfVxuIikKICAgICAgICAgICAgICAgIGYud3JpdGUoZiJ7REVMSU1JVEVSfVxuIikKCiAgICAgICAgcHJpbnQoZiJ7a30gd3JpdHRlbiB0byBHSVRIVUJfRU5WIikKCgppZiBfX25hbWVfXyA9PSAiX19tYWluX18iOgogICAgc2V0X2VudihzeXMuYXJndlsxXSkK | ||
- name: Setup headless display | ||
if: ${{ matrix.display == 'true' }} | ||
uses: pyvista/setup-headless-display-action@4cf5c603091e085da8830e1480355ff03f3e171b # v2 | ||
- name: Install tox | ||
run: python -m pip install --upgrade tox ${{ matrix.toxdeps }} | ||
- run: python -m tox -e ${{ matrix.toxenv }} ${{ matrix.toxargs }} -- ${{ matrix.pytest_flag }} ${{ matrix.posargs }} | ||
- if: ${{ (success() || failure()) && matrix.artifact-path != '' }} | ||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | ||
with: | ||
name: ${{ matrix.artifact-name }} | ||
path: ${{ matrix.artifact-path }} | ||
- if: ${{ (success() || failure()) && matrix.pytest-results-summary == 'true' && matrix.pytest == 'true' }} | ||
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 | ||
with: | ||
paths: "**/results.xml" | ||
- name: Upload to Codecov | ||
# Even if tox fails, upload coverage | ||
if: ${{ (success() || failure()) && contains(matrix.coverage, 'codecov') && matrix.pytest == 'true' }} | ||
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
- name: Upload coverage data to GitHub | ||
if: ${{ (success() || failure()) && contains(matrix.coverage, 'github') && matrix.pytest == 'true' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: .coverage.${{ github.sha }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.toxenv }} | ||
path: **/.coverage | ||
report_overall_test_coverage: | ||
needs: [ tox ] | ||
if: always() | ||
name: report overall test coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
submodules: ${{ inputs.submodules }} | ||
ref: ${{ inputs.checkout_ref }} | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
pattern: .coverage.* | ||
merge-multiple: true | ||
- id: check_downloaded_files | ||
run: | | ||
[ "$(ls -A .coverage*)" ] && exit 0 || exit 1 | ||
continue-on-error: true | ||
- if: steps.check_downloaded_files.outcome == 'success' | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
- if: steps.check_downloaded_files.outcome == 'success' | ||
name: generate coverage report | ||
run: | | ||
python -Im pip install --upgrade coverage[toml] | ||
python -Im coverage combine | ||
python -Im coverage report -i -m --format=markdown >> $GITHUB_STEP_SUMMARY | ||
- if: steps.check_downloaded_files.outcome == 'success' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: .coverage | ||
path: .coverage |