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 global debug option to flow command and correct flags #851

Merged
merged 6 commits into from
Nov 16, 2022

Conversation

feluelle
Copy link
Member

@feluelle feluelle commented Nov 1, 2022

Description

In the sql-cli we are adding a new global --debug flag which we need to register to cobra, too. So that astro-cli users can use the flag in flow.

🎟 Issue(s)

Related astronomer/astro-sdk#1040

📋 Checklist

  • Rebased from the main (or release if patching) branch (before testing)
  • Ran make test before taking out of draft
  • Ran make lint before taking out of draft
  • Added/updated applicable tests
  • Tested against Astro-API (if necessary).
  • Tested against Houston-API and Astronomer (if necessary).
  • Communicated to/tagged owners of respective clients potentially impacted by these changes.
  • Updated any related documentation

@codecov
Copy link

codecov bot commented Nov 1, 2022

Codecov Report

Base: 87.13% // Head: 87.14% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (79ba762) compared to base (f5b6e43).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #851      +/-   ##
==========================================
+ Coverage   87.13%   87.14%   +0.01%     
==========================================
  Files         106      106              
  Lines        9091     9105      +14     
==========================================
+ Hits         7921     7935      +14     
  Misses        689      689              
  Partials      481      481              
Impacted Files Coverage Δ
cmd/sql/flow.go 83.41% <100.00%> (+1.09%) ⬆️
sql/flow.go 91.95% <100.00%> (+0.18%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@feluelle feluelle changed the title Add global verbose option to flow command Add global debug option to flow command and correct flags Nov 4, 2022
@feluelle feluelle force-pushed the feature/debug branch 2 times, most recently from 1a1360e to 94cff7b Compare November 9, 2022 10:03
@feluelle feluelle marked this pull request as ready for review November 9, 2022 10:03
@kaxil
Copy link
Contributor

kaxil commented Nov 11, 2022

@kushalmalani @andriisoldatenko Could you review this PR please?

Copy link
Contributor

@neel-astro neel-astro left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -130,7 +130,7 @@ func TestFlowGenerateCmd(t *testing.T) {
err := execFlowCmd([]string{"init", projectDir}...)
assert.NoError(t, err)

err = execFlowCmd([]string{"generate", "example_basic_transform", "--project-dir", projectDir}...)
err = execFlowCmd([]string{"generate", "example_basic_transform", "--project-dir", projectDir, "--verbose"}...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have tests for both when we enable --verbose and not? Do they have different assertions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Those tests are only testing that the inputs work with cobra. For example, if the flag is unknown, it will raise an error.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can add all flags at once to cover all scenarios of flags added to cobra.

assert.NoError(t, err)

err = execFlowCmd([]string{"--debug", "run", "example_templating", "--env", "dev", "--project-dir", projectDir}...)
assert.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is checking if the command didn't raise an exception good enough? Would there be any other meaningful assertions we could make here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that this is currently enough as cobra will raise an error if the command is incorrect e.g. has too many args or unknown flags, etc.

cmd/sql/flow.go Show resolved Hide resolved
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
golang.org/x/text v0.3.7 // indirect
golang.org/x/crypto v0.1.0 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need changes in this file to be checked in?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this can be useful to read. I am reading it right now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why I had to run go mod tidy is because I added a new dependency golang.org/x/exp/slices.

go.sum Show resolved Hide resolved
@neel-astro neel-astro merged commit 9d2377f into main Nov 16, 2022
@neel-astro neel-astro deleted the feature/debug branch November 16, 2022 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants