Skip to content

Commit 9d7afbf

Browse files
committed
Modernize CI workflow
This PR uses the same workflow we have been using in other projects under pytest-dev: * Separete `test` and `deploy` workflows. * `test`: build package once and test it in the supported environments, as opposed to generate one package for each environment. * `deploy`: a manually triggered action, which once successful will tag the repository and create a GH release.
1 parent a676744 commit 9d7afbf

File tree

10 files changed

+133
-104
lines changed

10 files changed

+133
-104
lines changed

.github/workflows/deploy.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: deploy
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version'
8+
required: true
9+
default: '1.2.3'
10+
11+
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+
24+
deploy:
25+
needs: package
26+
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.
31+
32+
steps:
33+
- uses: actions/checkout@v3
34+
35+
- name: Download Package
36+
uses: actions/download-artifact@v3
37+
with:
38+
name: Packages
39+
path: dist
40+
41+
- name: Publish package to PyPI
42+
uses: pypa/[email protected]
43+
44+
- name: Push tag
45+
run: |
46+
git config user.name "pytest bot"
47+
git config user.email "[email protected]"
48+
git tag --annotate --message=${{ github.event.inputs.version }} ${{ github.event.inputs.version }} ${{ github.sha }}
49+
git push origin ${{ github.event.inputs.version }}
50+
51+
- name: GitHub Release
52+
uses: softprops/action-gh-release@v1
53+
with:
54+
files: dist/*
55+
tag_name: ${{ github.event.inputs.version }}

.github/workflows/main.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "test-me-*"
8+
9+
pull_request:
10+
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
18+
package:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Build and Check Package
23+
uses: hynek/[email protected]
24+
25+
test:
26+
27+
needs: [package]
28+
29+
runs-on: ${{ matrix.os }}
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
python: ["3.7", "3.8", "3.9"]
35+
os: [ubuntu-latest, windows-latest]
36+
37+
steps:
38+
- uses: actions/checkout@v3
39+
40+
- name: Download Package
41+
uses: actions/download-artifact@v3
42+
with:
43+
name: Packages
44+
path: dist
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v4
48+
with:
49+
python-version: ${{ matrix.python }}
50+
51+
- name: Install tox
52+
run: |
53+
python -m pip install --upgrade pip
54+
pip install tox
55+
56+
- name: Test
57+
shell: bash
58+
run: |
59+
tox run -e py --installpkg `find dist/*.tar.gz`

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
- id: rst
2828
name: rst
2929
entry: rst-lint --encoding utf-8
30-
files: ^(HOWTORELEASE.rst|README.rst)$
30+
files: ^(RELEASING.rst|README.rst)$
3131
language: python
3232
additional_dependencies: [pygments, restructuredtext_lint]
3333
- repo: https://github.com/myint/autoflake.git

HOWTORELEASE.rst

Lines changed: 0 additions & 29 deletions
This file was deleted.

RELEASING.rst

Lines changed: 7 additions & 0 deletions
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.

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[build-system]
2+
requires = [
3+
"setuptools",
4+
"setuptools-scm[toml]",
5+
]
6+
build-backend = "setuptools.build_meta"
7+
8+
[tool.setuptools_scm]
9+
write_to = "pytest_flask/_version.py"

requirements/main.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pytest>=5.2
2-
Flask
2+
Flask <3.0
33
Werkzeug>=0.7

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ keywords = pytest, flask, testing
77
author_email = [email protected]
88
url = https://github.com/pytest-dev/pytest-flask
99
long_description = file: README.rst, docs/changelog.rst, LICENSE
10+
long_description_content_type = text/x-rst
1011
description = A set of py.test fixtures to test Flask applications.
1112
project_urls =
1213
Source = https://github.com/pytest-dev/pytest-flask

tox.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ deps =
2626
-rrequirements/main.txt
2727
-rrequirements/test.txt
2828

29-
passenv = HOME LANG LC_ALL
30-
3129
commands =
3230
coverage run -m pytest {posargs:tests}
3331
coverage combine

0 commit comments

Comments
 (0)