Skip to content

Commit e4794b2

Browse files
authored
Merge pull request #11378 from nicoddemus/improve-ci-workflow
Improve CI workflow
2 parents afb8d66 + ab6cae2 commit e4794b2

File tree

3 files changed

+48
-30
lines changed

3 files changed

+48
-30
lines changed

.github/workflows/deploy.yml

+22-9
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
11
name: deploy
22

33
on:
4-
push:
5-
tags:
6-
# These tags are protected, see:
7-
# https://github.com/pytest-dev/pytest/settings/tag_protection
8-
- "[0-9]+.[0-9]+.[0-9]+"
9-
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version'
8+
required: true
9+
default: '1.2.3'
1010

1111

1212
# Set permissions at the job level.
1313
permissions: {}
1414

1515
jobs:
16-
build:
16+
package:
1717
runs-on: ubuntu-latest
18+
env:
19+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
1820
timeout-minutes: 10
21+
1922
steps:
2023
- uses: actions/checkout@v3
2124
with:
2225
fetch-depth: 0
2326
persist-credentials: false
27+
2428
- name: Build and Check Package
2529
uses: hynek/[email protected]
2630

2731
deploy:
2832
if: github.repository == 'pytest-dev/pytest'
29-
needs: [build]
33+
needs: [package]
3034
runs-on: ubuntu-latest
35+
environment: deploy
3136
timeout-minutes: 30
3237
permissions:
3338
id-token: write
@@ -37,9 +42,17 @@ jobs:
3742
with:
3843
name: Packages
3944
path: dist
45+
4046
- name: Publish package to PyPI
4147
uses: pypa/[email protected]
4248

49+
- name: Push tag
50+
run: |
51+
git config user.name "pytest bot"
52+
git config user.email "[email protected]"
53+
git tag --annotate --message=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }}
54+
git push origin v${{ github.event.inputs.version }}
55+
4356
release-notes:
4457

4558
# todo: generate the content in the build job
@@ -55,12 +68,12 @@ jobs:
5568
with:
5669
fetch-depth: 0
5770
persist-credentials: false
71+
5872
- name: Set up Python
5973
uses: actions/setup-python@v4
6074
with:
6175
python-version: "3.11"
6276

63-
6477
- name: Install tox
6578
run: |
6679
python -m pip install --upgrade pip

.github/workflows/test.yml

+22-14
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,19 @@ concurrency:
2727
permissions: {}
2828

2929
jobs:
30+
package:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v3
34+
with:
35+
fetch-depth: 0
36+
persist-credentials: false
37+
- name: Build and Check Package
38+
uses: hynek/[email protected]
39+
3040
build:
41+
needs: [package]
42+
3143
runs-on: ${{ matrix.os }}
3244
timeout-minutes: 45
3345
permissions:
@@ -58,7 +70,6 @@ jobs:
5870
"macos-py310",
5971
"macos-py312",
6072

61-
"docs",
6273
"doctesting",
6374
"plugins",
6475
]
@@ -149,10 +160,6 @@ jobs:
149160
os: ubuntu-latest
150161
tox_env: "plugins"
151162

152-
- name: "docs"
153-
python: "3.8"
154-
os: ubuntu-latest
155-
tox_env: "docs"
156163
- name: "doctesting"
157164
python: "3.8"
158165
os: ubuntu-latest
@@ -165,6 +172,12 @@ jobs:
165172
fetch-depth: 0
166173
persist-credentials: false
167174

175+
- name: Download Package
176+
uses: actions/download-artifact@v3
177+
with:
178+
name: Packages
179+
path: dist
180+
168181
- name: Set up Python ${{ matrix.python }}
169182
uses: actions/setup-python@v4
170183
with:
@@ -178,11 +191,13 @@ jobs:
178191
179192
- name: Test without coverage
180193
if: "! matrix.use_coverage"
181-
run: "tox -e ${{ matrix.tox_env }}"
194+
shell: bash
195+
run: tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz`
182196

183197
- name: Test with coverage
184198
if: "matrix.use_coverage"
185-
run: "tox -e ${{ matrix.tox_env }}-coverage"
199+
shell: bash
200+
run: tox run -e ${{ matrix.tox_env }}-coverage --installpkg `find dist/*.tar.gz`
186201

187202
- name: Generate coverage report
188203
if: "matrix.use_coverage"
@@ -196,10 +211,3 @@ jobs:
196211
fail_ci_if_error: true
197212
files: ./coverage.xml
198213
verbose: true
199-
200-
check-package:
201-
runs-on: ubuntu-latest
202-
steps:
203-
- uses: actions/checkout@v3
204-
- name: Build and Check Package
205-
uses: hynek/[email protected]

RELEASING.rst

+4-7
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,11 @@ Releasing
133133

134134
Both automatic and manual processes described above follow the same steps from this point onward.
135135

136-
#. After all tests pass and the PR has been approved, tag the release commit
137-
in the ``release-MAJOR.MINOR.PATCH`` branch and push it. This will publish to PyPI::
136+
#. After all tests pass and the PR has been approved, trigger the ``deploy`` job
137+
in https://github.com/pytest-dev/pytest/actions/workflows/deploy.yml.
138138

139-
git fetch upstream
140-
git tag MAJOR.MINOR.PATCH upstream/release-MAJOR.MINOR.PATCH
141-
git push upstream MAJOR.MINOR.PATCH
142-
143-
Wait for the deploy to complete, then make sure it is `available on PyPI <https://pypi.org/project/pytest>`_.
139+
This job will require approval from ``pytest-dev/core``, after which it will publish to PyPI
140+
and tag the repository.
144141

145142
#. Merge the PR. **Make sure it's not squash-merged**, so that the tagged commit ends up in the main branch.
146143

0 commit comments

Comments
 (0)