Skip to content

🔨🤖 Install pre-commit as a uv tool so the git hook works in every worktree - #9908

Merged
sanderegg merged 6 commits into
ITISFoundation:masterfrom
sanderegg:maintenance/pre-commit-uv-tool
Oct 26, 2026
Merged

sanderegg merged 6 commits into
ITISFoundation:masterfrom
sanderegg:maintenance/pre-commit-uv-tool

Conversation

@sanderegg

@sanderegg sanderegg commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Important

After pulling, run make devenv once in any worktree.

What do these changes do?

Git worktrees share one pre-commit hook, and it pointed to the .venv of the worktree that installed it last. Commits failed in all worktrees once that .venv was gone.

  • make devenv installs pre-commit as a uv tool and installs the hook from it.
  • pre-commit is removed from requirements/devenv.txt and from the _tools.txt files. They were regenerated without --upgrade, so versions stay the same.
  • make clean-hooks also works inside a worktree.
  • filelock, which pytest-simcore needs, is added to the test requirements. The lockfiles only had it through pre-commit (and pyyaml in settings-library).

Notes:

  • Hook versions stay per checkout, since each worktree runs its own .pre-commit-config.yaml.
  • pre-commit itself is now one version per user, upgraded for all worktrees with uv tool upgrade pre-commit or make devenv.

Bonus: Renovate and dependency tracking

Renovate now tracks its own pinned uv constraint in the shared uv update group, with a regression test, and enables GitHub Actions SHA pinning through helpers:pinGitHubActionDigests (Renovate will propose the workflow conversions). The obsolete director frozen-service rule and Python-test exemption are removed. All five Valkey Compose references use the explicit 7.2.14 tag while retaining their existing image digest, so the deployed image is unchanged. Debian tracking/migration is not included. Validation: 9 focused Python/uv tests, pre-commit hooks (including Compose validation), and Pylint passed.

Related issue/s

Split out of #9850.

How to test

Run make devenv, then sed -n 6p .git/hooks/pre-commit. It prints the Python of the uv tool, not of .venv. Commit from a second worktree.

Dev-ops

Developer tooling only.

Assisted-by: GitHub Copilot

Before and after

Before: the shared hook runs the .venv of the worktree that ran make devenv last.

osparc-simcore/.git/hooks/pre-commit  (shared by all worktrees)
  INSTALL_PYTHON=~/dev/worktree-B/.venv/bin/python
                         |
       +-----------------+-----------------+
  commit in worktree A           commit in worktree B
  uses worktree-B/.venv          uses worktree-B/.venv
  (fails once B's .venv is removed or recreated)

After: the hook runs the per-user uv tool, whatever the worktree.

osparc-simcore/.git/hooks/pre-commit  (shared by all worktrees)
  INSTALL_PYTHON=~/.local/share/uv/tools/pre-commit/bin/python
                         |
       +-----------------+-----------------+
  commit in worktree A           commit in worktree B
  uses the uv tool               uses the uv tool
  (each runs its own .pre-commit-config.yaml)

@github-actions github-actions Bot added a:infra+ops maintenance of infrastructure or operations (discussed in retro) a:storage issue related to storage service a:director issue related with the director service a:webserver webserver's codebase. Assigning the area is particularly useful for bugs a:services-library issues on packages/service-libs a:api framework api, data schemas, a:doc documentation, reporting, admin tasks a:database associated to postgres service and postgres-database package e2e Bugs found by or related to the end-2-end testing a:catalog catalog service a:director-v2 issue related with the director-v2 service a:apiserver api-server service a:dynamic-sidecar dynamic-sidecar service a:dask-service Any of the dask services: dask-scheduler/sidecar or worker a:models-library a:autoscaling autoscaling service in simcore's stack a:ooil integration-library or ooil a:agent agent service a:invitations invitations service a:resource-usage-tracker resource usage tracker service a:clusters-keeper a:payments area: payments service a:dynamic-scheduler a:aws-library a:datcore-adapter a:simcore-sdk a:notifications a:celery-library dependencies Pull requests that update a dependency file labels Oct 24, 2026
@sanderegg sanderegg self-assigned this Oct 24, 2026
@sanderegg sanderegg added the t:maintenance Maintenance work; used to filter tasks for end-of-sprint reporting in Review (Agreed July 3, Retro) label Oct 24, 2026
Comment thread Makefile
Comment thread packages/celery-library/requirements/_test.txt
@sanderegg sanderegg added the 🤖-automerge marks PR as ready to be merged for Mergify label Oct 26, 2026
@sanderegg

Copy link
Copy Markdown
Member Author

@mergify queue

@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

🛑 Queue command has been cancelled

@GitHK GitHK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see hooks go in user space now

Comment thread services/autoscaling/tests/manual/docker-compose.yml
@sanderegg

Copy link
Copy Markdown
Member Author

I see hooks go in user space now

@GitHK no as explained in the description, only pre-commit goes in user space. the hooks are attache into the repository (shared by all its worktrees actually).

@GitHK

GitHK commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

I see hooks go in user space now

@GitHK no as explained in the description, only pre-commit goes in user space. the hooks are attache into the repository (shared by all its worktrees actually).

correct I meant to say the library

sanderegg and others added 5 commits October 26, 2026 09:28
…tree

Git worktrees share .git/hooks, and `pre-commit install` writes the path of
the Python that ran it into the hook. With pre-commit in .venv, the hook
pointed to the .venv of whichever worktree ran `make devenv` (or
`pre-commit install`) last, and commits failed in every worktree once that
.venv was removed or recreated.

- `make devenv` installs pre-commit as a uv tool, removes it from .venv and
  installs the hook from the uv tool
- `make clean-hooks` removes the hook from the common git dir, which also
  works inside a worktree
- requirements/devenv.txt: drop pre-commit; */requirements/_tools.txt
  regenerated without --upgrade, so they only lose pre-commit and the
  packages only it needed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CI installs with `uv pip sync requirements/ci.txt`, which installs only what
the lockfiles list. pytest-simcore needs filelock, but the lockfiles only had
it through pre-commit (virtualenv) in _tools.txt, so removing pre-commit
broke every unit-test job. settings-library had pyyaml the same way and
loads pytest_simcore.environment_configs, which imports yaml.

_test.txt regenerated with `make reqs upgrade=filelock` (settings-library:
`upgrade="filelock pyyaml"`); no other pin changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Track Renovate's uv constraint with the shared uv group, enable action digest pinning, remove the director Python exemption, and use explicit Valkey patch tags without changing image digests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sanderegg
sanderegg force-pushed the maintenance/pre-commit-uv-tool branch from 0101f1a to 05e22de Compare October 26, 2026 08:30
@mergify

mergify Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

queue

🛑 The queue request has been cancelled: new commits were pushed

Details

@sanderegg pushed to this pull request after queue was requested. Review the new commits and request it again.

@sonarqubecloud

Copy link
Copy Markdown

@sanderegg

Copy link
Copy Markdown
Member Author

@mergify queue

@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • 🟠 Waiting for queue conditions
  • ⏳ Enter queue
  • ⏳ Run checks
  • ⏳ Merge
Waiting for
All conditions
  • -closed [📌 queue requirement]
  • any of [🔀 queue conditions]:
    • all of [📌 queue conditions of queue rule default]:
      • github-review-approved [🛡 GitHub repository ruleset rule master branch]
      • #approved-reviews-by>=2
      • #changes-requested-reviews-by=0
      • #review-threads-unresolved=0
      • -conflict
      • -draft
      • base=master
      • label!=🤖-do-not-merge
      • label=🤖-automerge
      • any of [🛡 GitHub repository ruleset rule master branch]:
        • check-skipped = @github-actions/deploy to dockerhub
        • check-neutral = @github-actions/deploy to dockerhub
        • check-success = @github-actions/deploy to dockerhub
      • any of [🛡 GitHub repository ruleset rule master branch]:
        • check-success = @github-actions/unit-tests
        • check-neutral = @github-actions/unit-tests
        • check-skipped = @github-actions/unit-tests
      • any of [🛡 GitHub repository ruleset rule master branch]:
        • check-success = @github-actions/integration-tests
        • check-neutral = @github-actions/integration-tests
        • check-skipped = @github-actions/integration-tests
      • any of [🛡 GitHub repository ruleset rule master branch]:
        • check-success = @github-actions/system-tests
        • check-neutral = @github-actions/system-tests
        • check-skipped = @github-actions/system-tests
      • any of [🛡 GitHub repository ruleset rule master branch]:
        • check-success = @github-actions/check OAS' are up to date
        • check-neutral = @github-actions/check OAS' are up to date
        • check-skipped = @github-actions/check OAS' are up to date
      • any of [🛡 GitHub repository ruleset rule master branch]:
        • check-success = @github-actions/api-server openai compatibility
        • check-neutral = @github-actions/api-server openai compatibility
        • check-skipped = @github-actions/api-server openai compatibility
      • any of [🛡 GitHub repository ruleset rule master branch]:
        • check-success = @sonarqubecloud/SonarCloud Code Analysis
        • check-neutral = @sonarqubecloud/SonarCloud Code Analysis
        • check-skipped = @sonarqubecloud/SonarCloud Code Analysis
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of [📌 queue -> configuration change requirements]:
    • -mergify-configuration-changed
    • check-success = @mergify/Configuration changed
    • check-success = @mergify/Configuration has been deleted
  • any of [📌 queue requirement]:
    • check-neutral = @mergify/Mergify Merge Protections
    • check-skipped = @mergify/Mergify Merge Protections
    • check-success = @mergify/Mergify Merge Protections

@sanderegg
sanderegg merged commit 8191584 into ITISFoundation:master Oct 26, 2026
59 of 60 checks passed
@sanderegg
sanderegg deleted the maintenance/pre-commit-uv-tool branch October 26, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-automerge marks PR as ready to be merged for Mergify a:agent agent service a:api framework api, data schemas, a:apiserver api-server service a:autoscaling autoscaling service in simcore's stack a:aws-library a:catalog catalog service a:celery-library a:clusters-keeper a:dask-service Any of the dask services: dask-scheduler/sidecar or worker a:database associated to postgres service and postgres-database package a:datcore-adapter a:director issue related with the director service a:director-v2 issue related with the director-v2 service a:doc documentation, reporting, admin tasks a:dynamic-scheduler a:dynamic-sidecar dynamic-sidecar service a:infra+ops maintenance of infrastructure or operations (discussed in retro) a:invitations invitations service a:models-library a:notifications a:ooil integration-library or ooil a:payments area: payments service a:resource-usage-tracker resource usage tracker service a:services-library issues on packages/service-libs a:simcore-sdk a:storage issue related to storage service a:webserver webserver's codebase. Assigning the area is particularly useful for bugs dependencies Pull requests that update a dependency file e2e Bugs found by or related to the end-2-end testing t:maintenance Maintenance work; used to filter tasks for end-of-sprint reporting in Review (Agreed July 3, Retro)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants