Skip to content

Commit 4f72f68

Browse files
committed
Upgrade to 1.24
Remove rotten protoc-gen-doc Upgrade tools version to correspond to those in general codebase. Use new avid-tools Add .gitattributes Add dependabot.yml Install protoc-gen-doc binary in ci workflow Use new go get -tool command to set tools and remove tools.go Use 'go install tool' to install all tools. Move all helper go code into separate directory and copy over when appropriate otherwise installing tools fails with unknown import. AB#10624 Signed-off-by: Paul Hewlett <[email protected]>
1 parent 8ad882c commit 4f72f68

38 files changed

+180
-738
lines changed

.env.tools

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export TOOLS_BUILDNUMBER=20241108.3
1+
export TOOLS_BUILDNUMBER=20250403.6

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/go.sum -diff -merge
2+
**/go.sum linguist-generated=true

.github/dependabot.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# refer: https://github.com/dependabot/dependabot-core/blob/main/.github/dependabot.yml
2+
version: 2
3+
updates:
4+
# Maintain dependencies for GitHub Actions
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
# Check for updates managed by Composer once a week
9+
interval: "weekly"
10+
day: "wednesday"
11+
time: "03:00"
12+
timezone: "Europe/London"
13+
14+
# Maintain dependencies for Golang
15+
- package-ecosystem: "gomod"
16+
directory: "/"
17+
schedule:
18+
# Check for updates managed by Composer once a week
19+
interval: "weekly"
20+
day: "wednesday"
21+
time: "03:00"
22+
timezone: "Europe/London"

.github/workflows/ci.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,40 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13+
1314
- name: Setup go-task
1415
uses: arduino/setup-task@v1
1516
with:
1617
version: 3.x
1718
repo-token: ${{ secrets.GITHUB_TOKEN }}
19+
1820
- name: Setup Go
1921
uses: actions/setup-go@v4
2022
with:
21-
go-version: '1.22.x'
23+
go-version: '1.24.x'
2224
token: ${{ secrets.GITHUB_TOKEN }}
2325
cache-dependency-path: |
2426
datatrails-common-api/go.sum
27+
2528
- name: Setup protobuf
2629
uses: arduino/setup-protoc@v2
2730
with:
2831
version: "24.3"
2932
repo-token: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Setup protoc-gen-doc
35+
run: |
36+
# download protoc-gen-doc as binary
37+
go install github.com/pseudomuto/protoc-gen-doc/cmd/[email protected]
38+
which protoc-gen-doc
39+
3040
- name: Generate, Test and Export
3141
run: |
3242
task all
3343
3444
- name: Show exports
3545
working-directory: exported/
36-
run: find . -type d
46+
run: find . -type f
3747

3848
- name: Publish release artifacts
3949
if: ${{ github.event_name == 'release' }}

README.md

+40-31
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,48 @@
22

33
Common public api definitions for the DataTrails platform
44

5-
## Finding and including proto files for depdendecnies
5+
## Finding and including proto files for dependencies
66

7-
tools/go.mod is the source of truth for all proto providing dependencies. That file alone specifies both the upstream version we are using *and* is used, via go install, to make the .proto files available locally
7+
go.mod is the source of truth for all proto providing dependencies. That file alone specifies both the upstream version we are using *and* is used, via go get -tool, to make the .proto files available locally
88

9-
This corresponds to the practice recommended by grpc-gateway and elsewhere
9+
This corresponds to the practice recommended by grpc-gateway and elsewhere.
1010

11-
1. *** ALWAYS *** Use tools/go.mod to specify the dependency version.
12-
2. Add the package to the `go install` command in the apis:preflight task
13-
3. If necessary, add a var for the new path in any-api **and** then add a reference to that var in the PROTO_INC var.
11+
1. Execute the `go get -tool` command to add the package to the go.mod file. This is a once-off command that simply
12+
sets up go.mod to manages all tools.
13+
2. If necessary, add a var for the new path in any-api **and** then add a reference to that var in the PROTO_INC var.
14+
3. Executing 'go install tool' is then sufficient to install required tools and the only command required in workflows.
1415

15-
Following this practice removes the need for dual maintenance of dependency versions in the builder image. It also produces a build cycle that is significantly faster.
16+
## Using the go tool commands
1617

17-
Cross repository builds in docker while using go.work to refer to locally modified sources don't work. And this setup is essential for an efficient workflow.
18+
These commands are NOT executed as part of the dev workflow.
19+
20+
Add tools to the go.mod file:
21+
22+
```
23+
go get -tool github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
24+
go get -tool github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
25+
go get -tool google.golang.org/protobuf/cmd/[email protected]
26+
go get -tool google.golang.org/grpc/cmd/[email protected]
27+
go get -tool github.com/envoyproxy/[email protected]
28+
```
29+
30+
Inspect the go.mod file and show the 'tool' section:
31+
32+
```
33+
tool (
34+
github.com/envoyproxy/protoc-gen-validate
35+
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway
36+
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
37+
google.golang.org/grpc/cmd/protoc-gen-go-grpc
38+
google.golang.org/protobuf/cmd/protoc-gen-go
39+
)
40+
```
41+
42+
Show installed tools
43+
44+
```
45+
go tool
46+
```
1847

1948
## bootstrap proto files
2049

@@ -24,29 +53,13 @@ For this reason we curl the proto's and make them available in our aggregate pro
2453

2554
## Workflow for updating common apis
2655

27-
### Ensure the go tool chain is setup on your host
56+
### Ensure tools are setup on your host
2857

29-
It is inordinately cumbersome to set this all up for docker. It can't be
30-
achieved without imposing significant inneficiencies in the workflow. For any
31-
engineer working on the api's it is reasonable to expect they can install the
32-
correct version of go for their host, and likely already have.
58+
This repo uses the go-task tool and also the go toolchain. The dev workflow is described below.
3359

34-
### Use an avid/src/go.work
35-
36-
First point avid at a clone of this repo so that it's imports will resolve
37-
directly against the sources in `./api`
38-
39-
### Familiarize with the workflow sub tasks
40-
41-
The general use entry points all use Docker and do not support efficiently and
42-
iteratively developing avid and other dependents against a local clone of this
43-
repo.
4460

4561
#### For this repo
4662

47-
You can do everything in the builder image using `task all`. This uses the
48-
blessed builder image and requires no host setup other than docker.
49-
5063
If you are iterating it is a lot more efficient to use the sub tasks, because they all run on your host.
5164

5265
`task` `apis:bootstrap` -> `task:apis:generate` -> `task:apis:test` -> `task:apis:export`
@@ -68,15 +81,11 @@ If you want to iterate on *just* the helper go code and there tests, do one roun
6881

6982
Then just iterate using `task apis:generate` and `task apis:test`
7083

71-
#### For avid
72-
73-
See the README.md in avid/src/api/README.md
74-
7584
##### Build one api against locally cloned go-datatrails-common-api
7685

7786
The protos can be included exactly as they are found from a clone of go-datatrails-common-api. *Without* needing to generate, build or export. Eg,
7887

7988
task apis:assetsv2-api \
8089
DATATRAILS_COMMON_API="../../go-datatrails-common-api"
8190

82-
It is necessary however to run `task apis:bootsrap` after cloning go-datatrails-common
91+
It is necessary however to run `task apis:bootstrap` after cloning go-datatrails-common-api.

datatrails-common-api/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
marshalers/
12
go.work
3+
*.go
4+
*.json
5+
*.storage

datatrails-common-api/assets/v2/assets/.gitignore

-5
This file was deleted.

datatrails-common-api/attribute/v2/attribute/.gitignore

-5
This file was deleted.

datatrails-common-api/caps/v1/caps/.gitignore

-5
This file was deleted.

datatrails-common-api/filter/v1/filter/.gitignore

-5
This file was deleted.

datatrails-common-api/go.mod

+26-31
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,49 @@ module github.com/datatrails/go-datatrails-common-api-gen
33
// Note: the go code is hosted in github.com/datatrails/go-datatrails-common-api-gen
44
// hence the module name
55

6-
go 1.22
6+
go 1.24
77

88
// This allows this module to operate as tho it were the generated module. This
99
// allows us to manage the proto tool dependencies via this go.mod. This go.mod
1010
// is also used as the go.mod for the generated package.
11-
// replace github.com/datatrails/go-datatrails-common-api-gen => ./
11+
replace github.com/datatrails/go-datatrails-common-api-gen => ./
1212

1313
require (
14-
github.com/datatrails/go-datatrails-common v0.18.1
15-
github.com/envoyproxy/protoc-gen-validate v1.0.4
14+
github.com/datatrails/go-datatrails-common v0.26.0
15+
github.com/envoyproxy/protoc-gen-validate v1.2.1
1616
github.com/google/uuid v1.6.0
17-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
18-
github.com/lyft/protoc-gen-star/v2 v2.0.3
19-
github.com/pseudomuto/protoc-gen-doc v1.5.1
20-
github.com/spf13/afero v1.10.0
21-
github.com/stretchr/testify v1.9.0
22-
go.mongodb.org/mongo-driver v1.12.1
23-
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094
24-
google.golang.org/grpc v1.65.0
25-
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0
26-
google.golang.org/protobuf v1.34.2
27-
gopkg.in/yaml.v3 v3.0.1
17+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0
18+
github.com/stretchr/testify v1.10.0
19+
go.mongodb.org/mongo-driver v1.17.3
20+
google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a
21+
google.golang.org/grpc v1.70.0
22+
google.golang.org/protobuf v1.36.6
2823
)
2924

3025
require (
31-
github.com/Masterminds/goutils v1.1.1 // indirect
32-
github.com/Masterminds/semver v1.5.0 // indirect
33-
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
3426
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
35-
github.com/gogo/protobuf v1.3.2 // indirect
36-
github.com/golang/protobuf v1.5.4 // indirect
37-
github.com/huandu/xstrings v1.4.0 // indirect
3827
github.com/iancoleman/strcase v0.3.0 // indirect
39-
github.com/imdario/mergo v0.3.16 // indirect
40-
github.com/mitchellh/copystructure v1.2.0 // indirect
41-
github.com/mitchellh/reflectwalk v1.0.2 // indirect
42-
github.com/mwitkow/go-proto-validators v0.3.2 // indirect
28+
github.com/lyft/protoc-gen-star/v2 v2.0.4-0.20230330145011-496ad1ac90a4 // indirect
4329
github.com/opentracing/opentracing-go v1.2.0 // indirect
4430
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
45-
github.com/pseudomuto/protokit v0.2.1 // indirect
4631
github.com/rogpeppe/go-internal v1.6.1 // indirect
32+
github.com/spf13/afero v1.10.0 // indirect
4733
go.uber.org/multierr v1.11.0 // indirect
4834
go.uber.org/zap v1.27.0 // indirect
49-
golang.org/x/crypto v0.25.0 // indirect
5035
golang.org/x/mod v0.17.0 // indirect
51-
golang.org/x/net v0.27.0 // indirect
52-
golang.org/x/sys v0.22.0 // indirect
53-
golang.org/x/text v0.16.0 // indirect
36+
golang.org/x/net v0.37.0 // indirect
37+
golang.org/x/sys v0.31.0 // indirect
38+
golang.org/x/text v0.23.0 // indirect
5439
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
55-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
40+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
41+
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 // indirect
42+
gopkg.in/yaml.v3 v3.0.1 // indirect
43+
)
44+
45+
tool (
46+
github.com/envoyproxy/protoc-gen-validate
47+
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway
48+
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
49+
google.golang.org/grpc/cmd/protoc-gen-go-grpc
50+
google.golang.org/protobuf/cmd/protoc-gen-go
5651
)

0 commit comments

Comments
 (0)