-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(workflows): update python_package workflow to separate build and p…
…ublish steps ci(workflows): add test_and_lint workflow for testing and linting on push and PR events
- Loading branch information
1 parent
f6f244b
commit 253abe2
Showing
2 changed files
with
106 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,68 @@ | ||
name: Python package | ||
name: Publish Python package | ||
|
||
on: [push, pull_request] | ||
on: | ||
release: | ||
types: [released, prereleased] | ||
workflow_dispatch: | ||
inputs: | ||
commit: | ||
description: "Commit to build from" | ||
required: true | ||
default: "main" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
ACTIONS_RUNNER_DEBUG: true | ||
ACTIONS_STEP_DEBUG: true | ||
build-pypi-dists: | ||
name: Build Python package | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.10", "3.11"] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.inputs.commit }} | ||
# Versioneer only generates correct versions with a full fetch | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
|
||
- name: Install poetry | ||
run: pipx install poetry | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
python-version: "3.10" | ||
cache: "poetry" | ||
|
||
- name: Cache pip | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}-${{ matrix.python-version }} | ||
restore-keys: | | ||
${{ runner.os }}-pip-${{ matrix.python-version }} | ||
- name: Install python packages | ||
run: poetry install | ||
|
||
- name: Install dependencies | ||
- name: Build a binary wheel and a source tarball | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox | ||
poetry build | ||
- name: Run tests | ||
run: tox -e ${{ matrix.python-version }} | ||
- name: Publish build artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: pypi-dists | ||
path: "./dist" | ||
|
||
- name: Run lint checks | ||
run: tox -e lint | ||
publish-pypi-dists: | ||
name: Publish to PyPI | ||
environment: | ||
name: release | ||
url: https://pypi.org/p/otf-api | ||
needs: [build-pypi-dists] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
|
||
- name: Run build checks | ||
run: tox -e build | ||
steps: | ||
- name: Download build artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: pypi-dists | ||
path: "./dist" | ||
|
||
- name: Run mkdocs build | ||
run: tox -e docs | ||
- name: Publish distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Python package | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
ACTIONS_RUNNER_DEBUG: true | ||
ACTIONS_STEP_DEBUG: true | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.10", "3.11"] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Cache pip | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}-${{ matrix.python-version }} | ||
restore-keys: | | ||
${{ runner.os }}-pip-${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox | ||
- name: Run tests | ||
run: tox -e ${{ matrix.python-version }} | ||
|
||
- name: Run lint checks | ||
run: tox -e lint | ||
|
||
- name: Run mkdocs build | ||
run: tox -e docs | ||
|
||
- name: Run build checks | ||
run: tox -e build | ||
|
||
- name: Publish build artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: pypi-dists | ||
path: "./dist" |