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

feat(cli): Add offline linting #5569

Merged
merged 10 commits into from
Apr 16, 2021
Merged

Conversation

NikeNano
Copy link
Contributor

@NikeNano NikeNano commented Apr 1, 2021

Checklist:

@NikeNano NikeNano marked this pull request as draft April 1, 2021 12:48
@codecov
Copy link

codecov bot commented Apr 1, 2021

Codecov Report

Merging #5569 (a06a556) into master (cc7e310) will decrease coverage by 0.16%.
The diff coverage is 29.21%.

❗ Current head a06a556 differs from pull request most recent head c11df9e. Consider uploading reports for the commit c11df9e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5569      +/-   ##
==========================================
- Coverage   47.08%   46.92%   -0.17%     
==========================================
  Files         240      244       +4     
  Lines       15050    15202     +152     
==========================================
+ Hits         7087     7134      +47     
- Misses       7058     7162     +104     
- Partials      905      906       +1     
Impacted Files Coverage Δ
cmd/argo/commands/client/conn.go 12.76% <0.00%> (-0.57%) ⬇️
cmd/argo/commands/clustertemplate/create.go 13.63% <0.00%> (-0.65%) ⬇️
cmd/argo/commands/clustertemplate/delete.go 0.00% <0.00%> (ø)
cmd/argo/commands/clustertemplate/get.go 0.00% <0.00%> (ø)
cmd/argo/commands/clustertemplate/lint.go 0.00% <0.00%> (ø)
cmd/argo/commands/clustertemplate/list.go 0.00% <0.00%> (ø)
cmd/argo/commands/cron/create.go 0.00% <0.00%> (ø)
cmd/argo/commands/cron/delete.go 0.00% <0.00%> (ø)
cmd/argo/commands/cron/get.go 24.59% <0.00%> (-0.41%) ⬇️
cmd/argo/commands/cron/lint.go 0.00% <0.00%> (ø)
... and 27 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc7e310...c11df9e. Read the comment docs.

@NikeNano NikeNano changed the title Add offline linting feat: Add offline linting Apr 1, 2021
@NikeNano NikeNano marked this pull request as ready for review April 3, 2021 21:20
@NikeNano
Copy link
Contributor Author

NikeNano commented Apr 3, 2021

@alexec would be great if you could give some pointers on the implementation for offline linting, thanks!

cmd/argo/commands/lint.go Outdated Show resolved Hide resolved
pkg/apiclient/http1-client.go Outdated Show resolved Hide resolved
@alexec alexec changed the title feat: Add offline linting feat(cli): Add offline linting Apr 4, 2021
@sarabala1979 sarabala1979 self-assigned this Apr 5, 2021
cmd/argo/commands/submit.go Outdated Show resolved Hide resolved
cmd/argo/commands/clustertemplate/lint.go Outdated Show resolved Hide resolved
cmd/argo/commands/lint.go Outdated Show resolved Hide resolved
pkg/apiclient/argo-kube-client.go Outdated Show resolved Hide resolved
pkg/apiclient/argo-server-client.go Outdated Show resolved Hide resolved
pkg/apiclient/http1-client.go Outdated Show resolved Hide resolved
pkg/apiclient/offlineclient.go Outdated Show resolved Hide resolved
pkg/apiclient/offlineclient.go Outdated Show resolved Hide resolved
cmd/argo/lint/lint.go Outdated Show resolved Hide resolved
var explicitPath string
var (
explicitPath string
Offline bool
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should have ARGO_OFFLINE envvar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would be better suited as an argument atm since it is only supported for the linting.

@@ -48,7 +48,10 @@ func NewCreateCommand() *cobra.Command {

func CreateCronWorkflows(filePaths []string, cliOpts *cliCreateOpts, submitOpts *wfv1.SubmitOpts) {
ctx, apiClient := client.NewAPIClient()
serviceClient := apiClient.NewCronWorkflowServiceClient()
serviceClient, err := apiClient.NewCronWorkflowServiceClient()
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: prefer errors.CheckError(err)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tried to be consistent with the error handling in each part of the code. Suggest we make a clean up in a seperate PR to errors.CheckError(err). WDYT?

Copy link
Contributor

@alexec alexec Apr 16, 2021

Choose a reason for hiding this comment

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

I don't feel strongly. Any comment prefixed with "minor" is a suggestion.

pkg/apiclient/offlineclient.go Outdated Show resolved Hide resolved
Signed-off-by: NikeNano <[email protected]>
Signed-off-by: NikeNano <[email protected]>
@alexec
Copy link
Contributor

alexec commented Apr 7, 2021

Lint error

  level=error msg="Running error: buildir: analysis skipped: errors in package: [/home/runner/work/argo-workflows/argo-workflows/test/e2e/cli_test.go:63:7: undeclared name: OFFLINE /home/runner/work/argo-workflows/argo-workflows/test/e2e/cli_test.go:725:12: undeclared name: OFFLINE]"

Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

Please lint

@@ -62,6 +66,7 @@ func NewClientFromOpts(opts Opts) (context.Context, Client, error) {
if opts.ClientConfigSupplier != nil {
opts.ClientConfig = opts.ClientConfigSupplier()
}
return newArgoKubeClient(opts.ClientConfig, instanceid.NewService(opts.InstanceID))
ctx, client, err := newArgoKubeClient(opts.ClientConfig, instanceid.NewService(opts.InstanceID))
return ctx, client, err
Copy link
Contributor

@alexec alexec Apr 7, 2021

Choose a reason for hiding this comment

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

suggestion: revert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean new line? Or that you actually want this to be indented?

@@ -14,6 +14,8 @@ import (

type httpClient http1.Facade

var _ Client = &httpClient{}
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@@ -719,6 +721,24 @@ func (s *CLISuite) TestWorkflowLint() {
})
}

func (s *CLISuite) TestWorkflowOfflineLint() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

Signed-off-by: NikeNano <[email protected]>
@NikeNano
Copy link
Contributor Author

NikeNano commented Apr 8, 2021

how do I re-trigger the tests again @alexec?

@alexec
Copy link
Contributor

alexec commented Apr 8, 2021

there are some users submitting PRs adding crypto mining code - lets wait for them to go away

@NikeNano
Copy link
Contributor Author

Is is possible to run the tests again @alexec?

@NikeNano
Copy link
Contributor Author

Will continue to work on why the TestArchive fail tomorrow.

@alexec alexec marked this pull request as draft April 13, 2021 18:27
@NikeNano NikeNano marked this pull request as ready for review April 15, 2021 19:19
Signed-off-by: NikeNano <[email protected]>
@NikeNano
Copy link
Contributor Author

NikeNano commented Apr 15, 2021

Fixed the tests now @alexec

Need to rerun the tests.

Signed-off-by: NikeNano <[email protected]>
Signed-off-by: NikeNano <[email protected]>
@NikeNano
Copy link
Contributor Author

Could you PTALA @alexec , thanks.

},
}

command.Flags().StringSliceVar(&lintKinds, "kinds", []string{"all"}, fmt.Sprintf("Which kinds will be linted. Can be: %s", strings.Join(allKinds, "|")))
command.Flags().StringVarP(&output, "output", "o", "pretty", "Linting results output format. One of: pretty|simple")
command.Flags().BoolVar(&strict, "strict", true, "Perform strict workflow validation")
command.Flags().BoolVar(&offline, "offline", false, "perform offline linting")
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion:

command.Flags().BoolVar(&client.Offline, "offline", false, "Go offline - do not connect to server")

@alexec alexec added this to the v3.1 milestone Apr 16, 2021
@alexec alexec merged commit 8607391 into argoproj:master Apr 16, 2021
@simster7 simster7 mentioned this pull request Apr 19, 2021
50 tasks
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.

3 participants