Fix check-code-regeneration CI jobs #4
Workflow file for this run
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
name: ci | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["**"] | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
permissions: | |
contents: "read" | |
jobs: | |
check-code-regeneration: | |
runs-on: ubuntu-latest | |
if: ${{ !github.event.pull_request.draft }} | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- name: Set up go | |
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | |
with: | |
go-version: 1.21 | |
- name: Install gen dependencies | |
run: | | |
go install github.com/mailru/easyjson/...@latest | |
go install github.com/hashicorp/copywrite@latest | |
- name: Ensure the code has been properly regenerated with 'go generate ./...' | |
run: | | |
go generate ./... | |
readonly changed_files="$(git diff --stat)" | |
if [[ "${changed_files}" != "" ]]; then | |
readonly changes="$(git diff)" | |
echo "Found differences after running 'go generate ./...'" | |
echo "Please run 'go generate ./...' & commit the changed files:" | |
echo "${changed_files}" | |
echo "Here are the differences:" | |
echo "${changes}" | |
exit 1 | |
fi | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- name: Set up go | |
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | |
with: | |
go-version: 1.21 | |
- name: Build | |
run: go build -v ./... | |
- name: Test | |
run: go test -v ./... | |
# TODO @dvcorreia: add linting workflow |