Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/verify-codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Verify

on:
pull_request:
workflow_dispatch:

jobs:
verify:
name: Verify Codegen

runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Run Codegen
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make update-codegen

- name: Verify
shell: bash
run: |
# URL encode function for GitHub Actions annotations
# From: https://backreference.org/2009/12/23/how-to-match-newlines-in-sed/
function urlencode() {
sed ':begin;$!N;s/\n/%0A/;tbegin'
}

if [[ -z "$(git status --porcelain)" ]]; then
echo "${{ github.repository }} up to date."
else
echo "Found diffs in: $(git diff-index --name-only HEAD --)"
for x in $(git diff-index --name-only HEAD --); do
echo "::error file=$x::Please run 'make update-codegen'.%0A$(git diff $x | urlencode)"
done
echo "Generated code is out of date. Please run 'make update-codegen' and commit the changes."
exit 1
fi
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.
create-kind-cluster:
./hack/create-kind-cluster.sh

.PHONY: update-codegen
update-codegen: generate manifests gen-mocks

##@ Dependencies

## Location to install dependencies to
Expand Down
Loading