11[ ![ pre-commit.ci status] ( https://results.pre-commit.ci/badge/github/tox-dev/action-pre-commit-uv/main.svg )] ( https://results.pre-commit.ci/latest/github/tox-dev/action-pre-commit-uv/main )
22[ ![ Build Status] ( https://github.com/tox-dev/action-pre-commit-uv/actions/workflows/main.yml/badge.svg )] ( https://github.com/tox-dev/action-pre-commit-uv/actions )
33
4- tox-dev/action-pre-commit-uv
5- ============================
4+ # tox-dev/action-pre-commit-uv
65
7- A GitHub action to run [ pre-commit] ( https://pre-commit.com )
8- using [ pre-commit-uv] ( https://github.com/tox-dev/pre-commit-uv ) .
6+ A GitHub action to run [ pre-commit] ( https://pre-commit.com ) using
7+ [ pre-commit-uv] ( https://github.com/tox-dev/pre-commit-uv ) .
98
109### using this action
1110
12- To use this action, make a file ` .github/workflows/pre-commit.yml ` . Here's a
13- template to get started:
11+ To use this action, make a file ` .github/workflows/pre-commit.yml ` . Here's a template to get started:
1412
1513``` yaml
1614name : pre-commit
@@ -24,52 +22,67 @@ jobs:
2422 pre-commit :
2523 runs-on : ubuntu-latest
2624 steps :
27- - uses : actions/checkout@v4
28- - uses : tox-dev/action-pre-commit-uv@v1
25+ - uses : actions/checkout@v4
26+ - uses : tox-dev/action-pre-commit-uv@v1
2927` ` `
3028
3129This does a few things:
3230
3331- clones the code
34- - installs uv
32+ - installs uv (if not already available)
3533- sets up the ` pre-commit` cache
3634
35+ The action auto-detects the right invocation : if a `pyproject.toml` exists it uses `uv run`, otherwise it uses `uvx` for
36+ isolated tool execution.
37+
38+ # ## controlling uv installation
39+
40+ By default (`uv-install : ' auto' ` ), the action detects whether uv is already available and only installs it if needed.
41+ You can override this with ` ' true' ` (always install) or ` ' false' ` (never install):
42+
43+ ` ` ` yaml
44+ - uses : astral-sh/setup-uv@v7
45+ with :
46+ version : 0.6.0
47+ - uses : tox-dev/action-pre-commit-uv@v1
48+ with :
49+ uv-install : ' false'
50+ ` ` `
51+
3752### using this action with custom invocations
3853
39- By default, this action runs all the hooks against all the files. `extra_args`
40- lets users specify a single hook id and/or options to pass to `pre-commit run`.
54+ By default, this action runs all the hooks against all the files. ` extra_args` lets users specify a single hook id
55+ and/or options to pass to `pre-commit run`.
4156
42- Here's a sample step configuration that only runs the `flake8` hook against all
43- the files (use the template above except for the `pre-commit` action) :
57+ Here's a sample step configuration that only runs the `flake8` hook against all the files (use the template above except
58+ for the `pre-commit` action) :
4459
4560` ` ` yaml
46- - uses: tox-dev/action-pre-commit-uv@v1
47- with:
48- extra_args: flake8 --all-files
61+ - uses: tox-dev/action-pre-commit-uv@v1
62+ with:
63+ extra_args: flake8 --all-files
4964` ` `
5065
5166# ## using this action in private repositories
5267
53- prior to v3.0.0, this action had custom behaviour which pushed changes back to
54- the pull request when supplied with a `token`.
68+ prior to v3.0.0, this action had custom behaviour which pushed changes back to the pull request when supplied with a
69+ ` token` .
5570
5671this behaviour was removed :
72+
5773- it required a PAT (didn't work with short-lived `GITHUB_TOKEN`)
58- - properly hiding this `input` from the installation and execution of hooks
59- is intractable in github actions (it is readily available as `$INPUT_TOKEN`)
60- - this meant potentially unvetted code could access the token via the
61- environment
74+ - properly hiding this `input` from the installation and execution of hooks is intractable in github actions (it is
75+ readily available as `$INPUT_TOKEN`)
76+ - this meant potentially unvetted code could access the token via the environment
6277
63- you can _likely_ achieve the same thing with an external action such as
64- [git-auto-commit-action] though you may want to take precautions to clear `git`
65- hooks or other ways that arbitrary code execution can occur when running
66- ` git commit` / `git push` (for example [core.fsmonitor]).
78+ you can _likely_ achieve the same thing with an external action such as [git-auto-commit-action] though you may want to
79+ take precautions to clear `git` hooks or other ways that arbitrary code execution can occur when running `git commit` /
80+ ` git push` (for example [core.fsmonitor]).
6781
68- while unrelated to this action, [pre-commit.ci] avoids these problems by
69- installing and executing isolated from the short-lived repository-scoped
70- [installation access token].
82+ while unrelated to this action, [pre-commit.ci] avoids these problems by installing and executing isolated from the
83+ short-lived repository-scoped [installation access token].
7184
72- [git-auto-commit-action] : https://github.com/stefanzweifel/git-auto-commit-action
7385[core.fsmonitor] : https://github.blog/2022-04-12-git-security-vulnerability-announced/
74- [pre- commit.ci ] : https://pre- commit.ci
86+ [git-auto- commit-action ] : https://github.com/stefanzweifel/git-auto- commit-action
7587[installation access token] : https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app
88+ [pre-commit.ci] : https://pre-commit.ci
0 commit comments