Skip to content

ci(prek): add language caching and use PR base/head refs - #3

Merged
benbenbang merged 1 commit into
mainfrom
ci/update
Sep 7, 2026
Merged

benbenbang merged 1 commit into
mainfrom
ci/update

Conversation

@benbenbang

Copy link
Copy Markdown
Member

This pull request enhances the reusable prek workflow with language-specific caching, more robust pull request handling, and new configurable inputs. The main changes are grouped below.

Language caching support:

  • Added a Set up Go and restore Go caches step that runs actions/setup-go when a Go version file is present, with caching keyed on go.mod and go.sum.
  • Added a Restore Rust caches step using Swatinem/rust-cache when a Cargo.toml is present, saving only on pushes to the default branch.
  • Updated the prek hook cache key to include both .pre-commit-config.yaml and .prek-config.yaml.

Pull request handling improvements:

  • Switched pull request detection to github.event_name == 'pull_request' and used the base/head SHAs for the diff range instead of origin/main.
  • Generalized default branch checks to use github.event.repository.default_branch instead of a hardcoded main.

New workflow inputs:

  • Added go_version_file input to control which file the Go setup reads the version from.
  • Added prek_skip input to skip hooks, files, or stages during the prek run.
  • Changed run_all_files to a boolean type and improved input descriptions.

Miscellaneous:

  • Bumped action versions for checkout, cache, and setup-go.

This pull request enhances the reusable prek workflow with language-specific caching, more robust pull request handling, and new configurable inputs. The main changes are grouped below.

**Language caching support:**
* Added a `Set up Go and restore Go caches` step that runs `actions/setup-go` when a Go version file is present, with caching keyed on `go.mod` and `go.sum`.
* Added a `Restore Rust caches` step using `Swatinem/rust-cache` when a `Cargo.toml` is present, saving only on pushes to the default branch.
* Updated the prek hook cache key to include both `.pre-commit-config.yaml` and `.prek-config.yaml`.

**Pull request handling improvements:**
* Switched pull request detection to `github.event_name == 'pull_request'` and used the base/head SHAs for the diff range instead of `origin/main`.
* Generalized default branch checks to use `github.event.repository.default_branch` instead of a hardcoded `main`.

**New workflow inputs:**
* Added `go_version_file` input to control which file the Go setup reads the version from.
* Added `prek_skip` input to skip hooks, files, or stages during the prek run.
* Changed `run_all_files` to a boolean type and improved input descriptions.

**Miscellaneous:**
* Bumped action versions for checkout, cache, and setup-go.
@benbenbang
benbenbang enabled auto-merge (squash) September 7, 2026 04:16
@benbenbang
benbenbang merged commit 1ac13de into main Sep 7, 2026
5 checks passed
@benbenbang
benbenbang deleted the ci/update branch September 7, 2026 04:17
@ptah-bw-technical-app

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant