Skip to content

Conversation

@efd6
Copy link
Contributor

@efd6 efd6 commented Jan 18, 2022

This is a follow up from #648, @mtojek please take a look.

The change bakes in the current version tag during make build if the repo is checked out at a tagged version.

Prior to this a user building elastic-package using make would be given an executable that is unaware of its version. Now make will leave an executable that renders elastic-package version similar to this when the source tree is checked out at a tagged version:

elastic-package v0.42.2 version-hash 3478ac7 (build time: 2022-01-20T09:11:07+4:30

If not at a tagged version, no semver version is output.

@efd6 efd6 requested a review from mtojek January 18, 2022 20:49
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jan 18, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-01-20T20:37:53.229+0000

  • Duration: 24 min 34 sec

  • Commit: aeeb6c4

Test stats 🧪

Test Results
Failed 0
Passed 459
Skipped 0
Total 459

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@mtojek mtojek marked this pull request as ready for review January 19, 2022 13:07
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

@efd6

Could you please add to the PR description, what is the test case the PR fixes?

Makefile Outdated
@@ -1,10 +1,12 @@
CODE_COVERAGE_REPORT_FOLDER = $(PWD)/build/test-coverage
CODE_COVERAGE_REPORT_NAME_UNIT = $(CODE_COVERAGE_REPORT_FOLDER)/coverage-unit-report
VER_PKG = github.com/elastic/elastic-package/internal/version
Copy link
Contributor

@mtojek mtojek Jan 19, 2022

Choose a reason for hiding this comment

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

Let's change it to:VERSION_IMPORT_PATH

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The choice was intentional to reduce line length. It's not far from its use, so the context is still strong. If you would still like me to make that change given this, let me know.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I suggest extending it as VER_PKG might be misleading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not clear to me how, but done.

Copy link
Contributor

Choose a reason for hiding this comment

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

My first guess was PKG_CONFIG as it is a Makefile.

Thanks for adjusting it.

@mtojek mtojek requested a review from a team January 20, 2022 12:12
Makefile Outdated
build:
go get -ldflags "-X github.com/elastic/elastic-package/internal/version.CommitHash=`git describe --always --long --dirty` -X github.com/elastic/elastic-package/internal/version.BuildTime=`date +%s`" \
go install -ldflags \
"-X $(VER_PKG).CommitHash=`git describe --always --long --dirty` -X $(VER_PKG).BuildTime=`date +%s` -X $(VER_PKG).Tag=`(git describe --exact-match --tags 2>/dev/null || echo '') | tr -d '\n'`" \
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this line can be split in multiple lines for easier readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately this is not possible due to the interaction of make string handling and -ldflags behaviour.

@efd6 efd6 merged commit 71ba8ef into elastic:master Jan 20, 2022
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.

4 participants