open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
3.1k stars 2.39k forks source link

[chore] `make generate` uses `.tools/mdatagen` #36416

Closed jade-guiton-dd closed 2 days ago

jade-guiton-dd commented 3 days ago

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.

The make generate commands currently starts by compiling build tools in the .tools folder, then it go installs 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.)

jade-guiton-dd commented 3 days ago

It seems marking the PR as ready for review, then turning into a draft again temporarily caused two people to be assigned, sorry about that.