Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Added script for checking diff of generated code (#30)
Browse files Browse the repository at this point in the history
* Added ci check for go generate

Signed-off-by: Yuvraj <code@evalsocket.dev>
  • Loading branch information
yindia committed Dec 6, 2021
1 parent d98b16b commit cd60809
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 20 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,13 @@ jobs:
with:
version: latest
args: --snapshot --skip-publish --rm-dist

generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v2
with:
go-version: '1.16'
- name: Go generate and diff
run: DELTA_CHECK=true make generate
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ update_boilerplate:
@curl https://raw.githubusercontent.com/flyteorg/boilerplate/master/boilerplate/update.sh -o boilerplate/update.sh
@boilerplate/update.sh

generate: download_tooling
@go generate ./...

clean:
rm -rf bin

Expand Down
17 changes: 0 additions & 17 deletions boilerplate/flyte/end2end/end2end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,5 @@ git clone https://github.com/flyteorg/flyte.git "${OUT}"

pushd ${OUT}

if [ ! -z "$IMAGE" ];
then
kind load docker-image ${IMAGE}
if [ "${IMAGE_NAME}" == "flytepropeller" ]
then
sed -i.bak -e "s_${IMAGE_NAME}:.*_${IMAGE}_g" "${OUT}"/kustomize/base/propeller/deployment.yaml
fi

if [ "${IMAGE_NAME}" == "flyteadmin" ]
then
sed -i.bak -e "s_${IMAGE_NAME}:.*_${IMAGE}_g" "${OUT}"/kustomize/base/admindeployment/deployment.yaml
fi
fi

make kustomize
# launch flyte end2end
kubectl apply -f "${OUT}/deployment/test/flyte_generated.yaml"
make end2end_execute
popd
4 changes: 4 additions & 0 deletions boilerplate/flyte/golang_test_targets/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
download_tooling: #download dependencies (including test deps) for the package
@boilerplate/flyte/golang_test_targets/download_tooling.sh

.PHONY: generate
generate: download_tooling #generate go code
@boilerplate/flyte/golang_test_targets/go-gen.sh

.PHONY: lint
lint: download_tooling #lints the package for common code smells
GL_DEBUG=linters_output,env golangci-lint run --deadline=5m --exclude deprecated -v
Expand Down
22 changes: 22 additions & 0 deletions boilerplate/flyte/golang_test_targets/go-gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -ex

echo "Running go generate"
go generate ./...

# This section is used by GitHub workflow to ensure that the generation step was run
if [ -n "$DELTA_CHECK" ]; then
DIRTY=$(git status --porcelain)
if [ -n "$DIRTY" ]; then
echo "FAILED: Go code updated without commiting generated code."
echo "Ensure make generate has run and all changes are committed."
DIFF=$(git diff)
echo "diff detected: $DIFF"
DIFF=$(git diff --name-only)
echo "files different: $DIFF"
exit 1
else
echo "SUCCESS: Generated code is up to date."
fi
fi

0 comments on commit cd60809

Please sign in to comment.