-
Notifications
You must be signed in to change notification settings - Fork 159
224 lines (204 loc) · 6.93 KB
/
Copy pathtest.yml
File metadata and controls
224 lines (204 loc) · 6.93 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
name: test
on:
push:
branches:
- main
- test-me-*
pull_request:
branches:
- main
# Set permissions at the job level.
permissions: {}
jobs:
check-package:
name: Build & inspect our package.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Detect release branch version
id: release
if: startsWith(github.head_ref || '', 'release-')
run: |
VERSION="${GITHUB_HEAD_REF#release-}"
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
fi
- uses: hynek/build-and-inspect-python-package@fe0a0fb1925ca263d076ca4f2c13e93a6e92a33e # v2.17.0
env:
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PLUGGY: ${{ steps.release.outputs.version || '' }}
test:
needs: [check-package]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
name: [
"windows-py310",
"windows-py314",
"windows-pypy3",
"ubuntu-py310-pytestmain",
"ubuntu-py310",
"ubuntu-py311",
"ubuntu-py312",
"ubuntu-py313",
"ubuntu-py314",
"ubuntu-pypy3",
"ubuntu-benchmark",
]
include:
- name: "windows-py310"
python: "3.10"
os: windows-latest
tox_env: "py310"
- name: "windows-py313"
python: "3.13"
os: windows-latest
tox_env: "py313"
- name: "windows-py314"
python: "3.14"
os: windows-latest
tox_env: "py314"
- name: "windows-pypy3"
python: "pypy3.10"
os: windows-latest
tox_env: "pypy3"
- name: "ubuntu-py310-pytestmain"
python: "3.10"
os: ubuntu-latest
tox_env: "py310-pytestmain"
use_coverage: true
- name: "ubuntu-py310"
python: "3.10"
os: ubuntu-latest
tox_env: "py310"
use_coverage: true
- name: "ubuntu-py311"
python: "3.11"
os: ubuntu-latest
tox_env: "py311"
use_coverage: true
- name: "ubuntu-py312"
python: "3.12"
os: ubuntu-latest
tox_env: "py312"
use_coverage: true
- name: "ubuntu-py313"
python: "3.13"
os: ubuntu-latest
tox_env: "py313"
use_coverage: true
- name: "ubuntu-py314"
python: "3.14"
os: ubuntu-latest
tox_env: "py314"
use_coverage: true
- name: "ubuntu-pypy3"
python: "pypy3.10"
os: ubuntu-latest
tox_env: "pypy3"
use_coverage: true
- name: "ubuntu-benchmark"
python: "3.10"
os: ubuntu-latest
tox_env: "benchmark"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Download built packages from the check-package job.
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages
path: dist
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python }}
allow-prereleases: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install tox coverage
- name: Test without coverage
if: "! matrix.use_coverage"
shell: bash
run: "tox run --installpkg dist/*.whl"
env:
TOX_ENV: ${{ matrix.tox_env }}
- name: Test with coverage
if: "matrix.use_coverage"
shell: bash
run: "tox run --installpkg dist/*.whl"
env:
TOX_ENV: ${{ matrix.tox_env }}-coverage
- name: Upload coverage
if: matrix.use_coverage && github.repository == 'pytest-dev/pluggy'
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
continue-on-error: true
with:
fail_ci_if_error: true
files: ./coverage.xml
verbose: true
release-artifacts:
name: Update draft GitHub release
needs: [check-package, test]
if: >-
github.repository == 'pytest-dev/pluggy'
&& github.event_name == 'pull_request'
&& startsWith(github.head_ref, 'release-')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Determine version from branch
id: version
run: |
VERSION="${GITHUB_HEAD_REF#release-}"
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "::notice::Branch $GITHUB_HEAD_REF is not a release version branch — skipping."
exit 0
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: steps.version.outputs.version
with:
persist-credentials: false
- name: Download built packages
if: steps.version.outputs.version
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages
path: dist
- name: Create or update draft release
if: steps.version.outputs.version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
TAG="$VERSION"
NOTES="Release $VERSION — built from \`${{ github.head_ref }}\` at ${{ github.event.pull_request.head.sha }}."
if gh release view "$TAG" --json isDraft --jq '.isDraft' 2>/dev/null | grep -q 'true'; then
# Update existing draft: replace assets with freshly tested ones.
gh release edit "$TAG" \
--draft \
--title "pluggy $VERSION" \
--notes "$NOTES" \
--target "${{ github.event.pull_request.head.sha }}"
for asset in $(gh release view "$TAG" --json assets --jq '.assets[].name'); do
gh release delete-asset "$TAG" "$asset" --yes
done
gh release upload "$TAG" dist/*
elif gh release view "$TAG" >/dev/null 2>&1; then
# A published (non-draft) release exists — version is locked.
echo "::notice::Release $VERSION is already published — skipping."
else
# No release exists yet — create a fresh draft.
gh release create "$TAG" dist/* \
--draft \
--title "pluggy $VERSION" \
--notes "$NOTES" \
--target "${{ github.event.pull_request.head.sha }}"
fi