forked from drand/drand
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (57 loc) · 1.87 KB
/
generate.yml
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
# Regenerates generated files and ensures PRs commit generated updates
name: Generate
on:
pull_request:
branches: [ master ]
jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/[email protected]
id: generate-dep-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- uses: actions/[email protected]
with:
go-version: '1.19.5'
- name: Fetch Dependencies
run: go get ./...
- name: Install Protoc
uses: arduino/setup-protoc@ab6203da1c3118e4406048171b09238ad31ad73e # [email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: '3.19.6'
- name: Install Protoc-gen-go
run: |
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
- name: Generate
run: go generate ./...&& go mod tidy
- name: Check
# git status --porcelain shows changed files.
# the echoed output provides github action output format, per
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjobs_idoutputs
run: |
protoc --version
protoc-gen-go --version
protoc-gen-go-grpc --version
if [[ -z "$(git status --porcelain)" ]];
then
exit 0
else
OUTPUT=$(git status --porcelain)
git diff
for file in $OUTPUT
do
f=$(echo $file | sed -e 's/^.* //')
echo "::error file=$f,line=1,col=1::File $f not in sync with ``go generate``"
done
OUTPUT="${OUTPUT//'%'/'%25'}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "::set-output name=result::$OUTPUT"
exit 1
fi