Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Make check-contrib rebuild and reapply tools #11670

Merged
merged 13 commits into from
Nov 21, 2024

Conversation

jade-guiton-dd
Copy link
Contributor

@jade-guiton-dd jade-guiton-dd commented Nov 13, 2024

Description

There have been issues where changes in mdatagen are not properly tested in CI and end up breaking collector-contrib (cf. #11167). This is because make check-contrib does not rebuild or rerun mdatagen before running contrib tests. This PR fixes that.

I added a flag to disable this when running manually, as it adds significant time (~3 min!) to the run and is only really useful when mdatagen has been modified.

I had to change the make gotidy to make for-all CMD="go mod tidy" because we don't have a way to run generate on a specific module group (and doing so may cause false-positives/negatives if a module group depends on the generated files of another).

Link to tracking issue

Fixes #11167

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.63%. Comparing base (8e522ad) to head (a5fb33c).
Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11670      +/-   ##
==========================================
+ Coverage   91.54%   91.63%   +0.09%     
==========================================
  Files         442      442              
  Lines       23792    23776      -16     
==========================================
+ Hits        21780    21787       +7     
+ Misses       1641     1618      -23     
  Partials      371      371              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@mx-psi mx-psi self-requested a review November 14, 2024 00:23
@jade-guiton-dd jade-guiton-dd changed the title Make check-contrib rebuild and reapply tools [chore] Make check-contrib rebuild and reapply tools Nov 14, 2024
@jade-guiton-dd
Copy link
Contributor Author

jade-guiton-dd commented Nov 14, 2024

So this works (I think), but it increases the duration of the "check contribs" job from about 10 min to about 13 min. This increase is mostly for two reasons:

  1. We're doing more stuff (rebuilding tools and recreating generated files). Is there a way to only run that part in cases where we modify mdatagen?
  2. For technical reasons (no way in the current contrib Makefile to run the go generate command only for a single group of modules), we're also go mod tidying all modules instead of just the current group. This could be fixed by adding a new command to the contrib Makefile. Do we want to bother with that? It may not be worth it if we manage to fix point 1.

(Note: The failure in build-and-test / checks is unrelated; it's because the CI just switched to the latest minor version of Go (1.22.9), and it's complaining that otelcol has a toolchain value of 1.22.8)

@mx-psi
Copy link
Member

mx-psi commented Nov 14, 2024

I also modified the go mod edit -replace and -dropreplace commands to use an automatically generated list of modules. This will prevent these lists from getting out of date. (For reference, we currently only replace 70 modules out of the 72 in versions.yaml, and only -dropreplace 63 out of those.)

@jade-guiton-dd This sounds great and we can probably land this change independently. Would you mind splitting this into a separate PR?

mx-psi pushed a commit that referenced this pull request Nov 15, 2024
#11683)

#### Description

`make check-contrib` use `go mod edit` to allow running the
`opentelemetry-collector-contrib` unit tests against the local version
of the core libraries. It also removes the `replace` statements after
tests have been run. At the moment, this is done with two long
handwritten `go mod edit` commands. But this very easily gets
out-of-date: for reference, we currently only `-replace` 70 modules out
of the 73 in versions.yaml, and only `-dropreplace` 63 out of _those_.

This PR changes the `Makefile` to programatically generate the commands,
to avoid needing to keep them up to date.

This was split off from PR #11670.

You can check the output in the `contrib-tests` CI job output.
@mx-psi
Copy link
Member

mx-psi commented Nov 15, 2024

Merged #11683 :)

bogdandrutu pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Nov 19, 2024
#### 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.)
@jade-guiton-dd jade-guiton-dd marked this pull request as ready for review November 20, 2024 11:28
@jade-guiton-dd jade-guiton-dd requested a review from a team as a code owner November 20, 2024 11:28
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
@mx-psi mx-psi merged commit c9f8e8b into open-telemetry:main Nov 21, 2024
49 checks passed
@github-actions github-actions bot added this to the next release milestone Nov 21, 2024
djaglowski pushed a commit to djaglowski/opentelemetry-collector that referenced this pull request Nov 21, 2024
open-telemetry#11683)

#### Description

`make check-contrib` use `go mod edit` to allow running the
`opentelemetry-collector-contrib` unit tests against the local version
of the core libraries. It also removes the `replace` statements after
tests have been run. At the moment, this is done with two long
handwritten `go mod edit` commands. But this very easily gets
out-of-date: for reference, we currently only `-replace` 70 modules out
of the 73 in versions.yaml, and only `-dropreplace` 63 out of _those_.

This PR changes the `Makefile` to programatically generate the commands,
to avoid needing to keep them up to date.

This was split off from PR open-telemetry#11670.

You can check the output in the `contrib-tests` CI job output.
djaglowski pushed a commit to djaglowski/opentelemetry-collector that referenced this pull request Nov 21, 2024
…y#11670)

#### Description

There have been issues where changes in `mdatagen` are not properly
tested in CI and end up breaking collector-contrib (cf. open-telemetry#11167). This is
because `make check-contrib` does not rebuild or rerun `mdatagen` before
running contrib tests. This PR fixes that.

I added a flag to disable this when running manually, as it adds
significant time (~3 min!) to the run and is only really useful when
`mdatagen` has been modified.

I had to change the `make gotidy` to `make for-all CMD="go mod tidy"`
because we don't have a way to run `generate` on a specific module group
(and doing so may cause false-positives/negatives if a module group
depends on the generated files of another).

#### Link to tracking issue
Fixes open-telemetry#11167
@jade-guiton-dd jade-guiton-dd deleted the better-check-contrib branch November 27, 2024 13:36
codeboten added a commit to codeboten/opentelemetry-collector that referenced this pull request Dec 3, 2024
This is a partial revert of open-telemetry#11670 as it is
currently blocking the release due to the need to run go mod tidy multiple times.

I'm still investigating why tidy is needed multiple times, but for now I'm disabling
the generate step, which was not run before and is currently blocking the
release process

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
codeboten added a commit that referenced this pull request Dec 3, 2024
This is a partial revert of
#11670 as
it is currently blocking the release due to the need to run go mod tidy
multiple times.

I'm still investigating why tidy is needed multiple times, but for now
I'm disabling the generate step, which was not run before and is
currently blocking the release process

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this pull request Dec 17, 2024
#### 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.)
HongChenTW pushed a commit to HongChenTW/opentelemetry-collector that referenced this pull request Dec 19, 2024
open-telemetry#11683)

#### Description

`make check-contrib` use `go mod edit` to allow running the
`opentelemetry-collector-contrib` unit tests against the local version
of the core libraries. It also removes the `replace` statements after
tests have been run. At the moment, this is done with two long
handwritten `go mod edit` commands. But this very easily gets
out-of-date: for reference, we currently only `-replace` 70 modules out
of the 73 in versions.yaml, and only `-dropreplace` 63 out of _those_.

This PR changes the `Makefile` to programatically generate the commands,
to avoid needing to keep them up to date.

This was split off from PR open-telemetry#11670.

You can check the output in the `contrib-tests` CI job output.
HongChenTW pushed a commit to HongChenTW/opentelemetry-collector that referenced this pull request Dec 19, 2024
…y#11670)

#### Description

There have been issues where changes in `mdatagen` are not properly
tested in CI and end up breaking collector-contrib (cf. open-telemetry#11167). This is
because `make check-contrib` does not rebuild or rerun `mdatagen` before
running contrib tests. This PR fixes that.

I added a flag to disable this when running manually, as it adds
significant time (~3 min!) to the run and is only really useful when
`mdatagen` has been modified.

I had to change the `make gotidy` to `make for-all CMD="go mod tidy"`
because we don't have a way to run `generate` on a specific module group
(and doing so may cause false-positives/negatives if a module group
depends on the generated files of another).

#### Link to tracking issue
Fixes open-telemetry#11167
HongChenTW pushed a commit to HongChenTW/opentelemetry-collector that referenced this pull request Dec 19, 2024
This is a partial revert of
open-telemetry#11670 as
it is currently blocking the release due to the need to run go mod tidy
multiple times.

I'm still investigating why tidy is needed multiple times, but for now
I'm disabling the generate step, which was not run before and is
currently blocking the release process

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
AkhigbeEromo pushed a commit to sematext/opentelemetry-collector-contrib that referenced this pull request Jan 13, 2025
#### 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.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI] Contrib tests should also test updated mdatagen
2 participants