Feature/precommit hooks - #517
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces pre-commit hooks using prek, updates various tool versions in .mise.toml, migrates repository references from the earthly organization to EarthBuild/earthbuild, and upgrades several Go dependencies in go.mod. The reviewer identified three critical issues: invalid module paths and non-existent versions for both golangci-lint and gofumpt in .mise.toml which will cause installation failures, and a mismatched variable name (BUILDKIT_BRANCH instead of BUILDKIT_GIT_BRANCH) in buildkitd/Earthfile that results in empty branch names in logs.
|
@copilot resolve the merge conflicts in this pull request |
|
Are these several things going on here? Is this the minimal changes for the precommit? Could we get these split out into smaller PRs please? |
a9634ba to
9ef9821
Compare
|
| Branch | Total Count |
|---|---|
| main | 5344 |
| This PR | 5349 |
| Difference | +5 (0.09%) |
📁 Changes by file type:
| File Type | Change |
|---|---|
| Go files (.go) | ➖ No change |
| Documentation (.md) | ➖ No change |
| Earthfiles | ❌ +3 |
Keep up the great work migrating from Earthly to Earthbuild! 🚀
💡 Tips for finding more occurrences
Run locally to see detailed breakdown:
./.github/scripts/count-earthly.shNote that the goal is not to reach 0.
There is anticipated to be at least some occurences of earthly in the source code due to backwards compatibility with config files and language constructs.
b26d605 to
9cb24c5
Compare
9cb24c5 to
a387cc9
Compare
gilescope
left a comment
There was a problem hiding this comment.
Looks good but let's eat our own dogfood and use earth to run the commands for reproducibility. If earth is slow used in this fashion we'll have good reason to speed it up.
- Add prek.toml with hooks for gofumpt (staged files only), golangci-lint (auto and manual --fix), and shellcheck. - Add .mise.toml entries for prek and gofumpt so hooks resolve without a locally installed binary. - Refactor Earthfile: split +lint into +lint-deps / +lint, add +lint-fix (saves corrected files back via SAVE ARTIFACT AS LOCAL), add +fmt-go with a --files ARG (defaults to ".") so the gofumpt hook can scope to staged files only, and add +lint-scripts that shellchecks every *.sh in the repo in its own directo - Inline golangci-lint install logic into +lint-deps (removes scripts/golangci-lint.sh); fix install.sh branch from master to main so the checksum grep is anchored and verification succeeds. - Fix +lint-fix SAVE ARTIFACT to mirror only the files +code copies, preventing silent deletion of non-Go files in the working tree. - Expand shellcheck coverage from a curated subset to the whole repo; fix all 64 pre-existing findings across tests/, release/, examples/, and .github/scripts/ (SC2068 unquoted $@, SC2251 ! under set -e, SC2295 glob leakage in assert.sh, SC2086/SC2046 unquoted expansions, SC2044 for-over-find, SC3040 pipefail under /bin/sh, SC2059 printf injection, and others). - Apply gofumpt baseline formatting across 30 files to establish a clean prek run --all-files starting point.
fd1e1cb to
d371b5b
Compare
Add prek pre-commit hooks for lint auto-fix
What
Introduces prek as a Git pre-commit hook manager to automatically fix Go linting and formatting issues before every commit.
Changes
prek.toml(new) — declares two hooks that run on staged.gofiles:.golangci.yaml.--fix— applies all auto-fixable lint corrections. Runs against full packages (pass_filenames = false) so type-checking is correct..mise.toml— adds three new tools somise installsets up the full dev environment in one step:prek 0.4.3— the hook manager itself.golangci-lint v2.11.4(viago:backend) — pinned to match the version inEarthfile.gofumpt v0.10.0(viago:backend) — pinned to the current latest release.Both tool versions carry
# renovate:comments so Renovate will keep them in sync automatically.CONTRIBUTING.md— adds a Pre-commit hooks section documenting the two-command setup:How it works
On
git commit, prek runs the hooks against staged.gofiles only (non-Go commits are unaffected). If a hook modifies a file, the commit is blocked so you can review the diff, re-stage, and commit again. To pre-apply all fixes before staging:prek run --all-files.