Skip to content

Commit

Permalink
ci: ensure the generated code is up-to-date
Browse files Browse the repository at this point in the history
See etcd-io#14612 (comment)
Signed-off-by: spacewander <spacewanderlzx@gmail.com>
  • Loading branch information
spacewander committed Oct 31, 2022
1 parent a1018db commit 6f61edd
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 197 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
version: v1.49.0
- name: protoc
uses: arduino/setup-protoc@v1
with:
version: '3.14.0'
- run: make verify
- run: make fix
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ fuzz:

# Static analysis

verify: verify-gofmt verify-bom verify-lint verify-dep verify-shellcheck verify-goword verify-govet verify-license-header verify-receiver-name verify-mod-tidy verify-shellcheck verify-shellws verify-proto-annotations
verify: verify-gofmt verify-bom verify-lint verify-dep verify-shellcheck verify-goword \
verify-govet verify-license-header verify-receiver-name verify-mod-tidy verify-shellcheck \
verify-shellws verify-proto-annotations verify-genproto
fix: fix-bom fix-lint
./scripts/fix.sh

Expand Down Expand Up @@ -99,6 +101,10 @@ verify-shellws:
verify-proto-annotations:
PASSES="proto_annotations" ./scripts/test.sh

.PHONY: verify-genproto
verify-genproto:
PASSES="genproto" ./scripts/test.sh


# Cleanup

Expand Down
4 changes: 4 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,10 @@ function proto_annotations_pass {
"${ETCD_ROOT_DIR}/scripts/verify_proto_annotations.sh"
}

function genproto_pass {
"${ETCD_ROOT_DIR}/scripts/verify_genproto.sh"
}

########### MAIN ###############################################################

function run_pass {
Expand Down
18 changes: 18 additions & 0 deletions scripts/verify_genproto.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# This scripts is automatically run by CI to prevent pull requests missing running genproto.sh
# after changing *.proto file.

set -o errexit
set -o nounset
set -o pipefail

./scripts/genproto.sh
diff=$(git diff | wc -l)
if [ "$diff" -eq 0 ]; then
echo "PASSED genproto-verification!"
exit 0
fi
echo "Failed genproto-verification!" >&2
echo "* Please rerun genproto.sh after changing *.proto file" >&2
echo "* Run ./scripts/genproto.sh" >&2
exit 1
2 changes: 1 addition & 1 deletion scripts/verify_proto_annotations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ fi
echo "Failed proto-annotations-verification!" >&2
echo "If you are adding new proto fields/messages that will be included in raft log:" >&2
echo "* Please add etcd_version annotation in *.proto file with next etcd version" >&2
echo "* Run ./scripts/getproto.sh" >&2
echo "* Run ./scripts/genproto.sh" >&2
echo "* Run ./scripts/update_proto_annotations.sh" >&2
exit 1
Loading

0 comments on commit 6f61edd

Please sign in to comment.