-
Notifications
You must be signed in to change notification settings - Fork 13
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
added code to display version as commit hash #85
Conversation
Im apprehensive about running git command as part of the version functionality, Im thinking we could make this simpler and have less requests to GH if we add it as a step in the install make target so it just changes the version var and that can be used like it is now for latest. The only thing is we are currently installing via go install and instead we want to use make install which uses go install but would have the extra version step so a update to the readme would be needed. wdyt? |
That's fair enough - adding an external dependency can present issue.
The proposed solution now, is to use the git command and source the commit hash locally. No requests to GitHub required.
Make target isn't a bad idea - however, git will still need to be used, so git command would be called outside of GoLang rather than within GoLang.
Okay, makes sense. Having things done in a single location provides better simplicity and improve what a user expects. I will research how to do my proposed solution via a make target instead.
Sure, so to update the README to reflect this new feature, right? That makes sense. Within my current PR, I will go ahead and implement a solution with your suggestions in mind. It will remain as a WIP until this is done, and I can ping you along the way to ensure this solution suits. :) Thanks for your suggestions, @R-Lawton ! |
4d98872
to
337953d
Compare
@R-Lawton I have implemented your suggestions - do they align with what you suggested ? :) |
@adam-cattermole is this what you were suggesting ? |
b08006e
to
00b9b01
Compare
@R-Lawton let me know if this what you were looking for :) If so, I'll go ahead and set the PR as Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM make target works verified the right version shows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now there are now 3 scenarios with different version values:
go build
creates binary which prints empty versionmake install
without git configured creates binary with version "dev -"make install
with git configured creates binary with correct version with commit hash
I would somehow merge the 1. and 2., maybe setting a default value in version/version.go
and not in Makefile?
@azgabur added requested changes - please review when you have the chance. :) |
I would like to propose a different approach. I am trying to align the "versioning system" with other kuadrant components like limitador
Or WIP, the kuadrant wasm-shim Kuadrant/wasm-shim#53 which would generate something like
The proposed format is
Rules for <version>
package version
var (
Version = "v0.2.4-dev"
) that The v0.2.4 release process would have an extra step to bump the version to Rules for <git-hash>The build process first tries
if it suceeded, it tries to check for "dirty" files (not committed files used in the build)
So
or
If it fails (because there is no
It fallsback to WDYT? |
Hey @eguzki, Thanks for your suggestion! I will work on the suggestion and ping you for review when it is ready. Thanks! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #85 +/- ##
==========================================
+ Coverage 0.38% 58.66% +58.27%
==========================================
Files 17 17
Lines 783 612 -171
==========================================
+ Hits 3 359 +356
+ Misses 780 181 -599
- Partials 0 72 +72 ☔ View full report in Codecov by Sentry. |
No worries, @eguzki. I will probably continue with this PR for now (if there are any changes that are not surrounded by this issue I will put those in a separate PR) . :) |
ecf1442
to
c76b96e
Compare
Hey @eguzki I have amended your suggestions - let me know if it looks good to you. :) |
7176e62
to
d198cc8
Compare
@eguzki I have amended your suggestions - let me know if this suits :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job 🎖️
It is working as defined. I tried with "clean" git, "dirty" git and without git and GITHUB_SHA
env set and worked as expected.
Before approval, some comments for final polishing
Thanks @eguzki for being patient with me as I work through the suggestions - they have been amended. :) Feel free to review. |
no need to be grateful, you are more than welcome. Sorry for being (sometimes) too nitpicking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is almost done.
I realized that we might have an issue with the release GH workflow. On every github release, this workflow is triggered .github/workflows/release.yaml
steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: 1.21.4
Which basically does go install
, thus, version.GitHash
would not be filled.
looking at the doc https://github.com/wangyoucao577/go-release-action it seems that the action allows "rich parameter support for go build".
It would be nice to have the "Git_hash" filled for release binaries (actually those are the candidates to be used out there).
You can try creating "fake" releases to trigger the workflow. Just set them as "pre-release" and give them clarifying names like: "v0.2.4-alpha-1", "v0.2.4-alpha-2", ...
I can probably do this in a separate PR if that suits? Either way, ready for review, @eguzki ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🏅
Last, but not least, I would bring this version with commit hash implementation to kuadrant operators (all of them). |
@eguzki that's quite the task you suggested! No worries, I'll go ahead and add that as an issue to all operators. I'll go ahead and add the issue to add the GitHash to the GitHub Actions Workflow . Thanks for the approval! Merging now... |
What:
./kuadrantctl version
if Git is installed. Otherwise, it will show version v0.0.0 .Verify:
go build
followed by./kuadrantctl version
. The output should be something like:If Git is not installed, the output should look like: