Skip to content

Improve CI workflow #11378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
name: deploy

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


# Set permissions at the job level.
permissions: {}

jobs:
build:
package:
runs-on: ubuntu-latest
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

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

deploy:
if: github.repository == 'pytest-dev/pytest'
needs: [build]
needs: [package]
runs-on: ubuntu-latest
environment: deploy
timeout-minutes: 30
permissions:
id-token: write
Expand All @@ -37,9 +42,17 @@ jobs:
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=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }}
git push origin v${{ github.event.inputs.version }}

release-notes:

# todo: generate the content in the build job
Expand All @@ -55,12 +68,12 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"


- name: Install tox
run: |
python -m pip install --upgrade pip
Expand Down
36 changes: 22 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,19 @@ concurrency:
permissions: {}

jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- name: Build and Check Package
uses: hynek/[email protected]

build:
needs: [package]

runs-on: ${{ matrix.os }}
timeout-minutes: 45
permissions:
Expand Down Expand Up @@ -58,7 +70,6 @@ jobs:
"macos-py310",
"macos-py312",

"docs",
"doctesting",
"plugins",
]
Expand Down Expand Up @@ -149,10 +160,6 @@ jobs:
os: ubuntu-latest
tox_env: "plugins"

- name: "docs"
python: "3.8"
os: ubuntu-latest
tox_env: "docs"
- name: "doctesting"
python: "3.8"
os: ubuntu-latest
Expand All @@ -165,6 +172,12 @@ jobs:
fetch-depth: 0
persist-credentials: false

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

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
Expand All @@ -178,11 +191,13 @@ jobs:

- name: Test without coverage
if: "! matrix.use_coverage"
run: "tox -e ${{ matrix.tox_env }}"
shell: bash
run: tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz`

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

- name: Generate coverage report
if: "matrix.use_coverage"
Expand All @@ -196,10 +211,3 @@ jobs:
fail_ci_if_error: true
files: ./coverage.xml
verbose: true

check-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and Check Package
uses: hynek/[email protected]
11 changes: 4 additions & 7 deletions RELEASING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,11 @@ Releasing

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

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

git fetch upstream
git tag MAJOR.MINOR.PATCH upstream/release-MAJOR.MINOR.PATCH
git push upstream MAJOR.MINOR.PATCH

Wait for the deploy to complete, then make sure it is `available on PyPI <https://pypi.org/project/pytest>`_.
This job will require approval from ``pytest-dev/core``, after which it will publish to PyPI
and tag the repository.

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

Expand Down