-
Notifications
You must be signed in to change notification settings - Fork 34
238 lines (217 loc) · 9.28 KB
/
Copy pathpythonpackage.yml
File metadata and controls
238 lines (217 loc) · 9.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
name: Python package
on: [ push ]
# Supply-chain protection: refuse PyPI packages uploaded less than 3 days ago.
# The cutoff is computed per job as an ISO 8601 datetime (see the "Compute
# supply-chain cutoff" step). pip 26.1 added the relative-duration form
# ("P3D"), but that requires Python>=3.10 and we still test on 3.9.
jobs:
test:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
- "3.9"
changed-dir:
- "qase-api-client"
- "qase-api-v2-client"
- "qase-pytest"
- "qase-robotframework"
- "qase-python-commons"
- "qase-behave"
- "qase-tavern"
name: Project ${{ matrix.changed-dir }} - Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
list-files: "shell"
filters: |
changes:
- '${{ matrix.changed-dir }}/**'
- name: Set up Python ${{ matrix.python-version }}
if: steps.filter.outputs.changes == 'true'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Compute supply-chain cutoff
if: steps.filter.outputs.changes == 'true'
run: |
cutoff=$(date -u -d '3 days ago' +%Y-%m-%dT%H:%M:%SZ)
echo "PIP_UPLOADED_PRIOR_TO=$cutoff" >> "$GITHUB_ENV"
- name: Prefetch first-party qase-* releases (cutoff-exempt)
if: steps.filter.outputs.changes == 'true'
# qase-* packages are released from this repo's own pipeline, so the
# 3-day quarantine that guards against external supply-chain attacks
# does not need to apply to them. Otherwise a cross-package PR that
# depends on a freshly-published qase-python-commons cannot pass CI
# until the cutoff window rolls past, blocking releases for 3 days.
# Download them with the cutoff disabled into a find-links cache;
# PIP_UPLOADED_PRIOR_TO does not filter wheels resolved via
# --find-links (the flag inspects PyPI metadata, which local wheels
# do not carry). Subsequent pip invocations - including those tox
# spawns inside its venv - pick up PIP_FIND_LINKS via the
# environment.
run: |
mkdir -p /tmp/qase-wheel-cache
env -u PIP_UPLOADED_PRIOR_TO python -m pip download \
--no-deps --dest /tmp/qase-wheel-cache \
qase-python-commons qase-api-client qase-api-v2-client
echo "PIP_FIND_LINKS=/tmp/qase-wheel-cache" >> "$GITHUB_ENV"
- name: Install dependencies
if: steps.filter.outputs.changes == 'true'
run: |
# Bootstrap with PIP_UPLOADED_PRIOR_TO unset: a seeded pip older than
# 26.0 would treat the env var as an unknown --uploaded-prior-to flag
# and abort.
env -u PIP_UPLOADED_PRIOR_TO python -m pip install --upgrade 'pip>=26.0'
pip install tox tox-gh-actions
- name: Run tox
if: steps.filter.outputs.changes == 'true'
working-directory: ./${{ matrix.changed-dir }}
run: |
tox
integration-test:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Compute supply-chain cutoff
run: |
cutoff=$(date -u -d '3 days ago' +%Y-%m-%dT%H:%M:%SZ)
echo "PIP_UPLOADED_PRIOR_TO=$cutoff" >> "$GITHUB_ENV"
- name: Install reporters-validator
run: |
env -u PIP_UPLOADED_PRIOR_TO python -m pip install --upgrade 'pip>=26.0'
pip install git+https://github.com/qase-tms/reporters-validator.git
- name: Download report schemas
run: git clone --depth 1 https://github.com/qase-tms/specs.git /tmp/specs
- name: Validate Pytest reporter
run: |
python -m venv /tmp/venv-pytest
env -u PIP_UPLOADED_PRIOR_TO /tmp/venv-pytest/bin/python -m pip install --upgrade 'pip>=26.0'
/tmp/venv-pytest/bin/pip install -q \
./qase-api-client ./qase-api-v2-client ./qase-python-commons ./qase-pytest
QASE_MODE=report \
QASE_REPORT_CONNECTION_PATH=${{ github.workspace }}/build/pytest-report \
/tmp/venv-pytest/bin/python -m pytest integration/pytest/tests/ -v || true
reporters-validator validate \
--report-dir ${{ github.workspace }}/build/pytest-report \
--expected integration/pytest/expected/pytest-examples.yaml \
--schema-dir /tmp/specs/report/schemas
- name: Validate Behave reporter
run: |
python -m venv /tmp/venv-behave
env -u PIP_UPLOADED_PRIOR_TO /tmp/venv-behave/bin/python -m pip install --upgrade 'pip>=26.0'
/tmp/venv-behave/bin/pip install -q \
./qase-api-client ./qase-api-v2-client ./qase-python-commons ./qase-behave
cd integration/behave
QASE_MODE=report \
QASE_REPORT_CONNECTION_PATH=${{ github.workspace }}/build/behave-report \
/tmp/venv-behave/bin/behave --format=qase.behave.formatter:QaseFormatter --no-capture features/ || true
reporters-validator validate \
--report-dir ${{ github.workspace }}/build/behave-report \
--expected expected/behave-examples.yaml \
--schema-dir /tmp/specs/report/schemas
- name: Validate Robot Framework reporter
run: |
python -m venv /tmp/venv-robot
env -u PIP_UPLOADED_PRIOR_TO /tmp/venv-robot/bin/python -m pip install --upgrade 'pip>=26.0'
/tmp/venv-robot/bin/pip install -q \
./qase-api-client ./qase-api-v2-client ./qase-python-commons ./qase-robotframework \
robotframework
QASE_MODE=report \
QASE_REPORT_CONNECTION_PATH=${{ github.workspace }}/build/robot-report \
/tmp/venv-robot/bin/robot --listener qase.robotframework.Listener \
--outputdir /tmp/robot-output \
integration/robot/tests/ || true
reporters-validator validate \
--report-dir ${{ github.workspace }}/build/robot-report \
--expected integration/robot/expected/robot-examples.yaml \
--schema-dir /tmp/specs/report/schemas
- name: Validate Tavern reporter
run: |
python -m venv /tmp/venv-tavern
env -u PIP_UPLOADED_PRIOR_TO /tmp/venv-tavern/bin/python -m pip install --upgrade 'pip>=26.0'
/tmp/venv-tavern/bin/pip install -q \
./qase-api-client ./qase-api-v2-client ./qase-python-commons ./qase-tavern \
tavern
QASE_MODE=report \
QASE_REPORT_CONNECTION_PATH=${{ github.workspace }}/build/tavern-report \
/tmp/venv-tavern/bin/python -m pytest integration/tavern/tests/ -v || true
reporters-validator validate \
--report-dir ${{ github.workspace }}/build/tavern-report \
--expected integration/tavern/expected/tavern-examples.yaml \
--schema-dir /tmp/specs/report/schemas
build-n-publish:
runs-on: ubuntu-latest
permissions:
contents: write
needs: test
strategy:
max-parallel: 1
matrix:
prefix:
[
"qase-api-client",
"qase-api-v2-client",
"qase-pytest",
"qase-robotframework",
"qase-python-commons",
"qase-behave",
"qase-tavern"
]
if: startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
if: contains(github.event.ref, matrix.prefix)
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Compute supply-chain cutoff
if: contains(github.event.ref, matrix.prefix)
run: |
cutoff=$(date -u -d '3 days ago' +%Y-%m-%dT%H:%M:%SZ)
echo "PIP_UPLOADED_PRIOR_TO=$cutoff" >> "$GITHUB_ENV"
- name: Install build dependencies
if: contains(github.event.ref, matrix.prefix)
run: |
env -u PIP_UPLOADED_PRIOR_TO python -m pip install --upgrade 'pip>=26.0'
pip install --upgrade setuptools wheel build
- name: Build the package
if: contains(github.event.ref, matrix.prefix)
working-directory: ./${{ matrix.prefix }}
run: |
python -m build
- name: Publish distribution to PyPI
if: contains(github.event.ref, matrix.prefix)
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
packages-dir: ./${{ matrix.prefix }}/dist
- name: Extract tag name
if: contains(github.event.ref, matrix.prefix)
id: tag
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
- name: Create GitHub Release
if: contains(github.event.ref, matrix.prefix)
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: Release ${{ steps.tag.outputs.tag }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}