Skip to content

Commit

Permalink
Test Protobuild with multiple protoc-gen-go versions
Browse files Browse the repository at this point in the history
This change extends GitHub Actions to test Protobuild against
multiple protoc-gen-go versions.

Signed-off-by: Kazuyoshi Kato <[email protected]>
  • Loading branch information
kzys committed Oct 21, 2021
1 parent a405183 commit 3b9c4c7
Show file tree
Hide file tree
Showing 8 changed files with 475 additions and 11 deletions.
93 changes: 83 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,40 @@ on:
branches: [ main ]

jobs:
test:
name: Test
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: src/github.com/containerd/protobuild
fetch-depth: 25

- name: Project checks
uses: containerd/project-checks@v1
with:
working-directory: src/github.com/containerd/protobuild

- name: Setup environment
shell: bash
run: |
echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
- name: Check out code
uses: actions/checkout@v2
with:
path: src/github.com/containerd/protobuild

- name: Test
working-directory: src/github.com/containerd/protobuild
run: |
go test
build:
name: Protobuild CI
v1:
name: Run with protoc-gen-go v1.3.5
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
Expand All @@ -30,12 +61,6 @@ jobs:
uses: actions/checkout@v2
with:
path: src/github.com/containerd/protobuild
fetch-depth: 25

- name: Project checks
uses: containerd/project-checks@v1
with:
working-directory: src/github.com/containerd/protobuild

- name: Build
working-directory: src/github.com/containerd/protobuild
Expand All @@ -58,7 +83,55 @@ jobs:
- name: Run protobuild to see all committed auto-generated files can be generated as is
working-directory: src/github.com/containerd/protobuild
run: |
find examples/ -name '*.pb.*' | xargs rm
rm examples/foo/*.pb.* examples/bar/*.pb.* examples/nogrpc/*.pb.*
export PATH=$(go env GOBIN):$PATH
./protobuild github.com/containerd/protobuild/examples/bar github.com/containerd/protobuild/examples/foo github.com/containerd/protobuild/examples/nogrpc
git diff --exit-code
v2:
name: Run with protoc-gen-go v1.26
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
id: go

- name: Setup environment
shell: bash
run: |
echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
- name: Check out code
uses: actions/checkout@v2
with:
path: src/github.com/containerd/protobuild

- name: Build
working-directory: src/github.com/containerd/protobuild
run: |
go build .
- name: Install protoc
run: |
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.18.1/protoc-3.18.1-linux-x86_64.zip
sudo unzip -x protoc-3.18.1-linux-x86_64.zip -d /usr/local
sudo chmod -R go+rX /usr/local/include
sudo chmod go+x /usr/local/bin/protoc
- name: Install protoc-gen-go and protoc-gen-go-grpc
run: |
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
- name: Run protobuild to see all committed auto-generated files can be generated as is
working-directory: src/github.com/containerd/protobuild
run: |
rm examples/v2/*.pb.*
export PATH=$(go env GOBIN):$PATH
go list ./... | grep -v vendor | xargs ./protobuild
./protobuild -f v2.toml github.com/containerd/protobuild/examples/v2
git diff --exit-code
21 changes: 21 additions & 0 deletions examples/v2/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright The containerd Authors.
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.
*/

// Package foo demonstrates a protobuf package.
//
// We include a doc.go file in here to let protobuild know to place a
// Go/Protobuf package.
package v2
165 changes: 165 additions & 0 deletions examples/v2/foo.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions examples/v2/foo.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";

package protobuild.example.v2;

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/containerd/protobuild/examples/v2/;v2";

service Foo {
rpc Do(DoRequest) returns (google.protobuf.Empty);
}

message DoRequest {
google.protobuf.Timestamp timestamp = 3;
}
Loading

0 comments on commit 3b9c4c7

Please sign in to comment.