-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (58 loc) · 1.85 KB
/
Copy pathcheckproto.yaml
File metadata and controls
71 lines (58 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Proto Consistency
on:
push:
branches:
- main
paths:
- "**/*.proto"
- "**/*.pb.go"
- "Makefile"
pull_request:
branches:
- main
paths:
- "**/*.proto"
- "**/*.pb.go"
- "Makefile"
permissions:
contents: read
jobs:
checkproto:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.26.6
- name: Set up protoc
run: |
PROTOC_VERSION=33.1
PROTOC_GEN_VERSION=v1.36.11
PROTOC_GRPC_VERSION=v1.6.0
# Download and install protoc
PROTOC_ZIP=protoc-$PROTOC_VERSION-linux-x86_64.zip
curl -0L -o $PROTOC_ZIP https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP
unzip -o $PROTOC_ZIP -d protoc3
sudo mv protoc3/bin/* /usr/local/bin/
sudo mv protoc3/include/* /usr/local/include/
rm -rf $PROTOC_ZIP protoc3
# Install protoc-gen-go and protoc-gen-go-grpc
go install google.golang.org/protobuf/cmd/protoc-gen-go@$PROTOC_GEN_VERSION
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$PROTOC_GRPC_VERSION
# Add protoc to the PATH
export PATH=$PATH:/usr/local/bin/protoc
- name: Verify generated protobuf files
run: |
git ls-files '*.pb.go' > /tmp/generated-protobuf-files.txt
while IFS= read -r p; do
mv "$p" "$p.tmp"
done < /tmp/generated-protobuf-files.txt
make protoc
while IFS= read -r p; do
if ! cmp -s "$p" "$p.tmp"; then
echo "Proto file and generated Go file $p are out of sync!"
exit 1
fi
done < /tmp/generated-protobuf-files.txt