-
Notifications
You must be signed in to change notification settings - Fork 14
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 display version, hash and dirty in logs #149
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #149 +/- ##
==========================================
- Coverage 85.01% 84.80% -0.21%
==========================================
Files 19 19
Lines 994 994
==========================================
- Hits 845 843 -2
- Misses 97 98 +1
- Partials 52 53 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
The github action should propagate COMMIT from ${{ github.sha }}
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.
missing propagation of docker args on github actions to build images. Here: .github/workflows/build-images-base.yaml
I tested functionality and works as expected:
if .git
does not exists -> dirty = unknown
if git diff --stat returns something -> dirty = true
else -> dirty = false
I wrote a little check-git-dirty.sh
bash script that does the same. For me it is more readable. But this is quite a matter of personal taste, so I leave up to you. Both scripts are good enough IMO.
#!/usr/bin/env bash
if ! command -v git &>/dev/null
then
echo "git not found..." >&2
exit 1
fi
if output=$(git diff --stat 2>/dev/null)
then
[ -n "$output" ] && echo "true" || echo "false"
else
# Not a git repository
exit 1
fi
I am using the script like this:
run: DIRTY=$(shell $(PROJECT_PATH)/utils/check-git-dirty.sh || echo "unknown")
run: manifests generate fmt vet ## Run a controller from your host.)
go run -ldflags "-X main.gitSHA=${GIT_SHA} -X main.dirty=${DIRTY}" ./main.go
@eguzki all done . :) |
Co-authored-by: Eguzki Astiz Lezaun <[email protected]>
Kuadrant/authorino#471
What:
Added info log to display version, commit hash and whether the branch was dirty or not on build .
Verify:
Run
make build
andmake local-setup
locally. Without any file changes made the hash should be displayed without appendixeddirty
flag. Then add a comment to a file to have git detect new changes and re-run the commands checking binary and in-cluster for both respectively.