diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6c5049e --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + groups: + github-actions: + patterns: + - "*" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d13b72c..bc2ff41 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,9 +16,11 @@ jobs: - if: ${{ startsWith(github.event_name, 'repository_dispatch') }} run: sleep 30 - - uses: actions/checkout@v4 + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: true # needed to push commits below - - uses: actions/setup-python@v5 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: "3.11" cache: pip diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index c432d6a..e08b530 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -24,7 +24,7 @@ entry: uv export language: python files: ^uv\.lock$ - args: ["--frozen", "--output-file=requirements.txt"] + args: ["--frozen", "--output-file=requirements.txt", "--quiet"] pass_filenames: false additional_dependencies: [] minimum_pre_commit_version: "2.9.2" @@ -38,3 +38,14 @@ pass_filenames: false stages: [post-checkout, post-merge, post-rewrite] minimum_pre_commit_version: "2.9.2" +- id: uv-run + name: uv-run + description: "Automatically run scripts with 'uv run'" + entry: uv run --no-active + args: [] + language: python + pass_filenames: false + additional_dependencies: [] + minimum_pre_commit_version: "2.9.2" + + diff --git a/README.md b/README.md index 73777ad..2e01698 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ To ensure the lockfile is up-to-date: ```yaml - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.7.15 + rev: 0.9.9 hooks: # Update the uv lockfile - id: uv-lock @@ -31,20 +31,22 @@ To autoexport `uv.lock` to `requirements.txt`: ```yaml - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.7.15 + rev: 0.9.9 hooks: - id: uv-export ``` +By default, this hook uses the ["quiet" output](https://docs.astral.sh/uv/reference/cli/#uv-export--quiet). + To export to an alternative file, modify the `args`: ```yaml - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.7.15 + rev: 0.9.9 hooks: - id: uv-export - args: ["--frozen", "--output-file=requirements-custom.txt"] + args: ["--frozen", "--output-file=requirements-custom.txt", "--quiet"] ``` To compile your requirements via pre-commit, add the following to your `.pre-commit-config.yaml`: @@ -52,7 +54,7 @@ To compile your requirements via pre-commit, add the following to your `.pre-com ```yaml - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.7.15 + rev: 0.9.9 hooks: # Run the pip compile - id: pip-compile @@ -64,7 +66,7 @@ To compile alternative files, modify the `args` and `files`: ```yaml - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.7.15 + rev: 0.9.9 hooks: # Run the pip compile - id: pip-compile @@ -77,7 +79,7 @@ To run the hook over multiple files at the same time: ```yaml - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.7.15 + rev: 0.9.9 hooks: # Run the pip compile - id: pip-compile @@ -94,7 +96,7 @@ To run a hook on a project within a subdirectory (i.e., in a monorepo): ```yaml - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.7.15 + rev: 0.9.9 hooks: # Update the uv lockfile - id: uv-lock @@ -114,7 +116,7 @@ default_install_hook_types: repos: - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.7.15 + rev: 0.9.9 hooks: - id: uv-sync ``` @@ -127,7 +129,7 @@ To synchronize all dependencies in a workspace: ```yaml - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.7.15 + rev: 0.9.9 hooks: - id: uv-sync args: ["--locked", "--all-packages"] @@ -139,12 +141,26 @@ include it as an additional sync dependency: ```yaml - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.7.15 + rev: 0.9.9 hooks: - id: uv-sync additional_dependencies: [keyring] ``` +To run an arbitrary script using `uv run`, (e.g., one using [inline script +metadata](https://packaging.python.org/en/latest/specifications/inline-script-metadata/#inline-script-metadata)): + +```yaml +- repo: https://github.com/astral-sh/uv-pre-commit + # uv version. + rev: 0.9.9 + hooks: + - id: uv-run + args: ["--script", "path/to/script.py"] + files: file-pattern-script-depends-on +``` + + ## License uv-pre-commit is licensed under either of diff --git a/pyproject.toml b/pyproject.toml index 7aa8ec6..a5e376d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "uv-pre-commit" version = "0.0.0" dependencies = [ - "uv==0.7.15", + "uv==0.9.9", ] [project.optional-dependencies]