Skip to content

Commit 78a615e

Browse files
committed
Refactor GitHub Actions workflows
Changes include: - Only run on PR creation/change or merge to master branch (stop running on pushes to random branches) - Combine lint and format checks into one Quality workflow which is based on running pre-commit so it includes additional formatters - Rename build workflow to tests and change how coverage data gets uploaded to codecov - Rename mypy workflow to typecheck and also make sure to run it for every version of Python as type support varies
1 parent d10e4c1 commit 78a615e

File tree

10 files changed

+157
-134
lines changed

10 files changed

+157
-134
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "Setup Python Environment"
2+
description: "Set up Python environment for the given Python version"
3+
4+
inputs:
5+
python-version:
6+
description: "Python version to use"
7+
required: true
8+
default: "3.13"
9+
uv-version:
10+
description: "uv version to use"
11+
required: true
12+
default: "0.7.8"
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: ${{ inputs.python-version }}
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v6
23+
with:
24+
version: ${{ inputs.uv-version }}
25+
enable-cache: "true"
26+
cache-suffix: ${{ matrix.python-version }}
27+
28+
- name: Install Python dependencies
29+
run: uv sync --frozen
30+
shell: bash

.github/workflows/build.yml

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

.github/workflows/doc.yml

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

.github/workflows/docs.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# For documentation on GitHub Actions Workflows, see:
2+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
3+
name: Docs
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
push:
8+
branches: [master]
9+
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
check-docs:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check out
20+
uses: actions/checkout@v4
21+
22+
- name: Set up the environment
23+
uses: ./.github/actions/setup-python-env
24+
25+
- name: Check if documentation can be built
26+
run: uv run mkdocs build -s

.github/workflows/format.yml

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

.github/workflows/lint.yml

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

.github/workflows/mypy.yml

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

.github/workflows/quality.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# For documentation on GitHub Actions Workflows, see:
2+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
3+
name: Quality
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
push:
8+
branches: [master]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
quality:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out
18+
uses: actions/checkout@v4
19+
20+
- uses: actions/cache@v4
21+
with:
22+
path: ~/.cache/pre-commit
23+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
24+
25+
- name: Set up the environment
26+
uses: ./.github/actions/setup-python-env
27+
28+
- name: Run pre-commit
29+
run: uv run pre-commit run -a --show-diff-on-failure

.github/workflows/tests.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# For documentation on GitHub Actions Workflows, see:
2+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
3+
name: Tests
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
push:
8+
branches: [master]
9+
10+
jobs:
11+
tests:
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14-dev"]
16+
fail-fast: false
17+
18+
runs-on: ${{ matrix.os }}
19+
defaults:
20+
run:
21+
shell: bash
22+
steps:
23+
- name: Check out
24+
uses: actions/checkout@v4
25+
26+
- name: Set up the environment
27+
uses: ./.github/actions/setup-python-env
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Run tests
32+
run: uv run inv pytest --junit --no-pty --base
33+
34+
- name: Run isolated tests
35+
run: uv run inv pytest --junit --no-pty --isolated
36+
37+
- name: Upload coverage reports to Codecov with GitHub Action on Python 3.13 for each OS
38+
uses: codecov/codecov-action@v3
39+
if: ${{ matrix.python-version == '3.13' }}

.github/workflows/typecheck.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# For documentation on GitHub Actions Workflows, see:
2+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
3+
name: TypeCheck
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
push:
8+
branches: [master]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
type-check:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14-dev"]
19+
fail-fast: false
20+
defaults:
21+
run:
22+
shell: bash
23+
steps:
24+
- name: Check out
25+
uses: actions/checkout@v4
26+
27+
- name: Set up the environment
28+
uses: ./.github/actions/setup-python-env
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
32+
- name: Check typing
33+
run: uv run mypy

0 commit comments

Comments
 (0)