Skip to content

Commit

Permalink
Added script for checking diff of generated code (#229)
Browse files Browse the repository at this point in the history
* Added script for checking diff of generated code

Signed-off-by: Yuvraj <[email protected]>
  • Loading branch information
yindia authored Dec 6, 2021
1 parent 0f9eee8 commit bd1d4e5
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion flytectl/.github/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Comment to be posted on PRs from first-time contributors in your repository
newPRWelcomeComment: >
newPRWelcomeComment: |
Thank you for opening this pull request! 🙌
These tips will help get your PR across the finish line:
Expand Down
10 changes: 10 additions & 0 deletions flytectl/.github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,13 @@ jobs:
env:
GO111MODULE: "on"
run: make install && make lint

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 flytectl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ define PIP_COMPILE
pip-compile $(1) --upgrade --verbose
endef

generate:
go test github.com/flyteorg/flytectl/cmd --update

compile:
go build -o bin/flytectl -ldflags=$(LD_FLAGS) main.go

Expand Down
4 changes: 2 additions & 2 deletions flytectl/boilerplate/flyte/golang_support_tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ go 1.16

require (
github.com/alvaroloes/enumer v1.1.2
github.com/flyteorg/flytestdlib v0.3.22
github.com/flyteorg/flytestdlib v0.4.7
github.com/golangci/golangci-lint v1.38.0
github.com/pseudomuto/protoc-gen-doc v1.4.1 // indirect
github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5
github.com/pseudomuto/protoc-gen-doc v0.1.1 // indirect
)

replace github.com/vektra/mockery => github.com/enghabu/mockery v0.0.0-20191009061720-9d0c8670c2f0
Expand Down
5 changes: 3 additions & 2 deletions flytectl/boilerplate/flyte/golang_support_tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
github.com/flyteorg/flytestdlib v0.3.22 h1:nJEPaCdxzXBaeg2p4fdo3I3Ua09NedFRaUwuLafLEdw=
github.com/flyteorg/flytestdlib v0.3.22/go.mod h1:1XG0DwYTUm34Yrffm1Qy9Tdr/pWQypEqTq5dUxw3/cM=
github.com/flyteorg/flytestdlib v0.4.7 h1:SMPPXI3j/MjP7D2fqaR+lPQkTrqYS7xZbwsgJI2F8SU=
github.com/flyteorg/flytestdlib v0.4.7/go.mod h1:fv1ar34LJLMTaf0tbfetisLykUlARi7rP+NQTUn6QQs=
github.com/flyteorg/protoc-gen-doc v1.4.2 h1:Otw0F+RHaPQ8XlpzhLLgjsCMcrAIcMO01Zh+ALe3rrE=
github.com/flyteorg/protoc-gen-doc v1.4.2/go.mod h1:exDTOVwqpp30eV/EDPFLZy3Pwr2sn6hBC1WIYH/UbIg=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk=
Expand Down Expand Up @@ -1263,6 +1263,7 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.1.2 h1:SMdYLJl312RXuxXziCCHhRsp/tvct9cGKey0yv95tZM=
honnef.co/go/tools v0.1.2/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
k8s.io/api v0.0.0-20210217171935-8e2decd92398/go.mod h1:60tmSUpHxGPFerNHbo/ayI2lKxvtrhbxFyXuEIWJd78=
k8s.io/api v0.20.2/go.mod h1:d7n6Ehyzx+S+cE3VhTGfVNNqtGc/oL9DCdYYahlurV8=
k8s.io/apimachinery v0.0.0-20210217011835-527a61b4dffe/go.mod h1:Z7ps/g0rjlTeMstYrMOUttJfT2Gg34DEaG/f2PYLCWY=
k8s.io/apimachinery v0.20.2 h1:hFx6Sbt1oG0n6DZ+g4bFt5f6BoMkOjKWsQFu077M3Vg=
k8s.io/apimachinery v0.20.2/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU=
Expand Down
4 changes: 4 additions & 0 deletions flytectl/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 flytectl/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
2 changes: 1 addition & 1 deletion flytectl/boilerplate/flyte/welcome_bot/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Comment to be posted on PRs from first-time contributors in your repository
newPRWelcomeComment: >
newPRWelcomeComment: |
Thank you for opening this pull request! 🙌
These tips will help get your PR across the finish line:
Expand Down

0 comments on commit bd1d4e5

Please sign in to comment.