Skip to content

Commit

Permalink
Add instructions for using docker to regen derived files (#3489)
Browse files Browse the repository at this point in the history
This is much cleaner than the previous approach of requiring protoc to be installed globally on the machine, which inevitably causes tensions with other projects that are developed on the same machine. We may want to consider building and publishing the Docker image in a repository so that people can just pull it and use it unless they are upgrading any of the tool versions (e.g. protoc).

The changes to the `batchmap` code are the results of regenerating all files using these new instructions.
  • Loading branch information
mhutchinson authored May 9, 2024
1 parent 6b4eb18 commit 05f1f7f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 33 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,21 @@ Some of the Trillian Go code is autogenerated from other files:
golang.org/x/tools/cmd/stringer`).

Re-generating mock or protobuffer files is only needed if you're changing
the original files; if you do, you'll need to install the prerequisites:
the original files. The recommended way to do this is by using the Docker
image used by the Cloud Build:

```shell
docker build -f ./integration/cloudbuild/testbase/Dockerfile -t trillian-builder .
docker run -it --mount type=bind,src="$(pwd)",target=/src trillian-builder /bin/bash -c "cd /src; ./scripts/install_deps.sh; go generate -x ./..."
```

These commands first create a docker image from the Dockerfile in this repo, and
then launch a container based on this image with the local directory mounted. The
correct versions of the tools are determined using the `go.mod` file in this repo,
and these tools are installed. Finally, all of the generated files are regenerated
and Docker exits.

Alternatively, you can install the prerequisites locally:

- a series of tools, using `go install` to ensure that the versions are
compatible and tested:
Expand Down
64 changes: 32 additions & 32 deletions experimental/batchmap/batchmap.shims.go

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

15 changes: 15 additions & 0 deletions scripts/install_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#
# Installs the dependencies required to build this repo.
set -eu

main() {
go install github.com/golang/mock/mockgen
go install google.golang.org/protobuf/proto
go install google.golang.org/protobuf/cmd/protoc-gen-go
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
go install golang.org/x/tools/cmd/stringer
}

main

0 comments on commit 05f1f7f

Please sign in to comment.