Skip to content

Commit

Permalink
Bump google.golang.org/protobuf from 1.30.0 to 1.31.0 (#157)
Browse files Browse the repository at this point in the history
Also updates version of protoc from v22 to v23, to match the contents of the google.golang.org/protobuf/types/descriptorpb.

This updates all handling regarding protoc versions to use a single configuration
file in the root: `.protoc_version`. Previously, the version was hard-coded in
four separate places. So now it only needs to be changed in one place.
  • Loading branch information
dependabot[bot] authored Jun 30, 2023
1 parent 730f77b commit 6a86e60
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 22 deletions.
1 change: 1 addition & 0 deletions .protoc_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
23.0
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ TOOLS_MOD_DIR := ./internal/tools
UNAME_OS := $(shell uname -s)
UNAME_ARCH := $(shell uname -m)

# NB: this must be kept in sync with constant in internal/benchmarks.
PROTOC_VERSION ?= 22.0
PROTOC_VERSION := $(shell cat ./.protoc_version)
PROTOC_DIR := $(abspath ./internal/testdata/protoc/$(PROTOC_VERSION))
PROTOC := $(PROTOC_DIR)/bin/protoc

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/google/go-cmp v0.5.9
github.com/stretchr/testify v1.8.4
golang.org/x/sync v0.3.0
google.golang.org/protobuf v1.30.0
google.golang.org/protobuf v1.31.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
26 changes: 20 additions & 6 deletions internal/benchmarks/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,23 @@ import (
)

const (
// NB: this must be kept in sync with PROTOC_VERSION in Makefile.
protocVersion = "22.0"

googleapisCommit = "cb6fbe8784479b22af38c09a5039d8983e894566"
)

var (
protocPath = fmt.Sprintf("../testdata/protoc/%s/bin/protoc", protocVersion)
protocPath string

googleapisURI = fmt.Sprintf("https://github.com/googleapis/googleapis/archive/%s.tar.gz", googleapisCommit)
googleapisDir string
googleapisSources []string
)

func TestMain(m *testing.M) {
if runtime.GOOS == "windows" {
protocPath += ".exe"
var err error
protocPath, err = getProtocPath()
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Failed to compute protoc path: %v\n", err)
os.Exit(1)
}
if info, err := os.Stat(protocPath); err != nil {
if errors.Is(err, fs.ErrNotExist) {
Expand Down Expand Up @@ -128,6 +129,19 @@ func TestMain(m *testing.M) {
stat = m.Run()
}

func getProtocPath() (string, error) {
data, err := os.ReadFile("../../.protoc_version")
if err != nil {
return "", err
}
version := strings.TrimSpace(string(data))
protocPath := fmt.Sprintf("../testdata/protoc/%s/bin/protoc", version)
if runtime.GOOS == "windows" {
protocPath += ".exe"
}
return protocPath, nil
}

func downloadAndExpand(url, targetDir string) (e error) {
start := time.Now()
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, url, nil)
Expand Down
2 changes: 1 addition & 1 deletion internal/benchmarks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/igrmk/treemap/v2 v2.0.1
github.com/jhump/protoreflect v1.14.1 // MUST NOT be updated to v1.15 or higher
github.com/stretchr/testify v1.8.4
google.golang.org/protobuf v1.30.0
google.golang.org/protobuf v1.31.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions internal/benchmarks/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
Binary file modified internal/testdata/all.protoset
Binary file not shown.
Binary file modified internal/testdata/desc_test_complex.protoset
Binary file not shown.
Binary file modified internal/testdata/desc_test_proto3_optional.protoset
Binary file not shown.
Binary file modified internal/testdata/descriptor_impl_tests.protoset
Binary file not shown.
Binary file modified internal/testdata/source_info.protoset
Binary file not shown.
28 changes: 21 additions & 7 deletions linker/linker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2552,14 +2552,15 @@ func TestCustomJSONNameWarnings(t *testing.T) {
}
}
// TODO: Need to run these test cases against protoc like other test
// cases in this file. As of writing, the most recent version (v22.0)
// of protoc produces too many different result with protocompile. So
// cases in this file. As of writing, the most recent version of
// protoc produces too many different result with protocompile. So
// we are focusing on other test cases first before protoc is fixed.
}

// testByProtoc tests the proto files with protoc. The fileNames parameter indicates the order of file
// that should be used in the command line for protoc. fileNames can be nil when the order does not matter.
func testByProtoc(t *testing.T, files map[string]string, fileNames []string) (passed bool, err error) {
t.Helper()
if len(fileNames) != 0 {
require.True(t, len(files) == len(fileNames))
for _, fileName := range fileNames {
Expand All @@ -2569,7 +2570,10 @@ func testByProtoc(t *testing.T, files map[string]string, fileNames []string) (pa
}

tempDir := writeFileToDisk(t, files)
defer os.RemoveAll(tempDir)
defer func() {
err := os.RemoveAll(tempDir)
require.NoError(t, err)
}()
if len(fileNames) == 0 {
fileNames = make([]string, 0, len(files))
for fileName := range files {
Expand Down Expand Up @@ -2599,7 +2603,11 @@ func writeFileToDisk(t *testing.T, files map[string]string) string {
func compileByProtoc(t *testing.T, protoPath string, fileNames []string) (passed bool, err error) {
args := []string{"-I", protoPath, "-o", os.DevNull}
args = append(args, fileNames...)
cmd := exec.Command(getProtocPath(), args...)
protocPath, err := getProtocPath()
if err != nil {
return false, err
}
cmd := exec.Command(protocPath, args...)
stdout, err := cmd.Output()
if err == nil {
return true, nil
Expand All @@ -2612,9 +2620,15 @@ func compileByProtoc(t *testing.T, protoPath string, fileNames []string) (passed
return false, err
}

func getProtocPath() string {
func getProtocPath() (string, error) {
// TODO: unify with similar logic in benchmarks
if runtime.GOOS == "windows" {
return "protoc"
return "protoc", nil
}
data, err := os.ReadFile("../.protoc_version")
if err != nil {
return "", err
}
return "../internal/testdata/protoc/22.0/bin/protoc"
version := strings.TrimSpace(string(data))
return fmt.Sprintf("../internal/testdata/protoc/%s/bin/protoc", version), nil
}
2 changes: 1 addition & 1 deletion windows/test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eo pipefail

PROTOC_VERSION="22.0"
PROTOC_VERSION="$(cat $(dirname "$0")/../.protoc_version)"
PROTOC_GEN_GO_VERSION="v1.28.2-0.20220831092852-f930b1dc76e8"
CONNECT_VERSION="v1.5.2"

Expand Down

0 comments on commit 6a86e60

Please sign in to comment.