Skip to content

Disable actionlint hook by default when running pre-commit locally#15061

Merged
AlexWaygood merged 2 commits intomainfrom
alex/speedup-pre-commit
Dec 19, 2024
Merged

Disable actionlint hook by default when running pre-commit locally#15061
AlexWaygood merged 2 commits intomainfrom
alex/speedup-pre-commit

Conversation

@AlexWaygood
Copy link
Member

Summary

We added actionlint as a pre-commit hook in #15021. Unfortunately, it's by far the slowest hook in our pre-commit config, so this now makes running uvx pre-commit run -a locally quite slow.

This PR tweaks our pre-commit config so that it will now be disabled by default when running pre-commit locally but will be enabled when pre-commit is run in CI. This is achieved by reworking the hook entry so that it is only run when --hook-stage=manual is specified on the command line.

Test Plan

The hook now runs instantaneously when uvx pre-commit run -a is invoked for me locally (because it is skipped), but still picks up errors in GitHub Actions workflows when --hook-stage=manual is specified. I also checked the exact command we'll be running in .github/workflows/ci.yaml, and actionlint correctly flags issues locally when that command is run.

@AlexWaygood AlexWaygood added the ci Related to internal CI tooling label Dec 19, 2024
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Thank you!

echo '```console' > "$GITHUB_STEP_SUMMARY"
# Enable color output for pre-commit and remove it for the summary
SKIP=cargo-fmt,clippy,dev-generate-all pre-commit run --all-files --show-diff-on-failure --color=always | \
SKIP=cargo-fmt,clippy,dev-generate-all pre-commit run --all-files --show-diff-on-failure --color=always --hook-stage=manual | \
Copy link
Member

Choose a reason for hiding this comment

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

Nit: It wasn't very clear to me what manual means. What would you think of renaming it to CI?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately this is out of my control 😆 it has to be one of git's recognised hook stages or manual: https://pre-commit.com/#confining-hooks-to-run-at-certain-stages

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'll add a comment to this workflow file, though

@github-actions
Copy link
Contributor

github-actions bot commented Dec 19, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@AlexWaygood AlexWaygood enabled auto-merge (squash) December 19, 2024 12:40
@AlexWaygood AlexWaygood merged commit d8b9a36 into main Dec 19, 2024
@AlexWaygood AlexWaygood deleted the alex/speedup-pre-commit branch December 19, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Related to internal CI tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants