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

added display version, hash and dirty in logs #149

Merged
merged 11 commits into from
Jul 8, 2024

Conversation

ehearneRedHat
Copy link
Contributor

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 and make local-setup locally. Without any file changes made the hash should be displayed without appendixed dirty 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.

@ehearneRedHat ehearneRedHat requested a review from eguzki July 2, 2024 12:03
@ehearneRedHat ehearneRedHat self-assigned this Jul 2, 2024
@ehearneRedHat ehearneRedHat added the kind/enhancement New feature or request label Jul 2, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jul 2, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.80%. Comparing base (da27315) to head (3eb7709).
Report is 4 commits behind head on main.

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     
Flag Coverage Δ
integration 78.77% <ø> (-0.61%) ⬇️
unit 66.51% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
api/v1alpha1 (u) 100.00% <ø> (ø)
pkg/helpers (u) 83.87% <ø> (ø)
pkg/log (u) 94.73% <ø> (ø)
pkg/reconcilers (u) 74.67% <ø> (ø)
pkg/limitador (u) 98.11% <ø> (ø)
controllers (i) 74.66% <ø> (-0.67%) ⬇️
pkg/upgrades 88.88% <ø> (ø)

see 1 file with indirect coverage changes

Copy link
Contributor

@eguzki eguzki left a comment

Choose a reason for hiding this comment

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

Makefile Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@ehearneRedHat ehearneRedHat requested a review from eguzki July 4, 2024 11:34
Copy link
Contributor

@eguzki eguzki left a 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

@ehearneRedHat
Copy link
Contributor Author

@eguzki all done . :)

@ehearneRedHat ehearneRedHat requested a review from eguzki July 8, 2024 12:27
.github/workflows/build-images-base.yaml Outdated Show resolved Hide resolved
.github/workflows/build-images-base.yaml Outdated Show resolved Hide resolved
@ehearneRedHat ehearneRedHat merged commit 5fde4c9 into main Jul 8, 2024
13 checks passed
@ehearneRedHat ehearneRedHat deleted the version-commit-dirty branch July 8, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants