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

Display Git commit ID in output of odo commands where the version is shown #7074

Conversation

rm3l
Copy link
Member

@rm3l rm3l commented Sep 6, 2023

What type of PR is this:
/kind task

What does this PR do / why we need it:
To help with troubleshooting, this PR appends the Git commit ID next to the odo version in the output of commands where the version is shown. This currently includes:

  • odo version
  • odo init
  • odo dev
  • odo deploy

Furthermore, the Git commit ID displayed is enriched with the current state of the working tree, like -dirty if the working tree has local changes. This will help quickly understand the version and help troubleshoot commands that run in CI for example.

Example:

Before With the changes here
$ asdf exec odo deploy
  __
 /  \__     Running the application in Deploy mode using my-nodejs-app Devfile
 \__/  \    Namespace: default
 /  \__/    odo version: v3.14.0
 \__/
$ odo deploy
  __
 /  \__     Running the application in Deploy mode using the "my-nodejs-app" Devfile
 \__/  \    Namespace: default
 /  \__/    odo version: v3.14.0 (6721c668b-dirty)
 \__/

Which issue(s) this PR fixes:
Fixes #6131

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:

…displayed

This covers:
- odo init
- odo dev
- odo deploy

Displaying the commit ID (same as in `odo version`) will help quickly pinpoint the exact commit without having to run `odo version`.

See redhat-developer#6131 for more context
`git describe` is much more helpful to quickly understand the state of the working tree.

For backward compatibility, we are defaulting to `git rev-parse`,
just in case `git describe` does not work correctly.
@openshift-ci openshift-ci bot added the kind/task Issue is actionable task label Sep 6, 2023
@netlify
Copy link

netlify bot commented Sep 6, 2023

Deploy Preview for odo-docusaurus-preview canceled.

Name Link
🔨 Latest commit 3c06ce0
🔍 Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/64f88aebdf7b170008df0474

@openshift-ci openshift-ci bot requested review from feloy and kadel September 6, 2023 08:29
@odo-robot
Copy link

odo-robot bot commented Sep 6, 2023

OpenShift Unauthenticated Tests on commit 3328de7 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 6, 2023

NoCluster Tests on commit 3328de7 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 6, 2023

Unit Tests on commit 3328de7 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 6, 2023

Validate Tests on commit 3328de7 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 6, 2023

Kubernetes Tests on commit 3328de7 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 6, 2023

Windows Tests (OCP) on commit 3328de7 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 6, 2023

OpenShift Tests on commit 3328de7 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 6, 2023

Kubernetes Docs Tests on commit adc9699 finished successfully.
View logs: TXT HTML

@rm3l
Copy link
Member Author

rm3l commented Sep 6, 2023

In CI, we can see that the working tree has local changes, which is weird to me. I'm looking into this..

  [odo]   __
  [odo]  /  \__     Initializing a new component
  [odo]  \__/  \    
  [odo]  /  \__/    odo version: v3.14.0 (6721c668b-dirty)
  [odo]  \__/
  [odo] 
  [odo]  •  Downloading devfile "go:latest"  ...
  [odo] I0906 09:05:22.048551   11880 registry.go:5

@rm3l rm3l added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. label Sep 6, 2023
Strip the Git commit ID from the full odo version string
prior to comparing the outputs.
We still want to compare the tag displayed.
@sonarcloud
Copy link

sonarcloud bot commented Sep 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rm3l
Copy link
Member Author

rm3l commented Sep 6, 2023

In CI, we can see that the working tree has local changes, which is weird to me. I'm looking into this..

  [odo]   __
  [odo]  /  \__     Initializing a new component
  [odo]  \__/  \    
  [odo]  /  \__/    odo version: v3.14.0 (6721c668b-dirty)
  [odo]  \__/
  [odo] 
  [odo]  •  Downloading devfile "go:latest"  ...
  [odo] I0906 09:05:22.048551   11880 registry.go:5

Ok, the problem is that after cloning odo in CI, we are copying the local repo of odo to a temporary directory before running the tests. For the repo in the temporary directory not to be marked as dirty, the Git index needs to be refreshed (either manually or using other Git commands that can auto-refresh it), but that should not be an issue for the doc automation tests here. 3c06ce0 (#7074) just ignores the Git commit ID when comparing the outputs.

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. label Sep 6, 2023
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Sep 6, 2023
@openshift-merge-robot openshift-merge-robot merged commit 725a640 into redhat-developer:main Sep 6, 2023
4 checks passed
@rm3l rm3l deleted the 6131-display-git-commit-id-in-output-of-odo-commands-where-the-version-is-shown branch September 7, 2023 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Issue is actionable task lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display Git commit ID in output of odo commands where the version is shown
3 participants