Skip to content

Commit 3a9076d

Browse files
authored
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.
1 parent 97ed843 commit 3a9076d

File tree

5 files changed

+65
-4
lines changed

5 files changed

+65
-4
lines changed

.github/workflows/test-report.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Test Report"
2+
on:
3+
workflow_run:
4+
workflows: ["Validate"]
5+
types:
6+
- completed
7+
jobs:
8+
report:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
checks: write
12+
statuses: write
13+
steps:
14+
- uses: dorny/test-reporter@v1
15+
with:
16+
artifact: /(.*)-mypy-junit-xml$/
17+
name: mypy report
18+
path: "*.xml"
19+
reporter: java-junit
20+
fail-on-error: "false"
21+
- uses: dorny/test-reporter@v1
22+
with:
23+
artifact: /(.*)-pytest-junit-xml$/
24+
name: pytest report
25+
path: "*.xml"
26+
reporter: java-junit
27+
fail-on-error: "false"

.github/workflows/validate.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,20 @@ jobs:
7777
EXTENSIVE=${{ matrix.extensive-tests || 'false' }} \
7878
TOX_PYTHON_VERSION=${{ matrix.python-version }} \
7979
TOXENV_SUFFIX=${{ matrix.TOXENV_SUFFIX }} \
80+
TOX_JUNIT_XML_PREFIX=${{ matrix.python-version }}-${{ matrix.os }}- \
8081
gha:validate
8182
env:
8283
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
- uses: actions/upload-artifact@v2
85+
if: ${{ (success() || failure()) }}
86+
with:
87+
name: ${{ matrix.python-version }}-${{ matrix.os }}-mypy-junit-xml
88+
path: test_reports/${{ matrix.python-version }}-${{ matrix.os }}-mypy-junit.xml
89+
- uses: actions/upload-artifact@v2
90+
if: ${{ (success() || failure()) }}
91+
with:
92+
name: ${{ matrix.python-version }}-${{ matrix.os }}-pytest-junit-xml
93+
path: test_reports/${{ matrix.python-version }}-${{ matrix.os }}-pytest-junit.xml
8394
extra-tasks:
8495
runs-on: ubuntu-latest
8596
strategy:

.gitignore

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ test_reports/*latest.ttl
1212
# PyCharm
1313
.idea/
1414
prepare_changelog.sh
15-
#### vimdiff <(curl --silent -L https://github.com/github/gitignore/raw/master/Python.gitignore) .gitignore
15+
*-junit.xml
16+
#### vimdiff <(curl --silent -L https://github.com/github/gitignore/raw/main/Python.gitignore) .gitignore
1617
# Byte-compiled / optimized / DLL files
1718
__pycache__/
1819
*.py[cod]
@@ -109,7 +110,22 @@ ipython_config.py
109110
# install all needed dependencies.
110111
#Pipfile.lock
111112

112-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
113+
# poetry
114+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
115+
# This is especially recommended for binary packages to ensure reproducibility, and is more
116+
# commonly ignored for libraries.
117+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
118+
#poetry.lock
119+
120+
# pdm
121+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
122+
#pdm.lock
123+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
124+
# in version control.
125+
# https://pdm.fming.dev/#use-with-ide
126+
.pdm.toml
127+
128+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113129
__pypackages__/
114130

115131
# Celery stuff
@@ -152,3 +168,9 @@ dmypy.json
152168
# Cython debug symbols
153169
cython_debug/
154170

171+
# PyCharm
172+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174+
# and can be added to the global gitignore or merged into this file. For a more nuclear
175+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
176+
#.idea/

Taskfile.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ tasks:
120120
- |
121121
{{if .TOX_PYTEST_ARGS}}TOX_PYTEST_ARGS={{shellQuote .TOX_PYTEST_ARGS}}{{end}} \
122122
{{if .TOX_EXTRA_COMMAND}}TOX_EXTRA_COMMAND={{shellQuote .TOX_EXTRA_COMMAND}}{{end}} \
123+
{{if .TOX_JUNIT_XML_PREFIX}}TOX_JUNIT_XML_PREFIX={{shellQuote .TOX_JUNIT_XML_PREFIX}}{{end}} \
123124
{{if .COVERAGE_FILE}}COVERAGE_FILE={{shellQuote .COVERAGE_FILE}}{{end}} \
124125
{{.TEST_HARNESS}} \
125126
{{._PYTHON | shellQuote}} \

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ extras =
2020
docs: docs
2121
commands =
2222
{env:TOX_EXTRA_COMMAND:}
23-
{env:TOX_MYPY_COMMAND:{envpython} -m mypy --show-error-context --show-error-codes}
24-
{posargs:{envpython} -m pytest -ra --tb=native {env:TOX_PYTEST_ARGS:--cov --cov-report=}}
23+
{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}
24+
{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=}}
2525
docs: sphinx-build -n -T -W -b html -d {envdir}/doctree docs docs/_build/html
2626

2727
[testenv:covreport]

0 commit comments

Comments
 (0)