Skip to content

Commit 25612d0

Browse files
authored
Draft: Refactor GitHub Actions workflows (#1432)
* 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 25612d0

File tree

9 files changed

+118
-106
lines changed

9 files changed

+118
-106
lines changed

.github/workflows/doc.yml

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

.github/workflows/docs.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
with:
22+
fetch-depth: 0 # Needed for setuptools_scm to work correctly
23+
24+
- name: Install uv and set the python version
25+
uses: astral-sh/setup-uv@v6
26+
with:
27+
python-version: "3.13"
28+
- name: Install the project
29+
run: uv sync --group docs
30+
- name: Check if the MkDocs documentation can be built
31+
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: 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: 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+
with:
20+
fetch-depth: 0 # Needed for setuptools_scm to work correctly
21+
22+
- uses: actions/cache@v4
23+
with:
24+
path: ~/.cache/pre-commit
25+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
26+
- name: Install uv and set the python version
27+
uses: astral-sh/setup-uv@v6
28+
with:
29+
python-version: "3.13"
30+
- name: Install the project
31+
run: uv sync --group quality
32+
- name: Run pre-commit
33+
run: uv run pre-commit run -a --show-diff-on-failure
Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
# For documentation on GitHub Actions Workflows, see:
22
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
3-
name: "build"
4-
5-
on: [push, pull_request]
3+
name: Tests
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
push:
8+
branches: [master]
69

710
jobs:
8-
build:
11+
tests:
912
strategy:
10-
fail-fast: false
1113
matrix:
1214
os: [ubuntu-latest, macos-latest, windows-latest]
1315
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14-dev"]
16+
fail-fast: false
17+
1418
runs-on: ${{ matrix.os }}
19+
defaults:
20+
run:
21+
shell: bash
1522
steps:
16-
- uses: actions/checkout@v4 # https://github.com/actions/checkout
23+
- name: Check out
24+
uses: actions/checkout@v4
1725
with:
18-
# Only a single commit is fetched by default, for the ref/SHA that triggered the workflow.
19-
# Set fetch-depth: 0 to fetch all history for all branches and tags.
2026
fetch-depth: 0 # Needed for setuptools_scm to work correctly
2127
- name: Install uv
2228
uses: astral-sh/setup-uv@v6
@@ -26,7 +32,6 @@ jobs:
2632
with:
2733
python-version: ${{ matrix.python-version }}
2834
allow-prereleases: true
29-
3035
- name: Install the project
3136
run: uv sync --all-extras --dev
3237

@@ -35,3 +40,7 @@ jobs:
3540

3641
- name: Run isolated tests
3742
run: uv run inv pytest --junit --no-pty --isolated
43+
44+
- name: Upload coverage reports to Codecov with GitHub Action on Python 3.13 for each OS
45+
uses: codecov/codecov-action@v3
46+
if: ${{ matrix.python-version == '3.13' }}

.github/workflows/typecheck.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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"]
19+
fail-fast: false
20+
defaults:
21+
run:
22+
shell: bash
23+
steps:
24+
- name: Check out
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # Needed for setuptools_scm to work correctly
28+
29+
- name: Install uv and set the python version
30+
uses: astral-sh/setup-uv@v6
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
34+
- name: Check typing
35+
run: uv run mypy .

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ docs = [
6565
"setuptools_scm>=8",
6666
]
6767
plugins = ["cmd2-ext-test"]
68+
quality = ["pre-commit>=2.20.0"]
6869
test = [
6970
"codecov>=2",
7071
"coverage>=7",

0 commit comments

Comments
 (0)