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

Add version in binary and docker #1030

Merged
merged 3 commits into from
Oct 19, 2023
Merged

Add version in binary and docker #1030

merged 3 commits into from
Oct 19, 2023

Conversation

charankamarapu
Copy link
Member

Related Issue

  • Info about Issue or bug

Closes: #1029

Describe the changes you've made

There are 3 different scenarios where the version should be appeared in CLI output

  1. When user runs released binary of keploy
  2. When user runs released docker of keploy
  3. When developer runs keploy in local by cloning keploy (docker as well as binary)

i) The 3rd scenario is nearly impossible because, when a developer forks keploy repository the release tags aren't pulled into the fork by default. So it is not possible to get the tags/version. I have tried multiple ways like
--Pulling tags through code in main.go and using them but I found that we can't just pull tags but commit will also be pulled with the tags which will mess developer repo.
--Doing a request to keploy repo with each commit in dev repo and seeing if there is a tag associated with it or not . But this is taking lot of time like 4-5 sec which is not preferable for just getting version.
I have referred other project and they were not printing the version in the output but they were printing the major version and a suffix like "dev". So I have also decided to do the same by printing "2-dev" in case of developer running keploy.

ii) Regarding 1st scenario previously version used to be appeared in the release binary but it stopped appearing after adding this line in goreleaser
- -s -w -X main.Dsn={{.Env.SENTRY_DSN_BINARY}}
I have did a bit of research and found out that by default these ldflags will be added
-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser.
So when we add a custom ldflag like SENTRY_DSN_BINARY the default will be erased and only custom will be taken up. Confirmed from go releaser maintainer - goreleaser/goreleaser#4377
So I have added the version ldflag into the custom

iii) For 2nd scenario I have added the version from tag into the docker-publish and into Dockerfile to show the version.

I have also changed how dsn in being populated

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, local variables)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Please let us know if any test cases are added

Please describe the tests(if any). Provide instructions how its affecting the coverage.

Describe if there is any unusual behaviour of your code(Write NA if there isn't)

A clear and concise description of it.

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Screenshots (if any)

Ignore the values in the version those were test numbers.
Developer:

Screenshot 2023-10-19 at 11 49 01 AM

Binary:

Screenshot 2023-10-19 at 11 49 12 AM

Docker:

Screenshot 2023-10-19 at 11 49 45 AM

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
@sweep-ai
Copy link

sweep-ai bot commented Oct 19, 2023

Apply Sweep Rules to your PR?

  • Apply: Leftover TODOs in the code should be handled.
  • Apply: All new business logic should have corresponding unit tests in the tests/ directory.
  • Apply: Any clearly inefficient or repeated code should be optimized or refactored.

@charankamarapu charankamarapu requested review from Sarthak160 and re-Tick and removed request for Sarthak160 October 19, 2023 06:25
Copy link
Contributor

@re-Tick re-Tick left a comment

Choose a reason for hiding this comment

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

LGTM

@charankamarapu charankamarapu merged commit 85b928b into keploy:main Oct 19, 2023
6 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug]: version not mentioned in docker and binary release
2 participants