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

Commit cd60809

Browse files
authored
Added script for checking diff of generated code (#30)
* Added ci check for go generate Signed-off-by: Yuvraj <code@evalsocket.dev>
1 parent d98b16b commit cd60809

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed

.github/workflows/pull_request.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,13 @@ jobs:
6868
with:
6969
version: latest
7070
args: --snapshot --skip-publish --rm-dist
71+
72+
generate:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v1
76+
- uses: actions/setup-go@v2
77+
with:
78+
go-version: '1.16'
79+
- name: Go generate and diff
80+
run: DELTA_CHECK=true make generate

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ update_boilerplate:
77
@curl https://raw.githubusercontent.com/flyteorg/boilerplate/master/boilerplate/update.sh -o boilerplate/update.sh
88
@boilerplate/update.sh
99

10-
generate: download_tooling
11-
@go generate ./...
12-
1310
clean:
1411
rm -rf bin
1512

boilerplate/flyte/end2end/end2end.sh

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,5 @@ git clone https://github.com/flyteorg/flyte.git "${OUT}"
1515

1616
pushd ${OUT}
1717

18-
if [ ! -z "$IMAGE" ];
19-
then
20-
kind load docker-image ${IMAGE}
21-
if [ "${IMAGE_NAME}" == "flytepropeller" ]
22-
then
23-
sed -i.bak -e "s_${IMAGE_NAME}:.*_${IMAGE}_g" "${OUT}"/kustomize/base/propeller/deployment.yaml
24-
fi
25-
26-
if [ "${IMAGE_NAME}" == "flyteadmin" ]
27-
then
28-
sed -i.bak -e "s_${IMAGE_NAME}:.*_${IMAGE}_g" "${OUT}"/kustomize/base/admindeployment/deployment.yaml
29-
fi
30-
fi
31-
32-
make kustomize
33-
# launch flyte end2end
34-
kubectl apply -f "${OUT}/deployment/test/flyte_generated.yaml"
3518
make end2end_execute
3619
popd

boilerplate/flyte/golang_test_targets/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
download_tooling: #download dependencies (including test deps) for the package
99
@boilerplate/flyte/golang_test_targets/download_tooling.sh
1010

11+
.PHONY: generate
12+
generate: download_tooling #generate go code
13+
@boilerplate/flyte/golang_test_targets/go-gen.sh
14+
1115
.PHONY: lint
1216
lint: download_tooling #lints the package for common code smells
1317
GL_DEBUG=linters_output,env golangci-lint run --deadline=5m --exclude deprecated -v
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
echo "Running go generate"
6+
go generate ./...
7+
8+
# This section is used by GitHub workflow to ensure that the generation step was run
9+
if [ -n "$DELTA_CHECK" ]; then
10+
DIRTY=$(git status --porcelain)
11+
if [ -n "$DIRTY" ]; then
12+
echo "FAILED: Go code updated without commiting generated code."
13+
echo "Ensure make generate has run and all changes are committed."
14+
DIFF=$(git diff)
15+
echo "diff detected: $DIFF"
16+
DIFF=$(git diff --name-only)
17+
echo "files different: $DIFF"
18+
exit 1
19+
else
20+
echo "SUCCESS: Generated code is up to date."
21+
fi
22+
fi

0 commit comments

Comments
 (0)