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

Move cloud run and login functionalities under cloud subcommands #3813

Merged
merged 11 commits into from
Jul 24, 2024

Conversation

oleiade
Copy link
Member

@oleiade oleiade commented Jun 25, 2024

What?

This PR modifies the k6 command-line interface and introduces the cloud run and login functionalities under specific subcommands: k6 cloud run and k6 cloud login.

These two new subcommands supersede the existing k6 cloud and k6 login cloud functionalities, but as planned, they will remain in place until we reach k6 version 1.0.0. However, they now display a deprecation warning inviting users to move to the new commands.

Future plans include to eventually, on k6 v1.0.0 release, we expect to modify the k6 cloud command behavior so that it doesn't run scripts in the cloud anymore but only displays the help text documenting its subcommands.

Technicalities

From a technical perspective, this PR "only" duplicates the existing logic under new subcommands and registers those. Some outstanding refactors are mentioned throughout their code, but we adopted the approach of delegating those refactors and improvements to a future PR.

Why?

This PR is part of the effort to improve the UX of our command-line interface towards k6 v1.0.0. It aligns with our goals to unify and expand the k6 CLI's capabilities to interact with the cloud. In my absence for UX-specific concerns and discussions, please get in touch with @dgzlopes, who have as much context as we do.

TaskList

  • As requested by @dgzlopes, drop k6 cloud login support for email and password login: this includes the interactive cli triggered when running k6 cloud login, it should instead request your API token.
  • As we're at it, we might as well remove the k6 cloud run --upload-only flag, and replace it with k6 cloud upload. If this is a bigger task that I anticipate, we should do it in a separate PR.
  • Add more tests for the k6 cloud run command (asserting the arguments management especially)
  • Add more tests for the k6 cloud login command: I wonder what we can improve on that front, but it would be worth looking into it.

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

@oleiade oleiade added this to the v0.53.0 milestone Jun 25, 2024
@oleiade oleiade force-pushed the cloud_subcommands branch 2 times, most recently from b7efb31 to 1468a97 Compare June 26, 2024 12:20
@codecov-commenter
Copy link

codecov-commenter commented Jun 26, 2024

Codecov Report

Attention: Patch coverage is 59.88201% with 136 lines in your changes missing coverage. Please review.

Project coverage is 71.69%. Comparing base (20f8feb) to head (cdaa712).
Report is 2 commits behind head on master.

Current head cdaa712 differs from pull request most recent head 1468a97

Please upload reports for the commit 1468a97 to get more accurate results.

Files Patch % Lines
cmd/cloud_login.go 25.00% 72 Missing ⚠️
cmd/cloud_run.go 71.28% 38 Missing and 20 partials ⚠️
cmd/cloud.go 82.35% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3813      +/-   ##
==========================================
- Coverage   71.87%   71.69%   -0.18%     
==========================================
  Files         291      293       +2     
  Lines       21274    21606     +332     
==========================================
+ Hits        15290    15490     +200     
- Misses       4920     5029     +109     
- Partials     1064     1087      +23     
Flag Coverage Δ
ubuntu 71.62% <59.88%> (-0.19%) ⬇️
windows 71.54% <59.88%> (-0.20%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

cmd/cloud.go Outdated Show resolved Hide resolved
cmd/cloud.go Outdated Show resolved Hide resolved
cmd/cloud_login.go Outdated Show resolved Hide resolved
cmd/cloud.go Outdated Show resolved Hide resolved
cmd/cloud.go Outdated
}

if len(args) == 2 && !isRunSubcommand && !isLoginSubcommand {
return fmt.Errorf("unexpected argument: %s", args[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

cmd/cloud_run.go Outdated Show resolved Hide resolved
cmd/cloud_login.go Outdated Show resolved Hide resolved
cmd/cloud_run.go Outdated Show resolved Hide resolved
cmd/cloud_run.go Outdated Show resolved Hide resolved
@oleiade
Copy link
Member Author

oleiade commented Jul 18, 2024

Cleaning up the PR history in preparation for leaving draft state 👀

@oleiade oleiade force-pushed the cloud_subcommands branch 2 times, most recently from ddce8cb to cf7e0b9 Compare July 18, 2024 14:22
@oleiade oleiade marked this pull request as ready for review July 18, 2024 14:45
@oleiade oleiade requested a review from a team as a code owner July 18, 2024 14:45
@oleiade oleiade requested review from codebien and olegbespalov and removed request for a team July 18, 2024 14:45
cmd/cloud.go Outdated Show resolved Hide resolved
cmd/cloud.go Outdated Show resolved Hide resolved
cmd/cloud.go Outdated Show resolved Hide resolved
cmd/cloud_login.go Outdated Show resolved Hide resolved
cmd/cloud_login.go Outdated Show resolved Hide resolved
cmd/login.go Outdated Show resolved Hide resolved
cmd/login_cloud.go Outdated Show resolved Hide resolved
cmd/cloud.go Outdated Show resolved Hide resolved
cmd/cloud.go Outdated Show resolved Hide resolved
cmd/cloud.go Outdated Show resolved Hide resolved
joanlopez
joanlopez previously approved these changes Jul 23, 2024
Copy link
Contributor

@joanlopez joanlopez left a comment

Choose a reason for hiding this comment

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

Great job! 🚀

oleiade and others added 9 commits July 23, 2024 14:53
Important notice: this commit declare a cobra sub-command holding the
logic for the `k6 cloud run` sub-command, but does not register it.

In this commit, we duplicate the logic from the existing `k6 cloud`
logic, with very little adjustments, to support the later registry of
the `k6 cloud run` command.

To simplify the collaboration on this and further reviews, we delegate
any refactoring of the original cloud command's logic, to a further
commit or Pull Request.
Important notice: this commit declare a cobra sub-command holding the
logic for the `k6 cloud login` sub-command, but does not register it.

In this commit, we duplicate the logic from the existing `k6 login`
logic, with very little adjustments, to support the later registry of
the `k6 cloud login` command.

To simplify the collaboration on this and further reviews, we delegate
any refactoring of the original cloud command's logic, to a further
commit or Pull Request.

This new `k6 cloud login` command is notably focusing solely on
authenticating with the Grafana Cloud k6, and by design does not aim to
support InfluxDB authentication.
Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
@oleiade
Copy link
Member Author

oleiade commented Jul 23, 2024

I have squashed the PR suggestion commits.

I've also applied a pretty significant refactor to avoid code duplication: the cloud run command relies on the cloud command's code directly, and I've refactored the tests to share the same test code between both the k6 cloud and k6 cloud run commands and parameterize the tests. Please check it out 2b0bc1f and let me know what you think @joanlopez and @olegbespalov 🙇🏻

If we're happy with this approach, I'll also apply it the k6 cloud login command if relevant 👍🏻

olegbespalov
olegbespalov previously approved these changes Jul 24, 2024
Copy link
Contributor

@olegbespalov olegbespalov left a comment

Choose a reason for hiding this comment

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

Logs good to me, left a few minor non-blocking suggestions 👍

cmd/cloud.go Outdated Show resolved Hide resolved
cmd/cloud.go Outdated Show resolved Hide resolved
cmd/cloud.go Outdated Show resolved Hide resolved
cmd/cloud_run.go Outdated Show resolved Hide resolved
cmd/cloud_login.go Outdated Show resolved Hide resolved
Co-authored-by: Oleg Bespalov <oleg.bespalov@grafana.com>
@oleiade oleiade merged commit aab3bc8 into master Jul 24, 2024
22 checks passed
@oleiade oleiade deleted the cloud_subcommands branch July 24, 2024 10:53
@mstoykov mstoykov added the documentation-needed A PR which will need a separate PR for documentation label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation-needed A PR which will need a separate PR for documentation enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants