Skip to content

Commit 49b1400

Browse files
committed
Install and manage pre-commit
1 parent 368fd67 commit 49b1400

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

Taskfile.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ tasks:
2929
- uv sync --frozen
3030

3131
init-pre-commit:
32-
desc: Install the pre-commit hooks
32+
desc: Setup pre-commit
3333
internal: true
3434
sources:
3535
- .pre-commit-config.yaml
3636
status:
37-
# Don't install the pre-commit hooks if you aren't in a git repository; quote to avoid yaml intrepretering the ! as a node tag
37+
# Don't do any of this if you aren't in a git repository; quote to avoid yaml intrepretering the ! as a node tag
3838
# https://yaml.org/spec/1.2.2/#691-node-tags
3939
- '! test -d .git'
4040
cmds:
41+
- uv tool install pre-commit
4142
# Don't run this in pipelines
4243
- '{{if ne .GITHUB_ACTIONS "true"}}{{.RUN_SCRIPT}} pre-commit install{{else}}echo "Detected a github actions pipeline; skipping the pre-commit install"{{end}}'
4344

@@ -88,6 +89,7 @@ tasks:
8889
cmds:
8990
# This currently assumes uv was installed via uv (locally); we will want to make it more flexible in the future
9091
- '{{if ne .GITHUB_ACTIONS "true"}}brew upgrade uv{{end}}'
92+
- uv tool upgrade --all
9193
- pre-commit autoupdate --freeze --jobs 4
9294
# Copy the newly updated config into the project template, excluding the exclude line
9395
- cat .pre-commit-config.yaml | grep -v ^exclude > '{{`{{cookiecutter.project_name|replace(" ", "")}}`}}/.pre-commit-config.yaml'

{{cookiecutter.project_name|replace(" ", "")}}/Taskfile.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ tasks:
4747
sources:
4848
- .pre-commit-config.yaml
4949
status:
50-
# Only install the pre-commit hooks if you are in a git repository; quote to avoid yaml intrepretering the ! as a node tag
50+
# Don't do any of this if you aren't in a git repository; quote to avoid yaml intrepretering the ! as a node tag
5151
# https://yaml.org/spec/1.2.2/#691-node-tags
5252
- '! test -d .git'
5353
cmds:
54+
- uv tool install pre-commit
5455
# Don't run this in pipelines
5556
- '{{ "{{" }}if ne .GITHUB_ACTIONS "true"{{ "}}{{.RUN_SCRIPT}} pre-commit install{{else}}echo \"Detected a github actions pipeline; skipping the pre-commit install\"{{end}}" }}'
5657

@@ -169,10 +170,11 @@ tasks:
169170
cmds:
170171
# This currently assumes uv was installed via uv (locally); we will want to make it more flexible in the future
171172
- '{{ "{{" }}if ne .GITHUB_ACTIONS "true"{{ "}}" }}brew upgrade uv{{ "{{" }}end{{ "}}" }}'
173+
- uv tool upgrade --all
172174
- pre-commit autoupdate --freeze --jobs 4
173175
- uv lock --upgrade
174176
# This can take a while but it's required for the following step to update BuildKit in the docker driver
175-
- '{{ "{{" }}if eq .CLI_ARGS "all"{{ "}}" }}docker buildx rm multiplatform || true{{ "{{" }}end{{ "}}" }}'
177+
- '{{ "{{" }}if eq .CLI_ARGS "all"{{ "}}" }}docker buildx rm multiplatform || true{{ "}}" }}end {{ "}}" }}'
176178
# If we just destroyed the "multiplatform" builder instance, this will configure a new one. The next time the host runs a `docker buildx build` it will
177179
# rebuild the builder instance, updating its BuildKit. There's no harm in running this even if we didn't do the `docker buildx rm` previously
178180
- task: init-docker-multiplatform

0 commit comments

Comments
 (0)