Skip to content

Add workflow to autoupdate pre-commit#191

Merged
ednolan merged 3 commits intobemanproject:mainfrom
wermos:precommit
Jul 19, 2025
Merged

Add workflow to autoupdate pre-commit#191
ednolan merged 3 commits intobemanproject:mainfrom
wermos:precommit

Conversation

@wermos
Copy link
Copy Markdown
Contributor

@wermos wermos commented Jun 26, 2025

Description

Added a GitHub Actions workflow to auto-update pre-commit.

I'm not sure what frequency we want to run it at. Running it daily felt excessive; right now it's set to run weekly.

Related Issues

Addresses #164.

Pinging @wusatosi as the creator of that issue and because it has the "mentoring available" tag.

Meta

  • If all approvals are obtained and the PR is green, any Beman member can merge the PR.

@wermos
Copy link
Copy Markdown
Contributor Author

wermos commented Jun 26, 2025

I'm not sure what the issue with the Cookiecutter Test is? I can't quite make sense of the error message 😟

@JeffGarland
Copy link
Copy Markdown
Member

maybe @ednolan has thoughts on this?

@ednolan
Copy link
Copy Markdown
Member

ednolan commented Jun 28, 2025

Thanks for this commit. The cookiecutter CI failure is caused by a conflict between the syntax for cookiecutter's templates and the syntax for variable substitution in GitHub workflows. You can address it by wrapping the .yml file in exemplar/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ in {% raw -%} on the first line and {%- endraw %} on the last line. The other workflow files in that directory also use this approach.

@wermos
Copy link
Copy Markdown
Contributor Author

wermos commented Jun 29, 2025

Thanks for the help, I've made the required changes.

@ClausKlein
Copy link
Copy Markdown
Contributor

ClausKlein commented Jul 6, 2025

I see problems with cuckiecutter after autoupdate.

and update is sometime downgrade?

bash-5.2$ git commit -a -m 'sync the cookiecutter with newline too'
trim trailing whitespace.............................(no files to check)Skipped
fix end of files.....................................(no files to check)Skipped
check yaml...........................................(no files to check)Skipped
check for added large files..........................(no files to check)Skipped
clang-format.........................................(no files to check)Skipped
CMake linting........................................(no files to check)Skipped
codespell............................................(no files to check)Skipped
[feature/test-installed-package 272f56f] sync the cookiecutter with newline too
 1 file changed, 1 insertion(+), 1 deletion(-)
bash-5.2$ git push
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 12 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 391 bytes | 391.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To github.com:ClausKlein/exemplar.git
   4d70f99..272f56f  feature/test-installed-package -> feature/test-installed-package
bash-5.2$ pre-commit autoupdate
[https://github.com/pre-commit/pre-commit-hooks] already up to date!
[https://github.com/pre-commit/mirrors-clang-format] updating v18.1.8 -> v20.1.7
[https://github.com/BlankSpruce/gersemi] updating 0.20.0 -> 0.19.3   # <<<<<<<<<<<<<
[https://github.com/codespell-project/codespell] updating v2.3.0 -> v2.4.1
bash-5.2$ 

@ClausKlein
Copy link
Copy Markdown
Contributor

@wermos
Copy link
Copy Markdown
Contributor Author

wermos commented Jul 6, 2025

update is sometime downgrade?

I'm not enough of a Git wizard to be able to conclusively demonstrate what's happening and why it's happening, but the GitHub release page indeed shows 0.20.0 as a release but running git ls-remote --tags https://github.com/BlankSpruce/gersemi.git shows 0.19.3 as the latest tag.

@ClausKlein
Copy link
Copy Markdown
Contributor

update is sometime downgrade?

I'm not enough of a Git wizard to be able to conclusively demonstrate what's happening and why it's happening, but the GitHub release page indeed shows 0.20.0 as a release but running git ls-remote --tags https://github.com/BlankSpruce/gersemi.git shows 0.19.3 as the latest tag.

perhaps GitHub needs more time, we should wait a week ;-)

@wermos
Copy link
Copy Markdown
Contributor Author

wermos commented Jul 13, 2025

A week has passed, and this is what I see right now:
image

(The other hooks are up-to-date because I ran the command once to see if I could reproduce the erroneous behavior, last week.)

@ClausKlein could you also run pre-commit autoupdate and see if v0.20.1 is showing up for you?

@ClausKlein
Copy link
Copy Markdown
Contributor

gersimi v0.20.1 is the current version, that is OK

@camio
Copy link
Copy Markdown
Member

camio commented Jul 18, 2025

There are two PR approvals here. Is this ready to be merged?

@wermos
Copy link
Copy Markdown
Contributor Author

wermos commented Jul 19, 2025

There are no objections to merging the PR from my side.

@neatudarius
Copy link
Copy Markdown
Member

There are no objections to merging the PR from my side.

Let's merge it!

@ClausKlein
Copy link
Copy Markdown
Contributor

The only point / question I have is:

  • what is about cookiecutter?
bash-5.2$ pre-commit autoupdate
[https://github.com/pre-commit/pre-commit-hooks] already up to date!
[https://github.com/pre-commit/mirrors-clang-format] updating v20.1.7 -> v20.1.8
[https://github.com/BlankSpruce/gersemi] updating 0.15.1 -> 0.21.0
[https://github.com/codespell-project/codespell] updating v2.3.0 -> v2.4.1
bash-5.2$ pre-commit run --all
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-clang-format.
[INFO] Initializing environment for https://github.com/BlankSpruce/gersemi.
[INFO] Installing environment for https://github.com/pre-commit/mirrors-clang-format.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/BlankSpruce/gersemi.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Passed
check for added large files..............................................Passed
clang-format.............................................................Passed
CMake linting............................................................Failed
- hook id: gersemi
- files were modified by this hook
codespell................................................................Passed
bash-5.2$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   .pre-commit-config.yaml
	modified:   src/beman/exemplar/CMakeLists.txt

bash-5.2$ 

@ednolan
Copy link
Copy Markdown
Member

ednolan commented Jul 19, 2025

@ClausKlein I don't think that issue relates to cookiecutter, just pre-commit. But it looks like it could have caused a legitimate problem, which I addressed in infra-workflows here and pulled into exemplar here.

@ednolan ednolan merged commit 058fe71 into bemanproject:main Jul 19, 2025
69 checks passed
@wermos
Copy link
Copy Markdown
Contributor Author

wermos commented Jul 20, 2025

It sounds to me that @ClausKlein has brought up a good point, and it's not immediately obvious to me what changes in infra-workflows make it a non-issue.

Namely, the updates to the version numbers inside the repo's .pre-commit-config.yaml won't be reflected in the cookiecutter's copy of .pre-commit-config.yaml, and this will be flagged as an error in the CI. Am I missing something?

@ednolan
Copy link
Copy Markdown
Member

ednolan commented Jul 20, 2025

Oh, good point, I didn't put that together. I'll have to think about how to fix that. In the meantime we can manually patch up the pull requests for exemplar, and it won't be an issue for other repositories because they don't use cookiecutter.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants