-
Notifications
You must be signed in to change notification settings - Fork 47
227 lines (226 loc) · 7.81 KB
/
ci.yaml
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
---
name: Showcase CI
on:
push:
branches:
- main
pull_request:
jobs:
regenerate:
runs-on: ubuntu-latest
outputs:
modified_files: ${{ steps.mod.outputs.modified_files }}
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Install Protoc
uses: arduino/setup-protoc@v1
- name: Install external generators
run: |
go install github.com/golang/protobuf/protoc-gen-go@latest
go install github.com/googleapis/gapic-generator-go/cmd/protoc-gen-go_cli@latest
go install github.com/googleapis/gapic-generator-go/cmd/protoc-gen-go_gapic@latest
- uses: actions/checkout@v4
- name: Checkout common protos
run: git submodule init && git submodule update
- name: Download go deps
run: go mod download
- name: Install REST server generator
run: go install ./util/cmd/protoc-gen-go_rest_server
- name: Regenerate sources
run: go run ./util/cmd/compile_protos
- name: Capture modified files
id: mod
run: |
files=$(git ls-files --deleted --modified --other --directory --exclude-standard cmd client server/genproto server/genrest)
echo ::set-output name=modified_files::$files
- name: Prepare regenerated sources
if: steps.mod.outputs.modified_files
run: tar czf regen.tgz ${{ steps.mod.outputs.modified_files }}
- uses: actions/upload-artifact@v4
if: steps.mod.outputs.modified_files
with:
name: regenerated-sources
path: regen.tgz
lint:
needs: regenerate
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Install golint
run: go install golang.org/x/lint/golint@latest
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
if: needs.regenerate.outputs.modified_files
with:
name: regenerated-sources
- name: Expand regen archive
if: needs.regenerate.outputs.modified_files
run: |
tar xvzf regen.tgz
rm regen.tgz
- name: Check formatting
run: gofmt -l ./server/services > gofmt.txt && ! [ -s gofmt.txt ]
if: ${{ always() }}
- name: Lint service implementations
run: golint ./server/services >> golint.txt && ! [ -s golint.txt ]
if: ${{ always() }}
- name: Vet service implementations
# The mod download is there to prevent go vet from logging mod downloads
# which would mess up the empty vetting results check.
run: go mod download && go vet ./server/services 2> govet.txt && ! [ -s govet.txt ]
if: ${{ always() }}
- uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: linting-results
path: |
gofmt.txt
golint.txt
govet.txt
tests:
needs: regenerate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- uses: actions/download-artifact@v4
if: needs.regenerate.outputs.modified_files
with:
name: regenerated-sources
- name: Expand regen archive
if: needs.regenerate.outputs.modified_files
run: |
tar xvzf regen.tgz
rm regen.tgz
- name: Run mod tidy
run: go mod tidy
- name: Run unit tests
run: go test ./...
- name: Run server coverage
run: go test ./server/... -coverprofile=coverage.txt -covermode=atomic
probes:
needs: regenerate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- uses: actions/download-artifact@v4
if: needs.regenerate.outputs.modified_files
with:
name: regenerated-sources
- name: Expand regen archive
if: needs.regenerate.outputs.modified_files
run: |
tar xvzf regen.tgz
rm regen.tgz
- name: Run mod tidy
run: go mod tidy
- name: Install gapic-showcase CLI
run: go install ./cmd/gapic-showcase
- name: Probe gRPC and REST servers
run: |
gapic-showcase run &
gapic-showcase echo echo --response content --response.content "hello!"
GRPC_EXIT_CODE=$?
STATUSCODE=$(curl --silent --output /dev/null --write-out "%{http_code}" http://localhost:7469/hello)
echo "gRPC exit code: $GRPC_EXIT_CODE"
echo "REST status code: $STATUSCODE"
[ $STATUSCODE = "200" ] && [ GRPC_EXIT_CODE != 0 ]
# Disabled until https://github.com/googleapis/gapic-generator-typescript/pull/955 is merged/released.
# typescript-smoke-test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v2
# with:
# node-version: '12'
# - name: Run gapic-generator-typescript
# run: |
# mkdir tsout
# docker run --rm --user $UID \
# --mount type=bind,source="$(pwd)"/schema,destination=/in/protos/google/showcase/v1beta1,readonly \
# --mount type=bind,source="$(pwd)"/tsout,destination=/out/ \
# gcr.io/gapic-images/gapic-generator-typescript:latest
# - name: Run auto-generated tests
# run: |
# cd tsout
# npm install
# npm test
# npm run system-test
protobufjs-load-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '12'
- name: Install protobuf loader
run: npm install google-proto-files
- name: Verify protos can be loaded by protobufjs
run: |
node -e "require('google-proto-files').loadSync('schema/google/showcase/v1beta1/echo.proto');"
node -e "require('google-proto-files').loadSync('schema/google/showcase/v1beta1/identity.proto');"
node -e "require('google-proto-files').loadSync('schema/google/showcase/v1beta1/messaging.proto');"
node -e "require('google-proto-files').loadSync('schema/google/showcase/v1beta1/testing.proto');"
node -e "require('google-proto-files').loadSync('schema/google/showcase/v1beta1/compliance.proto');"
node -e "require('google-proto-files').loadSync('schema/google/showcase/v1beta1/sequence.proto');"
push-generated-sources:
needs: [regenerate, lint, tests, probes]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && needs.regenerate.outputs.modified_files
steps:
- uses: actions/checkout@v4
with:
ref: main
- uses: actions/download-artifact@v4
with:
name: regenerated-sources
- name: Expand regen archive
run: |
tar xvzf regen.tgz
rm regen.tgz
- uses: googleapis/code-suggester@v4
env:
ACCESS_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
with:
command: pr
upstream_owner: googleapis
upstream_repo: gapic-showcase
description: 'Regenerated sources resulting from most recent commit to main'
title: 'chore: regenerate sources'
message: 'chore: regenerate sources'
primary: 'main'
branch: regen
git_dir: '.'
force: true
- name: Add automerge label to pull request
uses: actions/github-script@v7
with:
script: |
github.rest.issues.addLabels({
issue_number: ${{ steps.code_suggester.outputs.pull }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['automerge']
})
bazel_build_protos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bazel-contrib/[email protected]
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
- run: bazelisk build //schema/google/showcase/v1beta1:showcase_proto