21
21
REPORTS_DIR : CI_reports
22
22
PYTHON_VERSION_DEFAULT : " 3.11"
23
23
POETRY_VERSION : " 1.4.1"
24
+ TESTS_REPORTS_ARTIFACT : tests-reports
24
25
25
26
jobs :
26
27
coding-standards :
@@ -31,23 +32,19 @@ jobs:
31
32
- name : Checkout
32
33
# see https://github.com/actions/checkout
33
34
uses : actions/checkout@v4
34
-
35
35
- name : Setup Python Environment
36
36
# see https://github.com/actions/setup-python
37
37
uses : actions/setup-python@v4
38
38
with :
39
39
python-version : ${{ env.PYTHON_VERSION_DEFAULT }}
40
40
architecture : ' x64'
41
-
42
41
- name : Install poetry
43
42
# see https://github.com/marketplace/actions/setup-poetry
44
43
uses : Gr1N/setup-poetry@v8
45
44
with :
46
45
poetry-version : ${{ env.POETRY_VERSION }}
47
-
48
46
- name : Install dependencies
49
47
run : poetry install --no-root
50
-
51
48
- name : Run tox
52
49
run : poetry run tox -e flake8 -s false
53
50
@@ -71,32 +68,26 @@ jobs:
71
68
- name : Checkout
72
69
# see https://github.com/actions/checkout
73
70
uses : actions/checkout@v4
74
-
75
71
- name : Setup Python Environment
76
72
# see https://github.com/actions/setup-python
77
73
uses : actions/setup-python@v4
78
74
with :
79
75
python-version : ${{ matrix.python-version }}
80
76
architecture : ' x64'
81
-
82
77
- name : Install poetry
83
78
# see https://github.com/marketplace/actions/setup-poetry
84
79
uses : Gr1N/setup-poetry@v8
85
80
with :
86
81
poetry-version : ${{ env.POETRY_VERSION }}
87
-
88
82
- name : Install dependencies
89
83
run : poetry install --no-root
90
-
91
84
- name : Run tox
92
85
run : poetry run tox -e mypy-${{ matrix.toxenv-factor }} -s false
93
86
94
87
build-and-test :
95
88
name : Test (${{ matrix.os }} py${{ matrix.python-version }} ${{ matrix.toxenv-factor }})
96
89
runs-on : ${{ matrix.os }}
97
90
timeout-minutes : 15
98
- env :
99
- REPORTS_ARTIFACT : tests-reports
100
91
strategy :
101
92
fail-fast : false
102
93
matrix :
@@ -118,57 +109,71 @@ jobs:
118
109
run : |
119
110
git config --global core.autocrlf false
120
111
git config --global core.eol lf
121
-
122
112
- name : Checkout
123
113
# see https://github.com/actions/checkout
124
114
uses : actions/checkout@v4
125
-
126
115
- name : Create reports directory
127
116
run : mkdir ${{ env.REPORTS_DIR }}
128
-
129
117
- name : Setup Python Environment
130
118
# see https://github.com/actions/setup-python
131
119
uses : actions/setup-python@v4
132
120
with :
133
121
python-version : ${{ matrix.python-version }}
134
122
architecture : ' x64'
135
-
136
123
- name : Validate Python Environment
137
124
shell : python
138
125
run : |
139
126
import sys
140
127
print('Python %s on %s in %s' % (sys.version, sys.platform, sys.getdefaultencoding()))
141
-
142
128
- name : Install poetry
143
129
# see https://github.com/marketplace/actions/setup-poetry
144
130
uses : Gr1N/setup-poetry@v8
145
131
with :
146
132
poetry-version : ${{ env.POETRY_VERSION }}
147
-
148
133
- name : Install dependencies
149
134
run : poetry install --no-root
150
-
151
135
- name : Ensure build successful
152
136
run : poetry build
153
-
154
137
- name : Run tox
155
138
run : poetry run tox -e py-${{ matrix.toxenv-factor }} -s false
156
-
157
139
- 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"
163
146
- name : Artifact reports
164
147
if : ${{ ! cancelled() }}
165
148
# see https://github.com/actions/upload-artifact
166
149
uses : actions/upload-artifact@v3
167
150
with :
168
- name : ${{ env.REPORTS_ARTIFACT }}
151
+ name : ${{ env.TESTS_REPORTS_ARTIFACT }}
169
152
path : ${{ env.REPORTS_DIR }}
170
153
if-no-files-found : error
171
154
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
+
172
177
examples :
173
178
name : Examples
174
179
runs-on : ubuntu-latest
0 commit comments