From 3a9076deb865962fa6a987cbaa6c40b629244182 Mon Sep 17 00:00:00 2001 From: Iwan Aucamp Date: Tue, 23 Aug 2022 19:42:00 +0200 Subject: [PATCH] ci: publish test reports (#2091) Use the dorny/test-reporter GitHub Action to publish test reports for both mypy and pytest. This should make it easier to see what fails without having to dig through the rather noisy console logs. --- .github/workflows/test-report.yml | 27 +++++++++++++++++++++++++++ .github/workflows/validate.yaml | 11 +++++++++++ .gitignore | 26 ++++++++++++++++++++++++-- Taskfile.yml | 1 + tox.ini | 4 ++-- 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/test-report.yml diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml new file mode 100644 index 000000000..ad6a82883 --- /dev/null +++ b/.github/workflows/test-report.yml @@ -0,0 +1,27 @@ +name: "Test Report" +on: + workflow_run: + workflows: ["Validate"] + types: + - completed +jobs: + report: + runs-on: ubuntu-latest + permissions: + checks: write + statuses: write + steps: + - uses: dorny/test-reporter@v1 + with: + artifact: /(.*)-mypy-junit-xml$/ + name: mypy report + path: "*.xml" + reporter: java-junit + fail-on-error: "false" + - uses: dorny/test-reporter@v1 + with: + artifact: /(.*)-pytest-junit-xml$/ + name: pytest report + path: "*.xml" + reporter: java-junit + fail-on-error: "false" diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index b7fcb1574..0ed5ee7a3 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -77,9 +77,20 @@ jobs: EXTENSIVE=${{ matrix.extensive-tests || 'false' }} \ TOX_PYTHON_VERSION=${{ matrix.python-version }} \ TOXENV_SUFFIX=${{ matrix.TOXENV_SUFFIX }} \ + TOX_JUNIT_XML_PREFIX=${{ matrix.python-version }}-${{ matrix.os }}- \ gha:validate env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/upload-artifact@v2 + if: ${{ (success() || failure()) }} + with: + name: ${{ matrix.python-version }}-${{ matrix.os }}-mypy-junit-xml + path: test_reports/${{ matrix.python-version }}-${{ matrix.os }}-mypy-junit.xml + - uses: actions/upload-artifact@v2 + if: ${{ (success() || failure()) }} + with: + name: ${{ matrix.python-version }}-${{ matrix.os }}-pytest-junit-xml + path: test_reports/${{ matrix.python-version }}-${{ matrix.os }}-pytest-junit.xml extra-tasks: runs-on: ubuntu-latest strategy: diff --git a/.gitignore b/.gitignore index 43d030d5d..5c2017045 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,8 @@ test_reports/*latest.ttl # PyCharm .idea/ prepare_changelog.sh -#### vimdiff <(curl --silent -L https://github.com/github/gitignore/raw/master/Python.gitignore) .gitignore +*-junit.xml +#### vimdiff <(curl --silent -L https://github.com/github/gitignore/raw/main/Python.gitignore) .gitignore # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -109,7 +110,22 @@ ipython_config.py # install all needed dependencies. #Pipfile.lock -# PEP 582; used by e.g. github.com/David-OConnor/pyflow +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm __pypackages__/ # Celery stuff @@ -152,3 +168,9 @@ dmypy.json # Cython debug symbols cython_debug/ +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/Taskfile.yml b/Taskfile.yml index 0683b3e65..d46ca1f8d 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -120,6 +120,7 @@ tasks: - | {{if .TOX_PYTEST_ARGS}}TOX_PYTEST_ARGS={{shellQuote .TOX_PYTEST_ARGS}}{{end}} \ {{if .TOX_EXTRA_COMMAND}}TOX_EXTRA_COMMAND={{shellQuote .TOX_EXTRA_COMMAND}}{{end}} \ + {{if .TOX_JUNIT_XML_PREFIX}}TOX_JUNIT_XML_PREFIX={{shellQuote .TOX_JUNIT_XML_PREFIX}}{{end}} \ {{if .COVERAGE_FILE}}COVERAGE_FILE={{shellQuote .COVERAGE_FILE}}{{end}} \ {{.TEST_HARNESS}} \ {{._PYTHON | shellQuote}} \ diff --git a/tox.ini b/tox.ini index aa289523d..20f6e1fae 100644 --- a/tox.ini +++ b/tox.ini @@ -20,8 +20,8 @@ extras = docs: docs commands = {env:TOX_EXTRA_COMMAND:} - {env:TOX_MYPY_COMMAND:{envpython} -m mypy --show-error-context --show-error-codes} - {posargs:{envpython} -m pytest -ra --tb=native {env:TOX_PYTEST_ARGS:--cov --cov-report=}} + {env:TOX_MYPY_COMMAND:{envpython} -m mypy --show-error-context --show-error-codes --junit-xml=test_reports/{env:TOX_JUNIT_XML_PREFIX:}mypy-junit.xml} + {posargs:{envpython} -m pytest -ra --tb=native {env:TOX_PYTEST_ARGS:--junit-xml=test_reports/{env:TOX_JUNIT_XML_PREFIX:}pytest-junit.xml --cov --cov-report=}} docs: sphinx-build -n -T -W -b html -d {envdir}/doctree docs docs/_build/html [testenv:covreport]