Skip to content

Commit

Permalink
add job to ensure generated files are up to date
Browse files Browse the repository at this point in the history
  • Loading branch information
capnspacehook committed Oct 30, 2022
1 parent 364f21d commit f25471a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/lint-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
check-latest: true
cache: true

- name: Check if go.mod was tidied
- name: Ensure go.mod was tidied
run: |
go mod tidy -compat ${{ env.GO_VERSION }}
STATUS=$( git status --porcelain go.mod go.sum )
Expand All @@ -37,6 +37,32 @@ jobs:
fi
exit 0
check-go-generate:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}.x
check-latest: true
cache: true

# Install any tools 'go generate' uses here

- name: Ensure 'go generate' is clean
run: |
go generate "$(go list ./...)"
echo
echo
if git diff --name-only --exit-code; then
echo "The files above need updating. Please run 'go generate'."
exit 1
fi
staticcheck:
runs-on: ubuntu-latest
steps:
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ Multiple workflows are configured that will:

- Lint Go code
- Check that `go.mod` is tidied
- Check that generated files are up to date
- Test Go code and fuzz for 10 minutes
- Lint workflow files with [actionlint](https://github.com/rhysd/actionlint)
- Lint the Dockerfile with [hadolint](https://github.com/hadolint/hadolint)
- Lint workflow files with [actionlint](https://github.com/rhysd/actionlint)
- Build, publish, sign and scan Docker images with [cosign](https://github.com/sigstore/cosign), [grype](https://github.com/anchore/grype) and [trivy](https://github.com/aquasecurity/trivy)
- Build, sign, publish binaries and create releases with [goreleaser](https://github.com/goreleaser/goreleaser) and [cosign](https://github.com/sigstore/cosign)

Expand All @@ -24,11 +25,14 @@ Binaries will only be released when a semver compatible tag is pushed however.

Use this repository as a template and build your project from it.

Workflow files will work without modification, as will releasing Docker images and binaries with goreleaser.
Almost all workflow files will work without modification, as will releasing Docker images and binaries with goreleaser.
Note that only `linux/amd64` images and binaries are built by default, so you may need to add more target
operating systems and/or architectures based off of your requirements.

The workflow that tests and fuzzes Go code will still pass if no tests or fuzz tests are present, so when you
You may need to add steps to install tools that `go generate` uses in the `Lint Go/check-go-generate` job for it
to work correctly.

The `Test` workflow will still pass if no tests or fuzz tests are present, so when you
do add tests and fuzz tests the workflow will run them without needing any changes from you.

When you want to change the Go version that is used in workflows, simply change the `GO_VERSION` to the minor
Expand Down

0 comments on commit f25471a

Please sign in to comment.