Skip to content

Add pre-commit auto-update workflow - #853

Merged
forsyth2 merged 5 commits into
mainfrom
add-pre-commit-update-workflow
Aug 14, 2026
Merged

Add pre-commit auto-update workflow#853
forsyth2 merged 5 commits into
mainfrom
add-pre-commit-update-workflow

Conversation

@forsyth2

@forsyth2 forsyth2 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Add pre-commit auto-update workflow

Summary

Objectives:

  • Add pre-commit auto-update workflow

Issue resolution:

Select one: This pull request is...

  • a bug fix: increment the patch version
  • a small improvement: increment the minor version
  • a new feature: increment the minor version
  • an incompatible (non-backwards compatible) API change: increment the major version

Small Change

  • To merge, I will use "Squash and merge". That is, this change should be a single commit.
  • Logic: I have visually inspected the entire pull request myself.
  • Pre-commit checks: All the pre-commits checks have passed.

Add pre-commit auto-update workflow by copying changes from
equivalent zppy-interfaces PR:
https://github.com/E3SM-Project/zppy-interfaces/pull/57/changes
@forsyth2 forsyth2 self-assigned this Aug 13, 2026
@forsyth2 forsyth2 added the DevOps CI/CD, configuration, etc. label Aug 13, 2026
@forsyth2
forsyth2 requested a lite review from Copilot August 13, 2026 23:04

Copilot AI 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.

Pull request overview

This PR adds automation for keeping pre-commit hook versions up to date in the
zppy repo, including a GitHub Actions workflow and a helper script to
propagate updated versions into other pinned dependency locations.

Changes:

  • Add a pre_commit_update_workflow scheduled/manual GitHub Actions workflow to
    run pre-commit-update and open a PR with the results.
  • Add scripts/sync_pre_commit_versions.py to sync pinned tool versions based
    on .pre-commit-config.yaml.
  • Update existing pinned-version guidance and mypy hook dependencies to align
    with the new workflow/script.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
scripts/sync_pre_commit_versions.py New script to derive versions from .pre-commit-config.yaml and apply them to pinned dependency files.
conda/dev.yml Updates QA-tool comment to describe the intended update flow.
.pre-commit-config.yaml Adds a mypy additional_dependencies entry and a note about syncing pins.
.github/workflows/pre_commit_update_workflow.yml New scheduled workflow to auto-update pre-commit hooks and open a PR.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread conda/dev.yml
Comment thread scripts/sync_pre_commit_versions.py
auto-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We should probably use the latest version if we can.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It would be worth adding dependebot to update them.

Comment thread .pre-commit-config.yaml
hooks:
- id: mypy
args: ["--config=pyproject.toml"]
additional_dependencies: [types-PyYAML]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Add a `qa` extra (pinned to the same black/flake8/isort/mypy/etc.
versions as `.pre-commit-config.yaml`) and a `dev` extra to
`pyproject.toml`, plus the missing `flake8-isort` and `types-PyYAML`
pins in `conda/dev.yml`. Also add `[tool.pre-commit-update.yaml]` so
`pre-commit-update` doesn't reformat the whole config on its next run.

Brings zppy in line with the version-pinning pattern already used in
zppy-interfaces, so `scripts/sync_pre_commit_versions.py --check`
passes here too.

Generated by Claude (Anthropic).
flake8-isort==6.1.1 pins isort<6, which conflicts with the
isort==6.0.1 pin introduced in the previous commit and broke the
conda env solve in CI. 6.1.2 raises the cap to isort<7, which is
compatible.

Change made in .pre-commit-config.yaml and propagated to
conda/dev.yml and pyproject.toml via
`python scripts/sync_pre_commit_versions.py`.

Claude-generated, verified against the flake8-isort 6.1.1/6.1.2
PyPI metadata.

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (5)

.github/workflows/pre_commit_update_workflow.yml:18

  • The workflow requests issues: write but doesn’t appear to interact with issues. Reducing token permissions to only what’s used follows least-privilege and limits blast radius if a token is misused.
permissions:
  contents: write
  pull-requests: write
  issues: write

.github/workflows/pre_commit_update_workflow.yml:29

  • This workflow clones the repository later (git clone ... update-pre-commit-deps), so the initial actions/checkout step is unused work. Consider removing it to reduce runtime and avoid confusion about which working tree subsequent commands operate on.
      - uses: actions/checkout@v7

.github/workflows/pre_commit_update_workflow.yml:90

  • gh pr create will fail if a PR from update-pre-commit-deps already exists (e.g., previous month’s PR still open), which would make this scheduled workflow brittle. Consider making this step idempotent by detecting an existing PR for the branch and updating it (or exiting successfully) instead of failing the run.
          gh pr create \
          --title "Update pre-commit and its dependencies" \
          --body "This PR was auto-generated to update pre-commit and its dependencies." \
          --head update-pre-commit-deps \
          --reviewer ${{ env.REVIEWERS }} \

pyproject.toml:46

  • The comment says these versions “always match … .pre-commit-config.yaml”, but this list includes non-pinned constraints like types-PyYAML>=… while .pre-commit-config.yaml uses types-PyYAML with no version. Consider rewording to clarify that only pinned tool versions are meant to be synchronized.
# make sure these always match conda/dev.yml and .pre-commit-config.yaml
# (run `python scripts/sync_pre_commit_versions.py` to sync them)

scripts/sync_pre_commit_versions.py:1

  • Using #!/usr/bin/env python can resolve to Python 2 or fail on systems where python isn’t installed. Since this repository targets Python 3, use python3 in the shebang for safer direct execution.
#!/usr/bin/env python

@forsyth2

Copy link
Copy Markdown
Collaborator Author

pre-commit run --all-files passes as before using this branch (despite the functional changes in conda/dev.yml)

@xylar xylar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good! You can give it a run once this is merged and see if it works!

Got to the Actions tab, look for this one on the left (Pre-commit auto update) and then select "run workflow" on the right, choosing to run on main.

Comment thread pyproject.toml
Comment thread conda/dev.yml
Comment thread .github/workflows/pre_commit_update_workflow.yml Outdated
@forsyth2
forsyth2 merged commit c557e15 into main Aug 14, 2026
7 checks passed
@forsyth2
forsyth2 deleted the add-pre-commit-update-workflow branch August 14, 2026 16:39
@forsyth2

Copy link
Copy Markdown
Collaborator Author

Thanks @xylar, looks like it passed! https://github.com/E3SM-Project/zppy/actions/runs/31820401775

@forsyth2

Copy link
Copy Markdown
Collaborator Author

That created #854. It required a few fixes, but I was eventually able to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DevOps CI/CD, configuration, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants