Skip to content

Commit 6c3ebca

Browse files
committed
all: update to protobuf 27.0-rc1 and regenerate protos
This change required some changes to the editions default handling code because the descriptor.proto changed upstream [2]. The defaults are no longer one feature set but are split into overridable and not-overridable features which have to be merged. I had to do bootstraping in 4 phases but the results should be correct: 1. generate everything depending on descriptor.proto 2. generate new defaults binary proto 3. adjust all code that works with defaults (*/edition.go files) 4. generate everything else The was required because 1. is a prerequisite for 3. while 2. and 3. are a prerequisite for 4. (2. and 3. can probably be done in parallel). The new release also introduced new conformance tests. The go implementation is not yet conformant and the tests will be fixed in a follow up change because they require changes to the protojson and protoext encoders. [1] protocolbuffers/protobuf@e5502c7 Change-Id: Iddf248f6582a0402ab31256f6e64755d870ed82c Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/582635 Auto-Submit: Lasse Folger <lassefolger@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Nicolas Hillegeer <aktau@google.com>
1 parent 2939520 commit 6c3ebca

17 files changed

Lines changed: 4398 additions & 1696 deletions

File tree

integration_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var (
3434
regenerate = flag.Bool("regenerate", false, "regenerate files")
3535
buildRelease = flag.Bool("buildRelease", false, "build release binaries")
3636

37-
protobufVersion = "26.0-rc2"
37+
protobufVersion = "27.0-rc1"
3838

3939
golangVersions = func() []string {
4040
// Version policy: same version as is in the x/ repos' go.mod.
@@ -500,6 +500,12 @@ func mustHaveCopyrightHeader(t *testing.T, files []string) {
500500
var bad []string
501501
File:
502502
for _, file := range files {
503+
if strings.HasSuffix(file, "internal/testprotos/conformance/editions/test_messages_edition2023.pb.go") {
504+
// TODO(lassefolger) the underlying proto file is checked into
505+
// the protobuf repo without a copyright header. Fix is pending but
506+
// might require a release.
507+
continue
508+
}
503509
b, err := os.ReadFile(file)
504510
if err != nil {
505511
t.Fatal(err)

internal/cmd/generate-protos/main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ func generateEditionsDefaults() {
111111
maxEdition := strings.TrimPrefix(fmt.Sprint(editionssupport.Maximum), "EDITION_")
112112
cmd := exec.Command(
113113
"protoc",
114-
"--experimental_edition_defaults_out", dest,
115-
"--experimental_edition_defaults_minimum", minEdition,
116-
"--experimental_edition_defaults_maximum", maxEdition,
114+
"--edition_defaults_out", dest,
115+
"--edition_defaults_minimum", minEdition,
116+
"--edition_defaults_maximum", maxEdition,
117117
"-I"+filepath.Join(protoRoot, "src"), "-I"+filepath.Join(repoRoot, "src"),
118118
srcDescriptorProto, srcGoFeatures,
119119
)
@@ -230,8 +230,9 @@ func generateRemoteProtos() {
230230
{"", "conformance/conformance.proto", "google.golang.org/protobuf/internal/testprotos/conformance;conformance"},
231231
{"src", "google/protobuf/test_messages_proto2.proto", "google.golang.org/protobuf/internal/testprotos/conformance;conformance"},
232232
{"src", "google/protobuf/test_messages_proto3.proto", "google.golang.org/protobuf/internal/testprotos/conformance;conformance"},
233-
{"src", "google/protobuf/editions/golden/test_messages_proto2_editions.proto", "google.golang.org/protobuf/internal/testprotos/conformance/editions;editions"},
234-
{"src", "google/protobuf/editions/golden/test_messages_proto3_editions.proto", "google.golang.org/protobuf/internal/testprotos/conformance/editions;editions"},
233+
{"src", "editions/golden/test_messages_proto2_editions.proto", "google.golang.org/protobuf/internal/testprotos/conformance/editionsmigration;editions"},
234+
{"src", "editions/golden/test_messages_proto3_editions.proto", "google.golang.org/protobuf/internal/testprotos/conformance/editionsmigration;editions"},
235+
{"", "conformance/test_protos/test_messages_edition2023.proto", "google.golang.org/protobuf/internal/testprotos/conformance/editions;editions"},
235236

236237
// Benchmark protos.
237238
// TODO: The protobuf repo no longer includes benchmarks.
@@ -267,7 +268,7 @@ func generateRemoteProtos() {
267268
}
268269
}
269270
for _, f := range files {
270-
protoc("-I"+filepath.Join(protoRoot, f.prefix), "--go_out="+opts+":"+tmpDir, f.path)
271+
protoc("-I"+protoRoot, "-I"+filepath.Join(protoRoot, f.prefix), "--go_out="+opts+":"+tmpDir, f.path)
271272
}
272273

273274
syncOutput(repoRoot, tmpDir)

internal/conformance/conformance_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package conformance_test
77
import (
88
"encoding/binary"
99
"flag"
10+
"fmt"
1011
"io"
1112
"log"
1213
"os"
@@ -20,6 +21,7 @@ import (
2021

2122
pb "google.golang.org/protobuf/internal/testprotos/conformance"
2223
epb "google.golang.org/protobuf/internal/testprotos/conformance/editions"
24+
empb "google.golang.org/protobuf/internal/testprotos/conformance/editionsmigration"
2325
)
2426

2527
func init() {
@@ -102,10 +104,14 @@ func handle(req *pb.ConformanceRequest) (res *pb.ConformanceResponse) {
102104
msg = &pb.TestAllTypesProto3{}
103105
case "protobuf_test_messages.proto2.TestAllTypesProto2":
104106
msg = &pb.TestAllTypesProto2{}
107+
case "protobuf_test_messages.editions.TestAllTypesEdition2023":
108+
msg = &epb.TestAllTypesEdition2023{}
105109
case "protobuf_test_messages.editions.proto3.TestAllTypesProto3":
106-
msg = &epb.TestAllTypesProto3{}
110+
msg = &empb.TestAllTypesProto3{}
107111
case "protobuf_test_messages.editions.proto2.TestAllTypesProto2":
108-
msg = &epb.TestAllTypesProto2{}
112+
msg = &empb.TestAllTypesProto2{}
113+
default:
114+
panic(fmt.Sprintf("unknown message type: %s", req.GetMessageType()))
109115
}
110116

111117
// Unmarshal the test message.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

internal/conformance/failing_tests_text_format.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@ Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairB
88
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairString
99
Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortBytes
1010
Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortString
11+
Required.Editions.TextFormatInput.DelimitedFieldLowercased.ProtobufOutput
12+
Required.Editions.TextFormatInput.DelimitedFieldLowercased.TextFormatOutput
13+
Required.Editions_Proto2.TextFormatInput.GroupFieldLowercased.ProtobufOutput
14+
Required.Editions_Proto2.TextFormatInput.GroupFieldLowercased.TextFormatOutput
15+
Required.Editions_Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.ProtobufOutput
16+
Required.Editions_Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.TextFormatOutput
17+
Required.Proto2.TextFormatInput.GroupFieldLowercased.ProtobufOutput
18+
Required.Proto2.TextFormatInput.GroupFieldLowercased.TextFormatOutput
19+
Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.ProtobufOutput
20+
Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.TextFormatOutput
15 Bytes
Binary file not shown.

internal/filedesc/editions.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ func unmarshalEditionDefault(b []byte) {
108108
v, m := protowire.ConsumeBytes(b)
109109
b = b[m:]
110110
switch num {
111-
case genid.FeatureSetDefaults_FeatureSetEditionDefault_Features_field_number:
111+
case genid.FeatureSetDefaults_FeatureSetEditionDefault_FixedFeatures_field_number:
112+
fs = unmarshalFeatureSet(v, fs)
113+
case genid.FeatureSetDefaults_FeatureSetEditionDefault_OverridableFeatures_field_number:
112114
fs = unmarshalFeatureSet(v, fs)
113115
}
114116
}

internal/genid/descriptor_gen.go

Lines changed: 40 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)