Skip to content

Commit ad974a4

Browse files
authored
Improve CI workflow (#113)
* Deploy and tag via an action * Create package once and test over many environments * Create a GitHub release on deploy
1 parent d24a187 commit ad974a4

File tree

4 files changed

+70
-21
lines changed

4 files changed

+70
-21
lines changed

.github/workflows/deploy.yml

+38-18
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,52 @@
11
name: deploy
22

33
on:
4-
push:
5-
tags:
6-
- "v*"
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version'
8+
required: true
9+
default: '1.2.3'
10+
711
jobs:
12+
13+
package:
14+
runs-on: ubuntu-latest
15+
env:
16+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Build and Check Package
22+
uses: hynek/[email protected]
23+
824
deploy:
25+
needs: package
926
runs-on: ubuntu-latest
27+
environment: deploy
28+
permissions:
29+
id-token: write # For PyPI trusted publishers.
30+
contents: write # For tag and release notes.
1031

1132
steps:
12-
- uses: actions/checkout@v1
33+
- uses: actions/checkout@v3
1334

14-
- name: Set up Python
15-
uses: actions/setup-python@v1
35+
- name: Download Package
36+
uses: actions/download-artifact@v3
1637
with:
17-
python-version: "3.9"
38+
name: Packages
39+
path: dist
1840

19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install build
41+
- name: Publish package to PyPI
42+
uses: pypa/[email protected]
2343

24-
- name: Build package
44+
- name: Push tag
2545
run: |
26-
python -m build
46+
git config user.name "pytest bot"
47+
git config user.email "[email protected]"
48+
git tag --annotate --message=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }}
49+
git push origin v${{ github.event.inputs.version }}
2750
28-
- name: Publish package to PyPI
29-
uses: pypa/gh-action-pypi-publish@master
30-
with:
31-
user: __token__
32-
password: ${{ secrets.pypi_token }}
51+
- name: GitHub Release
52+
uses: softprops/action-gh-release@v1

.github/workflows/test.yml

+24-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
- "*"
77
pull_request:
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
compile:
1115

@@ -53,8 +57,15 @@ jobs:
5357
!tests/**/*.xml
5458
!tests/**/*.o
5559
60+
package:
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v3
64+
- name: Build and Check Package
65+
uses: hynek/[email protected]
66+
5667
test:
57-
needs: compile
68+
needs: [compile, package]
5869
runs-on: ubuntu-latest
5970

6071
strategy:
@@ -79,15 +90,25 @@ jobs:
7990
uses: actions/setup-python@v2
8091
with:
8192
python-version: ${{ matrix.python }}
93+
8294
- name: Download compiled tests
83-
uses: actions/download-artifact@v2
95+
uses: actions/download-artifact@v3
8496
with:
8597
name: tests
8698
path: tests
99+
100+
- name: Download Package
101+
uses: actions/download-artifact@v3
102+
with:
103+
name: Packages
104+
path: dist
105+
87106
- name: Install Tox
88107
run: |
89108
chmod a+x -R tests
90109
pip install tox
110+
91111
- name: Test
112+
shell: bash
92113
run: |
93-
tox -e ${{ matrix.tox_env }}
114+
tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz`

RELEASING.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Here are the steps on how to make a new release.
2+
3+
1. Create a ``release-VERSION`` branch from ``upstream/main``.
4+
2. Update ``CHANGELOG.rst``.
5+
3. Push the branch to ``upstream``.
6+
4. Once all tests pass, start the ``deploy`` workflow manually.
7+
5. Merge the PR.

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
author_email="[email protected]",
2020
description="Use pytest's runner to discover and execute C++ tests",
2121
long_description=open("README.rst").read(),
22+
long_description_content_type="text/x-rst",
2223
license="MIT",
2324
keywords="pytest test unittest",
2425
url="http://github.com/pytest-dev/pytest-cpp",

0 commit comments

Comments
 (0)