Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add note to README on responsible CI usage. #765

Closed
wants to merge 644 commits into from

Conversation

edwarnicke
Copy link

This is in the hopes of easing folks hitting #763 in getting
to a proper use of CI.

dsymonds and others added 30 commits March 9, 2016 13:16
such as using append where it makes the code shorter and more natural.
It has almost zero impact on performance in practice,
and permits this code to keep working with Go 1.4.

Fixes golang#146.
Signed-off-by: David Symonds <dsymonds@golang.org>
Clarify the unsupported nature of this interface in the README.

Fixes golang#147.
Signed-off-by: David Symonds <dsymonds@golang.org>
Like App Engine, GopherJS does not support unsafe.
This change adds a 'js' build tag (set by GopherJS)
alongside the existing 'appengine' tags.

Fixes golang#154.
…required field.

Signed-off-by: David Symonds <dsymonds@golang.org>
Enums used in maps is still broken, but commented-out test data
is now there, together with TODOs.

Fixes golang#164.
…ion.

See grpc/grpc-go#642 for the corresponding grpc-go change.

Signed-off-by: David Symonds <dsymonds@golang.org>
Signed-off-by: David Symonds <dsymonds@golang.org>
Unmarshaling Any is a TODO.

Fixes golang#170.
Methods that manipulate protos with extensions will now take
proto.Message instead of the internal extendableProto interface.

A ClearExtensions method is added to clear all extensions on protos.
While this check could be done before marshalling, it shouldn't occur
frequently and thus would slow down proto encoding on average.
Turn generated message struct field XXX_Extensions map[int32]Extension
into an embedded proto.InternalExtensions  struct

InternalExtensions is a struct without any exported fields and methods.
This effectively makes the representation of the extension map private.
The proto package can access InternalExtensions by checking that the
generated struct has the method 'extmap() proto.InternalExtensions'.

Also lock accesses to the extension map.

This change bumps the Go protobuf generated code version number. Any
.pb.go files generated with this version of the proto package or later
will require this version or later of the proto package to compile.
When the new V2 generated extension format was introduced, we
mistakenly dropped support for comparing V1 generated extensions
for equality. Add that back.
This is meant to fix golang#188. There
are no tests because we don't guarantee that we're going to maintain
this behavior in the future.

Fixes golang#188
Otherwise invalid JSON can be produced.
Bump support package version number from 2 to 3.
Add tests for merging a map field. When src contains a duplicate key,
its value message replaces (not merges with) the value message in dst.
// GetAllExtensionDescs returns a slice of all the descriptors
// extensions present in pb.
// // If an extension is not registered, a descriptor with only the
// 'field' value set will
// // be returned instead of a full descriptor.
// // The returned slice is not guaranteed to be in any given order.
// func GetAllExtensionDescs(pb Message) (extensions []*ExtensionDesc,
// err error)
A test depends on the new 'Cute' field.
sesmith177 and others added 18 commits October 3, 2018 12:35
Don't generate identifiers that conflict with predeclared identifiers,
prepend with "_" instead.

Signed-off-by: Arjun Sreedharan <asreedharan@pivotal.io>
…names (golang#724)

Permit creating a generated package named e.g., "string". Apply disambiguation
to prevent creating a local import name that conflicts with predefined
identifiers; importing package "string" will be done as:

    import string1 "string"
Avoid turning comments like "//////" into "// ////".
Parse floating-point default values and format them with fmt.Sprint.
Eliminates a minor point of inconsistency with the v2 generator.
Convert all the import_public protos to proto2 to allow testing more
features.

Add usage of groups, extensions, and default values.
Groups were being excluded from the set of messages we generate
forwarding declarations for. Include them.
Test the following case:

File 1 defines a symbol S.
File 2 publicly imports file 1.
File 3 imports file 2 and uses S.

All files in different Go packages: P1, P2, P3.

Note that the .pb.go for file 3 could import P1 or P2, since the symbol
is defined in both.
Consider this case:

File 1 defines M.
File 2 publicly imports file 1.
File 3 imports file 2, and references M.

Each file is in a different Go package: P1, P2, P3.

Should the generated Go code for file 3 reference P1.M, or P2.M?
The two should be equivalent, since file 2 will contain a forwarding
declaration such as "type M = P1.M".

Historically, we've gone with the latter (P2.M). This does make sense:
A generated file only imports the packages of the files that it directly
imports.

However, this does have some mildly surprising effects. If File 3
imports files 2a and 2b, each of which publicly imports file 1, we need
to arbitrarily pick one of P2a.M or P2b.M. (Admittedly an obscure case.)

Simplify the generator a little bit (and, more importantly, make it
consistent with the v2 generator) and change to referencing public
imports directly.
Despite the naming, these are "internal-only" functions that are intended to
only be called from generated code for MessageSets.
Furthermore, MessageSets are themselves a deprecated feature from proto1 days,
such that descriptor.proto even warns against their use since the initial
open-source release of protocol buffers in 2008. Within Google,
there are no direct usages of these functions, and all existing
usages of MessageSets go through the new table-driven implementation.

In addition to deprecating the {Unm,M}arshalMessageSet{JSON} top-level functions,
also modify the generator to stop emitting MarshalJSON and UnmarshalJSON methods
for messages sets. The UnmarshalJSON method is not implemented and the
MarshalJSON method does not seem to be called anywhere in Google (verified by
making the method panic and doing a global test). The jsonpb package continues
to work with MessageSets.

I should note that when the table-driven implementation was open sourced
in late 2017 (see 8cc9e46), it accidentally
removed generation of the Marshal and Unmarshal method. However, no one seemed
to have noticed that those methods were no longer generated.
…g#746)

The current API represents scalar extension fields as *T and
repeated extension fields as []T.
However, this is not an accurate reflection of the protobuf data model.

For scalars, pointers are usually used to represent nullability. However,
in the case of extension scalars, there is no need to do so since presence
information is captured by checking whether the field is in the extension map.
For this reason, presence on extension scalars is not determined by checking
whether the returned pointer is nil, but whether HasExtension reports true.

For repeated fields, using []T means that the returned value is only a partially
mutable value. You can swap out elements, but you cannot change the length of
the original field value. On the other hand, the reflective API provides methods
on repeated field values that permit operations that do change the length.
Thus, using *[]T is a closer match to the protobuf data model.

This CL changes the implementation of extension fields to always store T
for scalars, and *[]T for repeated fields. However, for backwards compatibility,
the API continues to provide *T and []T. In theory, this could break anyone
that relies on memory aliasing for *T. However, this is unlikely since:
* use of extensions themselves are relatively rare
* if extensions are used, it is recommended practice to use a message as the
field extension and not a scalar
* relying on memory aliasing is generally not a good idiom to follow.
The expected pattern is to call SetExtension to make it explicit that a mutation
is happening on the message.
* analysis within Google demonstrates that no one is relying on this behavior.
Update all proto files that is obtained from the upstream repository to v3.6.1.
…olang#760)

The marshaler, unmarshaler, and sizer functions are unused ever since
the underlying implementation was switched to be table-driven.
Change the function to only return the wrapper structs.

This change:
* enables generated protos to drop dependencies on certain proto types
* reduces the size of generated protos
* simplifies the implementation of oneofs in protoc-gen-go

Updates golang#708
This is in the hopes of easing folks hitting golang#763 in getting
to a proper use of CI.

Signed-off-by: Ed Warnicke <hagbard@gmail.com>
@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

1 similar comment
@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@edwarnicke
Copy link
Author

@sjdweb would something like this in the docs have helped you?

@googlebot
Copy link
Collaborator

CLAs look good, thanks!

1 similar comment
@googlebot
Copy link
Collaborator

CLAs look good, thanks!

@edwarnicke
Copy link
Author

Is CI broken? I'm a little surprised that a readme change broke CI...

Copy link

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicked some typos. I'm just an interested bystander, and while I appreciate the clarity, I wonder if it makes sense to include this. After all, the same applies to any binary used in a build system, protoc-gen-go is not special in any way here. 🤔

CI systems should produce repeatable builds. Installing proto-gen-go via:

```bash
go get go get github.com/golang/protobuf/protoc-gen-go

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one go get too much here


## Using protoc-gen-go in Continuous Integration (CI) Systems

CI systems should produce repeatable builds. Installing proto-gen-go via:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protoc-gen-go (missing c)

go get go get github.com/golang/protobuf/protoc-gen-go
```

within a CI system produces inherently non-reproducible builds, because

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] "reproducible" is a stronger property than repeatable, I'd think. (See this definition, for example, https://reproducible-builds.org/docs/definition/)

This can lead to unexpected build breakage in the CI system.

If you are using vendoring in go, and wish to have a repeatable stable build process,
it is better to install protoc-ge-go in your CI via:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protoc-gen-go (missing n)

@sjdweb
Copy link

sjdweb commented Nov 29, 2018

Would have helped yes, probably in my case including dep instructions (and go modules I assume when it's production ready).

@edwarnicke
Copy link
Author

@srenatus Thanks for the typo checks. I'm not super strongly opinionated about where this goes... but I suspect a lot of folks are about to have this issue due to recent changes in master which cause things to break if you are being cavalier about your CI.

Do you have other suggestions about how to get the word out?

@gopherbot gopherbot closed this Apr 16, 2019
@golang golang locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.