-
Notifications
You must be signed in to change notification settings - Fork 8
115 lines (98 loc) · 3.11 KB
/
go.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Build and Test
on:
push:
branches:
- 'main'
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["1.20"]
command: ["build", "vet", "lint", "test", "testrace"]
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.version }}
cache: true
- name: Cache linter
uses: actions/cache@v3
with:
path: ~/go/bin/golangci-lint
key: golangci-lint-v1.51.2
if: ${{ matrix.command == 'lint' }}
- name: Install linter
run: go install github.com/golangci/golangci-lint/cmd/[email protected]
if: ${{ matrix.command == 'lint' }}
- name: ${{ matrix.command }}
run: ./dev/build_and_test ${{ matrix.command }}
generate:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["1.20"]
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.version }}
cache: true
- name: Cache protoc-gen-go
uses: actions/cache@v3
with:
path: ~/go/bin/protoc-gen-go
key: protoc-gen-go-v1.26
- name: Cache addlicense
uses: actions/cache@v3
with:
path: ~/go/bin/addlicense
key: addlicense-v1.1.1
- name: Install protoc
run: sudo apt install -y protobuf-compiler
- name: Install protoc-gen-go
run: go install google.golang.org/protobuf/cmd/[email protected]
- name: Install addlicense
run: go install github.com/google/[email protected]
- name: Install weaver
run: go install github.com/ServiceWeaver/weaver/cmd/weaver@latest
- name: Generate code
run: ./dev/build_and_test generate
- name: Check spurious changes
run: |
# TODO(mwhittaker): Check .pb.go files.
# Exclude .pb.go files, as the protoc version may differ.
if [[ $(git ls-files --modified --others | grep -v '.*\.pb\.go') ]]; then
for f in $(git ls-files --modified); do
if ! [[ $f == *.pb.go ]]; then
echo "❌ File $f modified."
git diff "$f"
fi
done
for f in $(git ls-files --others); do
echo "❌ File $f untracked."
done
echo "Run './dev/build_and_test generate' and commit the changes."
exit 1
fi
echo "Success ✅"