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

Re-add version code to cmd/builder #11208

Merged
merged 7 commits into from
Sep 24, 2024
Merged

Conversation

jackgopack4
Copy link
Contributor

@jackgopack4 jackgopack4 commented Sep 18, 2024

Revert "[chore] delete code to set a version and date, as it it not used (#10715)"
Remove date string but re-add functions that check for version number
This (mostly) reverts commit b53f57d.

Description

This re-enables the functionality to set a version number for ocb binary (cmd/builder). It was erroneously removed. It also adds unit tests for this functionality, as a warning is given on CI with no code coverage.

Link to tracking issue

Relates to open-telemetry/opentelemetry-collector-releases#664.
Closes #11220 along with open-telemetry/opentelemetry-collector-releases#665

Testing

ran build and release cycles inside personal fork repositories (jackgopack4/opentelemetry-collector and jackgopack4/opentelemetry-collector-releases)

Documentation

.chloggen file

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@d6f568d). Learn more about missing BASE report.
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11208   +/-   ##
=======================================
  Coverage        ?   91.42%           
=======================================
  Files           ?      424           
  Lines           ?    20188           
  Branches        ?        0           
=======================================
  Hits            ?    18456           
  Misses          ?     1348           
  Partials        ?      384           

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

@jackgopack4 jackgopack4 reopened this Sep 19, 2024
@jackgopack4 jackgopack4 marked this pull request as ready for review September 19, 2024 18:09
@jackgopack4 jackgopack4 requested a review from a team as a code owner September 19, 2024 18:09
@bogdandrutu
Copy link
Member

@jackgopack4 who is writing the version though? Am I missing something here?

@jackgopack4
Copy link
Contributor Author

after this code was removed, passing the build flag for version does not properly set the version when someone wants to run ocb version or run ocb and see the output of version before it runs all of its commands.

as I understand it, this function is called by the cobra cli interface when someone runs ocb on the command line.

Comment on lines 41 to 44
version, err = fn(debug.ReadBuildInfo)
if err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the difference just that the debug.ReadBuildInfo() is executed in the Run? If that is the case, can we do just that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, that's not enough to make a difference. running CGO_ENABLED=0 go build -trimpath -ldflags='-s -w -X go.opentelemetry.io/collector/cmd/builder/internal.version=v0.110.0' with this code passes a version number but just moving the debug.ReadBuildInfo into the RunE command does not fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to have a check to see if version is still blank; the init function is overwriting version with debug.ReadBuildInfo otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simply adding an if version == "" check to the init() function originally on line 17 would also solve it, it seems

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok @bogdandrutu I made the PR much smaller and still fixed the issue

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

running CGO_ENABLED=0 go build -trimpath -ldflags='-s -w -X go.opentelemetry.io/collector/cmd/builder/internal.version=v0.110.0'

Where do we do this?

@bogdandrutu bogdandrutu merged commit 9811830 into open-telemetry:main Sep 24, 2024
49 checks passed
@github-actions github-actions bot added this to the next release milestone Sep 24, 2024
HongChenTW pushed a commit to HongChenTW/opentelemetry-collector that referenced this pull request Dec 19, 2024
Revert "[chore] delete code to set a version and date, as it it not used
(open-telemetry#10715)"
Remove date string but re-add functions that check for version number
This (mostly) reverts commit b53f57d.

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
This re-enables the functionality to set a version number for ocb binary
(cmd/builder). It was erroneously removed. It also adds unit tests for
this functionality, as a warning is given on CI with no code coverage.

<!-- Issue number if applicable -->
#### Link to tracking issue
Relates to
open-telemetry/opentelemetry-collector-releases#664.
Closes open-telemetry#11220 along with
open-telemetry/opentelemetry-collector-releases#665

<!--Describe what testing was performed and which tests were added.-->
#### Testing
ran build and release cycles inside personal fork repositories
(jackgopack4/opentelemetry-collector and
jackgopack4/opentelemetry-collector-releases)
<!--Describe the documentation added.-->
#### Documentation
.chloggen file
<!--Please delete paragraphs that you did not use before submitting.-->
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.

OCB v0.107.0 and onward no longer report version on command line
3 participants