Skip to content

Commit

Permalink
Modernize CI workflow
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nicoddemus committed Oct 9, 2023
1 parent a676744 commit 9d7afbf
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 104 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: deploy

on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
default: '1.2.3'

jobs:

package:
runs-on: ubuntu-latest
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}

steps:
- uses: actions/checkout@v3

- name: Build and Check Package
uses: hynek/[email protected]

deploy:
needs: package
runs-on: ubuntu-latest
environment: deploy
permissions:
id-token: write # For PyPI trusted publishers.
contents: write # For tag and release notes.

steps:
- uses: actions/checkout@v3

- name: Download Package
uses: actions/download-artifact@v3
with:
name: Packages
path: dist

- name: Publish package to PyPI
uses: pypa/[email protected]

- name: Push tag
run: |
git config user.name "pytest bot"
git config user.email "[email protected]"
git tag --annotate --message=${{ github.event.inputs.version }} ${{ github.event.inputs.version }} ${{ github.sha }}
git push origin ${{ github.event.inputs.version }}
- name: GitHub Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
tag_name: ${{ github.event.inputs.version }}
71 changes: 0 additions & 71 deletions .github/workflows/main.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: test

on:
push:
branches:
- main
- "test-me-*"

pull_request:


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and Check Package
uses: hynek/[email protected]

test:

needs: [package]

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
python: ["3.7", "3.8", "3.9"]
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v3

- name: Download Package
uses: actions/download-artifact@v3
with:
name: Packages
path: dist

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install tox
run: |
python -m pip install --upgrade pip
pip install tox
- name: Test
shell: bash
run: |
tox run -e py --installpkg `find dist/*.tar.gz`
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repos:
- id: rst
name: rst
entry: rst-lint --encoding utf-8
files: ^(HOWTORELEASE.rst|README.rst)$
files: ^(RELEASING.rst|README.rst)$
language: python
additional_dependencies: [pygments, restructuredtext_lint]
- repo: https://github.com/myint/autoflake.git
Expand Down
29 changes: 0 additions & 29 deletions HOWTORELEASE.rst

This file was deleted.

7 changes: 7 additions & 0 deletions RELEASING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Here are the steps on how to make a new release.

1. Create a ``release-VERSION`` branch from ``upstream/main``.
2. Update ``CHANGELOG.rst``.
3. Push the branch to ``upstream``.
4. Once all tests pass, start the ``deploy`` workflow manually.
5. Merge the PR.
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[build-system]
requires = [
"setuptools",
"setuptools-scm[toml]",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "pytest_flask/_version.py"
2 changes: 1 addition & 1 deletion requirements/main.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytest>=5.2
Flask
Flask <3.0
Werkzeug>=0.7
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ keywords = pytest, flask, testing
author_email = [email protected]
url = https://github.com/pytest-dev/pytest-flask
long_description = file: README.rst, docs/changelog.rst, LICENSE
long_description_content_type = text/x-rst
description = A set of py.test fixtures to test Flask applications.
project_urls =
Source = https://github.com/pytest-dev/pytest-flask
Expand Down
2 changes: 0 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ deps =
-rrequirements/main.txt
-rrequirements/test.txt

passenv = HOME LANG LC_ALL

commands =
coverage run -m pytest {posargs:tests}
coverage combine
Expand Down

0 comments on commit 9d7afbf

Please sign in to comment.