Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-commit.ci configurations to enable auto updates of hooks #3414

Merged
merged 9 commits into from
Aug 27, 2024

Conversation

seisman
Copy link
Member

@seisman seisman commented Aug 26, 2024

Description of proposed changes

Run pre-commit autoupdate command in the Style Checks workflow, to check if there are new versions of pre-commit hooks. The workflow will fail if there are updates. Then we just need to open a PR to manually update the workflow.

Address #3374 (comment).

@@ -37,6 +37,11 @@ jobs:
python -m pip install ruff pre-commit
python -m pip list

- name: Check updates of pre-commit hooks
run: |
pre-commit autoupdate
Copy link
Member

Choose a reason for hiding this comment

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

Maybe run the autoupdate line only on cron jobs? So that PRs don't get slowed down by sudden Style Check changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. I've added the if-condition so that the autoupdate command only runs on schedule or workflow_dispatch events. It means we have to check https://github.com/GenericMappingTools/pygmt/actions/workflows/style_checks.yaml to know if there are new versions for hooks. Maybe we should automatically open a PR if there are updates?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should automatically open a PR if there are updates?

Maybe we could just use pre-commit.ci as was tried in #3283? The automation would require quite a bit of code to set up. Ideally we could use dependabot but looking at dependabot/dependabot-core#1524, it's still not working yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm OK with enabling pre-commit.ci for auto update.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, add these lines to .pre-commit-config.yaml :

# https://pre-commit.ci/#configuration
ci:
  autofix_prs: false
  autoupdate_schedule: quarterly

Copy link
Member Author

Choose a reason for hiding this comment

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

@seisman seisman changed the title POC: CI: Update pre-commit hooks in the Style Checks workflow Add pre-commit.ci configurations to enable auto updates of hooks Aug 27, 2024
@seisman seisman marked this pull request as ready for review August 27, 2024 09:30
@seisman seisman added the maintenance Boring but important stuff for the core devs label Aug 27, 2024
@seisman seisman added this to the 0.13.0 milestone Aug 27, 2024
@seisman seisman merged commit 9daa2cb into main Aug 27, 2024
7 checks passed
@seisman seisman deleted the ci/pre-commit branch August 27, 2024 09:36
@seisman
Copy link
Member Author

seisman commented Aug 27, 2024

pre-commit.ci fails in the main branch https://results.pre-commit.ci/run/github/85352251/1724751409.rGgeqA4fQ22hZH-xAZG-Nw, as mentioned in #3283 (comment).

It seems we can't change how files are cloned in pre-commit.ci and also can't disable pre-commit.ci in the main branch. I guess the only option is removing the chmod hook from .pre-commit-config.yaml and add it back to the style checks workflow.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Boring but important stuff for the core devs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants