operator icon indicating copy to clipboard operation
operator copied to clipboard

Update pre-commit to monorepo

Open dimaqq opened this issue 8 months ago • 2 comments

We've switched to monorepo, but pre-commit got left behind.

Today it looks like:

    - repo: https://github.com/astral-sh/ruff-pre-commit
      rev: v0.11.2
      hooks:
        - id: ruff
E         args: [ --preview ] # E: too many spaces inside brackets
        - id: ruff-format
E         args: [ --preview ] # E: too many spaces inside brackets
    # Spellcheck the code.
    - repo: https://github.com/codespell-project/codespell
      rev: v2.4.1
      hooks:
E     - id: codespell # E: wrong indentation: expected 6 but found 4
        additional_dependencies:
          - tomli
    # Check workflow security.

And it could be something like:

  - repo: local
    hooks:
      - id: ruff
        name: ruff (uv)
        entry: uv run -- ruff check --preview
        language: system
        types: [python]

      - id: pyright
        name: pyright (uv)
        entry: uv run -- pyright
        language: system
        types: [python]

dimaqq avatar Jul 04 '25 06:07 dimaqq

precedent: https://github.com/canonical/jubilant/pull/166

dimaqq avatar Aug 07 '25 05:08 dimaqq

Current state:

(ops) 🦐/c/operator (fix-dont-cache-secret-values)> pre-commit run -a
[INFO] Initializing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Initializing environment for https://github.com/codespell-project/codespell.
[INFO] Initializing environment for https://github.com/codespell-project/codespell:tomli.
[INFO] Initializing environment for https://github.com/woodruffw/zizmor-pre-commit.
[INFO] Installing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/codespell-project/codespell.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/woodruffw/zizmor-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
check for added large files..............................................Passed
check python ast.........................................................Passed
check for case conflicts.................................................Passed
check that executables have shebangs.....................................Passed
check that scripts with shebangs are executable..........................Passed
check for merge conflicts................................................Passed
check for broken symlinks................................................Passed
check json...........................................(no files to check)Skipped
check yaml...............................................................Passed
check toml...............................................................Passed
mixed line ending........................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing docs/tutorial/write-your-first-machine-charm.md
Fixing docs/reference/ops.rst
Fixing docs/reference/index.md
Fixing docs/howto/manage-interfaces.md
Fixing docs/reference/ops-main-entrypoint.rst
Fixing docs/tutorial/from-zero-to-hero-write-your-first-kubernetes-charm/study-your-application.md
Fixing docs/explanation/charm-relation-interfaces.md
Fixing docs/howto/manage-secrets.md

trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing docs/explanation/state-transition-testing.md
Fixing docs/howto/trace-your-charm.md
Fixing test/charms/test_tracing/charmcraft.yaml
Fixing HACKING.md
Fixing docs/howto/manage-interfaces.md
Fixing docs/howto/manage-opened-ports.md
Fixing docs/tutorial/from-zero-to-hero-write-your-first-kubernetes-charm/study-your-application.md
Fixing docs/explanation/charm-relation-interfaces.md
Fixing docs/howto/manage-secrets.md

detect private key.......................................................Passed
ruff.....................................................................Passed
ruff-format..............................................................Passed
codespell................................................................Passed
zizmor...................................................................Passed
(ops) 🦐/c/operator (fix-dont-cache-secret-values) [1]> gs
 M HACKING.md
 M docs/explanation/charm-relation-interfaces.md
 M docs/explanation/state-transition-testing.md
 M docs/howto/manage-interfaces.md
 M docs/howto/manage-opened-ports.md
 M docs/howto/manage-secrets.md
 M docs/howto/trace-your-charm.md
 M docs/reference/index.md
 M docs/reference/ops-main-entrypoint.rst
 M docs/reference/ops.rst
 M docs/tutorial/from-zero-to-hero-write-your-first-kubernetes-charm/study-your-application.md
 M docs/tutorial/write-your-first-machine-charm.md
 M test/charms/test_tracing/charmcraft.yaml
(ops) 🦐/c/operator (fix-dont-cache-secret-values)>

dimaqq avatar Sep 09 '25 03:09 dimaqq