Skip to content

Commit

Permalink
[chore] make generate uses .tools/mdatagen (#36416)
Browse files Browse the repository at this point in the history
#### Description

This PR is in the context of [this PR on the core Collector modifying
`make check-contrib` to use the latest version of
`mdatagen`](open-telemetry/opentelemetry-collector#11670).

The `make generate` commands currently starts by compiling build tools
in the `.tools` folder, then it `go install`s mdatagen globally for use
in `go:generate`. Unfortunately, `go install` does not take into account
the version of `mdatagen` referenced in `internal/tools/go.mod`. This
means it isn't possible to generate using the local version of
`mdatagen` for testing, even with `replace` statements.

This PR fixes this by prepending `.tools` to the `$PATH` before running
the generate command, which makes `go:generate` use the version of
`mdatagen` in that folder instead of a global one.

(Originally, this PR also added a new `modgenerate` target in
`Makefile.Common`, to allow running generate commands on a specific
group of modules instead of all of them for efficiency reasons. After
discussing it with @mx-psi, we decided to hold off on that change for a
later PR, as it warrants further discussion.)
  • Loading branch information
jade-guiton-dd authored Nov 19, 2024
1 parent 4e8dbb5 commit 3f4e13f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ docker-telemetrygen:

.PHONY: generate
generate: install-tools
cd ./internal/tools && go install go.opentelemetry.io/collector/cmd/mdatagen
$(MAKE) for-all CMD="$(GOCMD) generate ./..."
PATH="$$PWD/.tools:$$PATH" $(MAKE) for-all CMD="$(GOCMD) generate ./..."
$(MAKE) gofmt

.PHONY: githubgen-install
Expand Down

0 comments on commit 3f4e13f

Please sign in to comment.