Repository navigation
HYPERFLEET-1806 - ci: add pre-commit secondary checks #21
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
Closed
rafabene
wants to merge
5
commits into
openshift-hyperfleet:main
from
rafabene:HYPERFLEET-1806-precommit-ci
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0e9d82b
HYPERFLEET-1806 - ci: add pre-commit secondary checks
rafabene d78b6c1
HYPERFLEET-1806 - ci: scope permissions and install project hooks
rafabene 61d99d8
HYPERFLEET-1806 - ci: keep generation only in the API workflow
rafabene 649186f
HYPERFLEET-1806 - ci: cache compatible pre-commit environments
rafabene 3345b02
HYPERFLEET-1806 - ci: omit unnecessary Git hook registration
rafabene File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| name: pre-commit | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: pre-commit-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| pre-commit: | ||
| permissions: | ||
| contents: read | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 30 | ||
| env: | ||
| CGO_ENABLED: "0" | ||
| PRE_COMMIT_VERSION: "4.6.2" | ||
| steps: | ||
| - name: Check out source | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Go | ||
| id: go | ||
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | ||
| with: | ||
| go-version-file: go.mod | ||
| cache-dependency-path: | | ||
| go.sum | ||
| tools/go.sum | ||
|
|
||
| - name: Set up Python | ||
| id: python | ||
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Cache pre-commit environments | ||
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | ||
| with: | ||
| path: ~/.cache/pre-commit | ||
| key: pre-commit-v1-${{ runner.os }}-${{ runner.arch }}-go${{ steps.go.outputs.go-version }}-py${{ steps.python.outputs.python-version }}-pc${{ env.PRE_COMMIT_VERSION }}-${{ hashFiles('.pre-commit-config.yaml') }} | ||
|
|
||
| - name: Install pre-commit | ||
| run: python -m pip install "pre-commit==${PRE_COMMIT_VERSION}" | ||
|
|
||
| # This runs pre-commit-stage hooks; PR-title validation stays in Prow. | ||
| - name: Run pre-commit hooks | ||
| run: pre-commit run --all-files --show-diff-on-failure | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cache step only saves on success, so any run where the hooks fail throws away the environments it just built, and failing on unformatted code is this check's normal outcome, so fix-and-repush cycles rebuild from scratch every time. Consider splitting it into
actions/cache/restore+actions/cache/savewithif: always()per the upstream docs.