-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add a check for go mod tidy (#2481)
## Description Adds a check in CI and `pre-commit` hooks to check if `go mod tidy` needs to be ran in a PR This PR adds: - shell script to check if `go mod tidy` needs to be ran in a PR - `make` target to call the script - workflow to run in CI - `pre-commit` hook ## Checklist before merging - [ ] Test, docs, adr added or updated as needed - [ ] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/.github/CONTRIBUTING.md#developer-workflow) followed
- Loading branch information
1 parent
15a73e0
commit e69f3ab
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,26 @@ | ||
name: Validate Go Mod Tidy | ||
on: | ||
pull_request: | ||
paths: | ||
- "go.mod" | ||
- "go.sum" | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Setup golang | ||
uses: ./.github/actions/golang | ||
|
||
- name: Check go mod tidy | ||
run: make test-go-mod-tidy | ||
|
||
- name: Save logs | ||
if: always() | ||
uses: ./.github/actions/save-logs |
This file contains 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
This file contains 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
This file contains 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,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
go mod tidy | ||
if ! git diff --quiet go.mod go.sum; then | ||
echo "ERROR: Changes detected after running 'go mod tidy'. Please run 'go mod tidy' and commit the changes." | ||
exit 1 | ||
fi |