Skip to content

Commit 17b2087

Browse files
jufty-botjuftin
andauthored
✨ Update Taskfile and CI Workflow (#13)
* ♻️ (ci): consolidate pull request checks * ✨ (ci): finalize consolidated workflows * 👷 (ci): install each non-build matrix * 👷 (ci): declare matrix installation * 🧪 test Copier workflow deletion * 📝 clarify task descriptions * 📝 refine task descriptions * 📝 standardize task descriptions and Python versions * 📝 document task entrypoints * 📝 complete task documentation * 📝 standardize task descriptions * 👷 (ci): limit main pushes to tests * 👷 (ci): gate pushes by matrix entry * 📝 organize task workflows --------- Co-authored-by: Justin Flannery <justin.flannery@juftin.com>
1 parent bb96fe5 commit 17b2087

18 files changed

Lines changed: 628 additions & 384 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: ci
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
11+
permissions:
12+
contents: read
13+
id-token: write
14+
pull-requests: write
15+
16+
jobs:
17+
ci:
18+
name: ${{ matrix.name }}
19+
runs-on: ubuntu-24.04
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ matrix.name }}-${{ github.event.pull_request.number }}
22+
cancel-in-progress: true
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- name: test
28+
task: test
29+
install: true
30+
run_on_push: true
31+
annotations_pytest: true
32+
- name: pre-commit
33+
task: install
34+
install: true
35+
pre_commit: true
36+
- name: template - build
37+
task: build
38+
template: true
39+
buildx: true
40+
- name: template - check - format
41+
task: check:format
42+
template: true
43+
install: true
44+
annotations_ruff: true
45+
- name: template - check - lint
46+
task: check:lint
47+
template: true
48+
install: true
49+
annotations_ruff: true
50+
- name: template - check - types
51+
task: check:types
52+
template: true
53+
install: true
54+
annotations_mypy: true
55+
- name: template - test - 3.10
56+
task: test
57+
template: true
58+
install: true
59+
run_on_push: true
60+
python: "3.10"
61+
- name: template - test - 3.11
62+
task: test
63+
template: true
64+
install: true
65+
run_on_push: true
66+
python: "3.11"
67+
- name: template - test - 3.12
68+
task: test
69+
template: true
70+
install: true
71+
run_on_push: true
72+
python: "3.12"
73+
- name: template - test - 3.13
74+
task: test
75+
template: true
76+
install: true
77+
run_on_push: true
78+
python: "3.13"
79+
- name: template - test - 3.14
80+
task: test
81+
template: true
82+
install: true
83+
run_on_push: true
84+
python: "3.14"
85+
annotations_pytest: true
86+
pytest_coverage: true
87+
pytest_coverage_xml: tests/example-project/coverage.xml
88+
pytest_coverage_junit: tests/example-project/pytest.xml
89+
- name: template - pre-commit
90+
task: install
91+
template: true
92+
install: true
93+
pre_commit: true
94+
steps:
95+
- name: lock template project
96+
if: (matrix.template || false) && (github.event_name == 'pull_request' || matrix.run_on_push)
97+
uses: juftin/actions/taskfile@v1
98+
with:
99+
task: lock
100+
task-args: --taskfile tests/example-project/Taskfile.yaml
101+
checkout: true
102+
fetch-depth: ${{ matrix.pre_commit && '0' || '1' }}
103+
setup-uv: true
104+
github-token: ${{ secrets.GITHUB_TOKEN }}
105+
- name: install template project
106+
if: matrix.template && matrix.install && (github.event_name == 'pull_request' || matrix.run_on_push)
107+
uses: juftin/actions/taskfile@v1
108+
with:
109+
task: install
110+
task-args: --taskfile tests/example-project/Taskfile.yaml
111+
setup-task: false
112+
setup-uv: false
113+
- name: ${{ matrix.name }}
114+
if: github.event_name == 'pull_request' || matrix.run_on_push
115+
uses: juftin/actions/taskfile@v1
116+
with:
117+
task: ${{ matrix.task }}
118+
task-args: ${{ matrix.template && '--taskfile tests/example-project/Taskfile.yaml' || '' }}
119+
checkout: ${{ !matrix.template }}
120+
install: ${{ matrix.install || false }}
121+
fetch-depth: ${{ matrix.pre_commit && '0' || '1' }}
122+
setup-task: ${{ !matrix.template }}
123+
setup-uv: ${{ !matrix.template }}
124+
buildx: ${{ matrix.buildx || false }}
125+
github-token: ${{ secrets.GITHUB_TOKEN }}
126+
annotations-ruff: ${{ matrix.annotations_ruff || false }}
127+
annotations-mypy: ${{ matrix.annotations_mypy || false }}
128+
annotations-pytest: ${{ matrix.annotations_pytest || false }}
129+
pytest-coverage: ${{ matrix.pytest_coverage && github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork || false }}
130+
pytest-coverage-xml: ${{ matrix.pytest_coverage_xml || 'coverage.xml' }}
131+
pytest-coverage-junit: ${{ matrix.pytest_coverage_junit || 'pytest.xml' }}
132+
env:
133+
UV_PYTHON: ${{ matrix.python || '' }}
134+
- name: pre-commit
135+
if: matrix.pre_commit && github.event_name == 'pull_request'
136+
run: |
137+
uv tool run --isolated \
138+
--with pre-commit-uv \
139+
pre-commit run \
140+
--color always \
141+
--from-ref ${{ github.event.pull_request.base.sha }} \
142+
--to-ref ${{ github.event.pull_request.head.sha }}

.github/workflows/test.yaml

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

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ repos:
4040
description: Runs Prettier Code Formatter
4141
entry: prettier --write --ignore-unknown
4242
args: ["--tab-width=4"]
43-
exclude: \.github/\.copier-answers\.yaml$
43+
exclude: |
44+
(?x)(
45+
\.github/\.copier-answers\.yaml$|
46+
^copier\.yaml$
47+
)
4448
language: node
4549
types:
4650
- text

Taskfile.yaml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,27 @@ env:
66
UV_LOCKED: 1
77

88
tasks:
9-
#######################################
9+
########################
10+
# DEFAULT TASK
11+
########################
1012
default:
11-
desc: Install Project, List Tasks
13+
desc: List Available Tasks
1214
cmds:
13-
- task --list-all
14-
deps: [sync]
15-
#######################################
15+
- task --list-all --sort alphanumeric
16+
silent: true
17+
########################
18+
# INSTALL AND DEPENDENCIES
19+
########################
1620
install:
1721
desc: Install Project + Dev Dependencies
1822
cmds:
1923
- task: pre-commit-install
2024
- task: sync
21-
#######################################
25+
########################
26+
# TESTING
27+
########################
2228
test:
23-
desc: Run Tests
29+
desc: Run Copier Tests
2430
cmds:
2531
- uv run -- pytest tests/test_copier.py {{.CLI_ARGS}}
2632
deps:
@@ -30,33 +36,39 @@ tasks:
3036
CLI_ARGS: --quiet
3137
env:
3238
UV_PYTHON: "{{.UV_PYTHON}}"
33-
#######################################
39+
########################
40+
# DOCUMENTATION AND COMMANDS
41+
########################
3442
docs:
35-
desc: Generate Documentation
43+
desc: Run Documentation Site
3644
cmds:
3745
- uv run --group docs -- mkdocs {{.CLI_ARGS | default "serve"}}
3846
#######################################
3947
run:
40-
desc: Run Command within Project (requires "--")
48+
desc: Run Project Command (requires "--")
4149
interactive: true
4250
cmds:
4351
- uv run -- {{.CLI_ARGS}}
44-
#######################################
52+
########################
53+
# DEPENDENCY MANAGEMENT
54+
########################
4555
lock:
46-
desc: Regenerate the Project Lockfile
56+
desc: Regenerate Project Lockfile
4757
cmds:
4858
- uv lock
4959
env:
5060
UV_LOCKED: "0"
51-
#######################################
61+
########################
62+
# GENERATED PROJECT FIXTURE
63+
########################
5264
example-project:
53-
desc: Regenerate the example project for testing
65+
desc: Regenerate Example Project
5466
cmds:
5567
- rm -rf tests/example-project
5668
- uv run -- copier copy --vcs-ref=HEAD --defaults --data-file tests/answers.yml . {{.CLI_ARGS | default "tests/example-project"}}
57-
#######################################
69+
########################
5870
# INTERNAL TASKS
59-
#######################################
71+
########################
6072
sync:
6173
desc: Install Project Dependencies
6274
internal: true

docs/contributing.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ manager) and **[task]** (task runner). Once both are installed, you can use
1818
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d
1919
```
2020

21-
3. Install project dependencies and list available tasks
21+
3. Install the project development environment
2222

2323
```shell
2424
task install
@@ -34,18 +34,15 @@ manager) and **[task]** (task runner). Once both are installed, you can use
3434

3535
### Task Cheat Sheet
3636

37-
| Command Description | Command | Notes |
38-
| ------------------- | ------------------- | --------------------------------------- |
39-
| Install Project | `task install` | Installs project and dev dependencies |
40-
| Run Tests | `task test` | Runs tests with `pytest` |
41-
| Run Linting | `task lint` | Lints code with `ruff` |
42-
| Fix Code Issues | `task fix` | Formats and auto-fixes code with `ruff` |
43-
| Run Formatting | `task fmt` | Formats code with `ruff` |
44-
| Run Type Checking | `task check` | Runs static analysis with `mypy` |
45-
| Build Project | `task build` | Builds project artifacts |
46-
| Update Dependencies | `task lock` | Regenerates project lockfile |
47-
| Serve Documentation | `task docs` | Serves docs with `mkdocs` |
48-
| Run Commands | `task run -- <cmd>` | Runs arbitrary commands |
37+
| Command Description | Command | Notes |
38+
| ---------------------------------- | ---------------------- | ------------------------------------------ |
39+
| List Available Tasks | `task` | Lists tasks in alphanumeric order |
40+
| Install Project + Dev Dependencies | `task install` | Installs dependencies and pre-commit hooks |
41+
| Run Copier Tests | `task test` | Runs the Copier test suite |
42+
| Run Documentation Site | `task docs` | Runs MkDocs |
43+
| Run a Project Command | `task run -- <cmd>` | Runs a command in the project environment |
44+
| Regenerate Project Lockfile | `task lock` | Regenerates `uv.lock` |
45+
| Regenerate Example Project | `task example-project` | Replaces the checked-in generated fixture |
4946

5047
### Task Explanation
5148

template/.github/workflows/ci.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: ci
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
11+
permissions:
12+
contents: read
13+
id-token: write
14+
pull-requests: write
15+
16+
jobs:
17+
ci:
18+
name: ${{"{{"}} matrix.name {{"}}"}}
19+
runs-on: ubuntu-24.04
20+
concurrency:
21+
group: ${{"{{"}} github.workflow {{"}}"}}-${{"{{"}} matrix.name {{"}}"}}-${{"{{"}} github.event.pull_request.number {{"}}"}}
22+
cancel-in-progress: true
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- name: build
28+
task: build
29+
- name: check - format
30+
task: check:format
31+
install: true
32+
annotations_ruff: true
33+
- name: check - lint
34+
task: check:lint
35+
install: true
36+
annotations_ruff: true
37+
- name: check - types
38+
task: check:types
39+
install: true
40+
annotations_mypy: true
41+
- name: test - 3.10
42+
task: test
43+
install: true
44+
run_on_push: true
45+
python: "3.10"
46+
- name: test - 3.11
47+
task: test
48+
install: true
49+
run_on_push: true
50+
python: "3.11"
51+
- name: test - 3.12
52+
task: test
53+
install: true
54+
run_on_push: true
55+
python: "3.12"
56+
- name: test - 3.13
57+
task: test
58+
install: true
59+
run_on_push: true
60+
python: "3.13"
61+
- name: test - 3.14
62+
task: test
63+
install: true
64+
run_on_push: true
65+
python: "3.14"
66+
- name: pre-commit
67+
task: install
68+
install: true
69+
steps:
70+
- name: ${{"{{"}} matrix.name {{"}}"}}
71+
if: github.event_name == 'pull_request' || matrix.run_on_push
72+
uses: juftin/actions/taskfile@v1
73+
with:
74+
task: ${{"{{"}} matrix.task {{"}}"}}
75+
checkout: true
76+
install: ${{"{{"}} matrix.install || false {{"}}"}}
77+
fetch-depth: ${{"{{"}} matrix.name == 'pre-commit' && '0' || '1' {{"}}"}}
78+
setup-uv: true
79+
buildx: ${{"{{"}} matrix.name == 'build' {{"}}"}}
80+
github-token: ${{"{{"}} secrets.GITHUB_TOKEN {{"}}"}}
81+
annotations-ruff: ${{"{{"}} matrix.annotations_ruff || false {{"}}"}}
82+
annotations-mypy: ${{"{{"}} matrix.annotations_mypy || false {{"}}"}}
83+
annotations-pytest: ${{"{{"}} matrix.python == '{{ default_python_version }}' {{"}}"}}
84+
pytest-coverage: ${{"{{"}} matrix.python == '{{ default_python_version }}' && github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork {{"}}"}}
85+
env:
86+
UV_PYTHON: ${{"{{"}} matrix.python || '' {{"}}"}}
87+
- name: pre-commit
88+
if: matrix.name == 'pre-commit' && github.event_name == 'pull_request'
89+
run: |
90+
uv tool run --isolated \
91+
--with pre-commit-uv \
92+
pre-commit run \
93+
--color always \
94+
--from-ref ${{"{{"}} github.event.pull_request.base.sha {{"}}"}} \
95+
--to-ref ${{"{{"}} github.event.pull_request.head.sha {{"}}"}}

0 commit comments

Comments
 (0)