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

Feature: Added Keploy Update to CLI #1325

Merged
merged 62 commits into from
Feb 5, 2024

Conversation

Akash-Singh04
Copy link
Contributor

@Akash-Singh04 Akash-Singh04 commented Jan 9, 2024

Related Issue

  • This pull request enhances the update functionality in the Keploy CLI tool to ensure smoother and more efficient updates of the Keploy binary file.

Resolves: #1303

Describe the changes you've made

The updates include:

Addition of Update Command

  • Integrated the update command in the Keploy CLI to fetch the latest version from the GitHub repository.
  • Refactored the update process to verify the current installed version against the latest available version fetched from the repository.
  • Integrated GitHub API requests to retrieve the latest release version and get the changelog
  • Updated the binary file
  • Display the changelog after the version has been successfully updated

Addition of notification for new update

  • Checks for a new update whenever keploy CLI is used
  • If a new update is available, prompts the user in a non invasive way to update the binary file.

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

NIL

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

NA

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)

Screenshot 2024-01-11 061617

Signed-off-by: Akash <akashsingh2210670@gmail.com>
Copy link

github-actions bot commented Jan 9, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@AkashKumar7902 AkashKumar7902 self-requested a review January 9, 2024 16:01
Signed-off-by: Akash <akashsingh2210670@gmail.com>
@Akash-Singh04 Akash-Singh04 marked this pull request as draft January 10, 2024 04:52
@Akash-Singh04 Akash-Singh04 marked this pull request as ready for review January 10, 2024 04:55
@Akash-Singh04
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@AkashKumar7902
Copy link
Member

AkashKumar7902 commented Jan 10, 2024

@Akash-Singh04 If there is a way to get the changelog for the new version, it would be great to display it after updating the binary.

@AkashKumar7902
Copy link
Member

AkashKumar7902 commented Jan 10, 2024

Also, if the api endpoint used to fetch the version is down or unresponsive, will the keploy execution hang waiting for a response from the endpoint ?
if it hangs, then set an appropriate timeout. show an error of unresponsiveness only during keploy update execution, the other commands should run fine.
After completion please update the PR description.

@AkashKumar7902
Copy link
Member

you can transfer the redundant getlatestreleaseversion function to utils/utils.go

Copy link
Member

@AkashKumar7902 AkashKumar7902 left a comment

Choose a reason for hiding this comment

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

please address the review comments

cmd/updatebinary.go Outdated Show resolved Hide resolved
cmd/updatebinary.go Outdated Show resolved Hide resolved
cmd/updatebinary.go Outdated Show resolved Hide resolved
@AkashKumar7902
Copy link
Member

AkashKumar7902 commented Jan 10, 2024

Highlight the keploy update command in gray in the version available msg. also just run 'keploy update' to update would be good. remove the quotes around keploy update too.

It should look like:
image

Decrease the length of the box by 20-30%

@Akash-Singh04
Copy link
Contributor Author

Understood! Working on the proposed changes!

Signed-off-by: Akash <akashsingh2210670@gmail.com>
Signed-off-by: Akash <akashsingh2210670@gmail.com>
@Akash-Singh04
Copy link
Contributor Author

you can transfer the redundant getlatestreleaseversion function to utils/utils.go

since the utils/utils.go package is on https://pkg.go.dev/go.keploy.io/server/utils , i am unable to modify that package into having the getGithubUpdateRelease() function. Am i missing out on something here?

If so kindly let me know how do i update the utils package to now include this new function

@Akash-Singh04
Copy link
Contributor Author

@AkashKumar7902 Updated the PR, kindly have a look and revert

@AkashKumar7902
Copy link
Member

when I ran keploy after update command then, I get this :
image
investigate why this is happening as my binary is up to date.

main.go Outdated Show resolved Hide resolved
pkg/service/updateBinary/updateBinary.go Outdated Show resolved Hide resolved
pkg/service/updateBinary/updateBinary.go Outdated Show resolved Hide resolved
pkg/service/updateBinary/updateBinary.go Outdated Show resolved Hide resolved
pkg/service/updateBinary/updateBinary.go Outdated Show resolved Hide resolved
pkg/service/updateBinary/updateBinary.go Outdated Show resolved Hide resolved
pkg/service/updateBinary/updateBinary.go Outdated Show resolved Hide resolved
pkg/service/updateBinary/updateBinary.go Outdated Show resolved Hide resolved
pkg/service/updateBinary/updateBinary.go Outdated Show resolved Hide resolved
pkg/service/updateBinary/updateBinary.go Outdated Show resolved Hide resolved
Signed-off-by: Akash Kumar <meakash7902@gmail.com>
@AkashKumar7902
Copy link
Member

the changelog returned by the github api is in the form of markdown. we can't display raw markdown. convert into a pretty format

@Akash-Singh04
Copy link
Contributor Author

Will make the necessary changes and revert

@Akash-Singh04
Copy link
Contributor Author

when I ran keploy after update command then, I get this : image investigate why this is happening as my binary is up to date.

The reason for this behaviour is that when we are using a development version, the version of the binary file is automatically set to "2-dev".

image

As using the command

sudo go run main.go

You are creating a new development version of the binary file and executing it, the version doesn't match the latest release version.

That is my hyothesis for the cause of this behaviour. Please feel free to correct me or suggest an alternative approach.

@Akash-Singh04
Copy link
Contributor Author

Akash-Singh04 commented Jan 29, 2024

@charankamarapu @AkashKumar7902 How are we planning to implement the update message? As @charankamarapu pointed out, it will cause a 2-3s delay everytime a keploy command is run as it is making an HTTP request.

An alternative i can suggest is to instead have the message pop up at the end of command execution, hence not effecting the user experience.

Kindly let me know the implementation of this, alternatively we can seggregate the update message into a different issue to reflect upon it further

cmd/root.go Outdated Show resolved Hide resolved
Copy link
Member

@charankamarapu charankamarapu left a comment

Choose a reason for hiding this comment

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

Please address the comments

cmd/root.go Outdated Show resolved Hide resolved
cmd/update.go Outdated Show resolved Hide resolved
pkg/service/update/service.go Outdated Show resolved Hide resolved
pkg/service/update/update.go Show resolved Hide resolved
pkg/service/update/update.go Show resolved Hide resolved
pkg/service/update/update.go Outdated Show resolved Hide resolved
Signed-off-by: Akash <akashsingh2210670@gmail.com>
Copy link
Member

@charankamarapu charankamarapu left a comment

Choose a reason for hiding this comment

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

Please address the comments

cmd/update.go Outdated Show resolved Hide resolved
cmd/update.go Outdated Show resolved Hide resolved
pkg/service/update/service.go Outdated Show resolved Hide resolved
pkg/service/update/update.go Outdated Show resolved Hide resolved
pkg/service/update/update.go Outdated Show resolved Hide resolved
pkg/service/update/update.go Show resolved Hide resolved
pkg/service/update/update.go Outdated Show resolved Hide resolved
pkg/service/update/update.go Show resolved Hide resolved
pkg/service/update/update.go Show resolved Hide resolved
pkg/service/update/update.go Outdated Show resolved Hide resolved
Signed-off-by: Akash <akashsingh2210670@gmail.com>
Signed-off-by: Akash <akashsingh2210670@gmail.com>
Signed-off-by: Akash <akashsingh2210670@gmail.com>
pkg/service/update/update.go Outdated Show resolved Hide resolved
pkg/service/update/update.go Show resolved Hide resolved
Copy link
Member

@charankamarapu charankamarapu left a comment

Choose a reason for hiding this comment

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

Please address the comment everything else looks good to me.

Signed-off-by: Akash <akashsingh2210670@gmail.com>
Copy link
Member

@charankamarapu charankamarapu left a comment

Choose a reason for hiding this comment

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

Ship it!

@charankamarapu charankamarapu merged commit b84f6a6 into keploy:main Feb 5, 2024
13 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 5, 2024
@Akash-Singh04 Akash-Singh04 deleted the updatecommand branch February 5, 2024 07:51
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.

[feature]: add update command to keploy cli
3 participants