2121 REPORTS_DIR : CI_reports
2222 PYTHON_VERSION_DEFAULT : " 3.11"
2323 POETRY_VERSION : " 1.4.1"
24+ TESTS_REPORTS_ARTIFACT : tests-reports
2425
2526jobs :
2627 coding-standards :
@@ -31,23 +32,19 @@ jobs:
3132 - name : Checkout
3233 # see https://github.com/actions/checkout
3334 uses : actions/checkout@v4
34-
3535 - name : Setup Python Environment
3636 # see https://github.com/actions/setup-python
3737 uses : actions/setup-python@v4
3838 with :
3939 python-version : ${{ env.PYTHON_VERSION_DEFAULT }}
4040 architecture : ' x64'
41-
4241 - name : Install poetry
4342 # see https://github.com/marketplace/actions/setup-poetry
4443 uses : Gr1N/setup-poetry@v8
4544 with :
4645 poetry-version : ${{ env.POETRY_VERSION }}
47-
4846 - name : Install dependencies
4947 run : poetry install --no-root
50-
5148 - name : Run tox
5249 run : poetry run tox -e flake8 -s false
5350
@@ -71,32 +68,26 @@ jobs:
7168 - name : Checkout
7269 # see https://github.com/actions/checkout
7370 uses : actions/checkout@v4
74-
7571 - name : Setup Python Environment
7672 # see https://github.com/actions/setup-python
7773 uses : actions/setup-python@v4
7874 with :
7975 python-version : ${{ matrix.python-version }}
8076 architecture : ' x64'
81-
8277 - name : Install poetry
8378 # see https://github.com/marketplace/actions/setup-poetry
8479 uses : Gr1N/setup-poetry@v8
8580 with :
8681 poetry-version : ${{ env.POETRY_VERSION }}
87-
8882 - name : Install dependencies
8983 run : poetry install --no-root
90-
9184 - name : Run tox
9285 run : poetry run tox -e mypy-${{ matrix.toxenv-factor }} -s false
9386
9487 build-and-test :
9588 name : Test (${{ matrix.os }} py${{ matrix.python-version }} ${{ matrix.toxenv-factor }})
9689 runs-on : ${{ matrix.os }}
9790 timeout-minutes : 15
98- env :
99- REPORTS_ARTIFACT : tests-reports
10091 strategy :
10192 fail-fast : false
10293 matrix :
@@ -118,57 +109,71 @@ jobs:
118109 run : |
119110 git config --global core.autocrlf false
120111 git config --global core.eol lf
121-
122112 - name : Checkout
123113 # see https://github.com/actions/checkout
124114 uses : actions/checkout@v4
125-
126115 - name : Create reports directory
127116 run : mkdir ${{ env.REPORTS_DIR }}
128-
129117 - name : Setup Python Environment
130118 # see https://github.com/actions/setup-python
131119 uses : actions/setup-python@v4
132120 with :
133121 python-version : ${{ matrix.python-version }}
134122 architecture : ' x64'
135-
136123 - name : Validate Python Environment
137124 shell : python
138125 run : |
139126 import sys
140127 print('Python %s on %s in %s' % (sys.version, sys.platform, sys.getdefaultencoding()))
141-
142128 - name : Install poetry
143129 # see https://github.com/marketplace/actions/setup-poetry
144130 uses : Gr1N/setup-poetry@v8
145131 with :
146132 poetry-version : ${{ env.POETRY_VERSION }}
147-
148133 - name : Install dependencies
149134 run : poetry install --no-root
150-
151135 - name : Ensure build successful
152136 run : poetry build
153-
154137 - name : Run tox
155138 run : poetry run tox -e py-${{ matrix.toxenv-factor }} -s false
156-
157139 - name : Generate coverage reports
158- run : >
159- poetry run coverage report &&
160- poetry run coverage xml -o ${{ env.REPORTS_DIR }}/coverage-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.toxenv-factor }}.xml &&
161- poetry run coverage html -d ${{ env.REPORTS_DIR }}
162-
140+ shell : bash
141+ run : |
142+ set -eux
143+ poetry run coverage report
144+ poetry run coverage xml -o "$REPORTS_DIR/coverage.${{ matrix.os }}_py${{ matrix.python-version }}_${{ matrix.toxenv-factor }}.cobertura.xml"
145+ # poetry run coverage lcov -o "$REPORTS_DIR/coverage.${{ matrix.os }}_py${{ matrix.python-version }}_${{ matrix.toxenv-factor }}.lcov.xml"
163146 - name : Artifact reports
164147 if : ${{ ! cancelled() }}
165148 # see https://github.com/actions/upload-artifact
166149 uses : actions/upload-artifact@v3
167150 with :
168- name : ${{ env.REPORTS_ARTIFACT }}
151+ name : ${{ env.TESTS_REPORTS_ARTIFACT }}
169152 path : ${{ env.REPORTS_DIR }}
170153 if-no-files-found : error
171154
155+ report-coverage :
156+ name : Publish test coverage
157+ needs : [ "build-and-test" ]
158+ runs-on : ubuntu-latest
159+ timeout-minutes : 5
160+ steps :
161+ - name : fetch test artifacts
162+ # see https://github.com/actions/download-artifact
163+ uses : actions/download-artifact@v3
164+ with :
165+ name : ${{ env.TESTS_REPORTS_ARTIFACT }}
166+ path : ${{ env.REPORTS_DIR }}
167+ - name : Run codacy-coverage-reporter
168+ env :
169+ CODACY_PROJECT_TOKEN : ${{ secrets.CODACY_PROJECT_TOKEN }}
170+ if : ${{ env.CODACY_PROJECT_TOKEN != '' }} # # see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-secrets
171+ # see https://github.com/codacy/codacy-coverage-reporter-action
172+ uses : codacy/codacy-coverage-reporter-action@v1
173+ with :
174+ project-token : ${{ env.CODACY_PROJECT_TOKEN }}
175+ coverage-reports : ${{ env.REPORTS_DIR }}/coverage.*
176+
172177 examples :
173178 name : Examples
174179 runs-on : ubuntu-latest
0 commit comments