Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] Exclude generated modules from
make for-all
(open-telemetry…
…#37755) #### Context <details> The `Makefile` currently has two variables listing "every" module in the repo: - `ALL_MODS` contains everything except the non-gitted modules `cmd/otelcontribcol` and `cmd/oteltestbedcol`; - `NONROOT_MODS` contains everything except the root module, but including `cmd/otel*col` if present. These variables are mostly used through the following helpers: - `make for-all CMD=blabla` loops through `NONROOT_MODS` + (explicitly) the root module; - `make for-all-target` loops through `ALL_MODS`. The result is that the former includes `cmd/otel*col`, while the latter does not. This discrepancy is confusing, and can cause issues. For instance, the `make check-contrib` task in Core (surprise, this is yet another PR indirectly related to [core#11167](open-telemetry/opentelemetry-collector#11167)) needs to perform the following steps: 1. replace core dependencies in contrib using `make for-all` 2. run `make gotidy`, which uses `make for-all-target` (or used to until my recent PR, but the `tidylist`-based version still excludes the generated modules) 3. run `make generate`, which uses `make for-all` 4. run `make gotest`, which uses `make for-all-target` The discrepancy causes `make generate` to fail because `cmd/otel*col` was modified to replace core dependencies, but not tidied. I don't believe there are many instances where a command needs to be run on all modules, *including* `cmd/otel*col`, so I decided to standardize on `ALL_MODS` in this PR. </details> #### Description This PR removes the `NONROOT_MODS` variable from the `Makefile`, and modifies `make for-all` to use `ALL_MODS` instead. The practical consequence is that `make generate`, `make otel-from-tree`, and `make otel-from-lib` no longer apply to the non-gitted modules `cmd/otelcontribcol` and `cmd/oteltestbedcol`. This matches the existing behavior of all the `make goXXX` targets, reducing discrepancies. I added a new module group `GENERATED_MODS`, which contains the two problematic modules iff they are present on disk. The new `make for-generated` target can be used along with `make for-all` to return to the previous behavior. I don't believe there are any scripts in contrib or core that require this change (since `cmd/otel*col` don't have `//go:generate` statements). I also made some miscellaneous improvements to the Makefile: - removed a definition of `EXPORTER_MODS_0/1` that is overwritten just below - fix the addition of the root module in `ALL_MODS` (currently broken when calling from another directory with `make -C`, see [this StackOverflow answer](https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile)) - updated the output of `make all-groups` with missing groups and macOS-compatible `-e` option I can move these to another PR if it seems too messy to include these here.
- Loading branch information