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
5 changes: 5 additions & 0 deletions .github/workflows/style_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.

if [[ $(git ls-files -m) ]]; then git --no-pager diff HEAD; exit 1; fi

- name: Formatting check (ruff + pre-commit)
run: |
make check
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-yaml
Expand Down
Loading