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

fix(golangci-lint): fix errors as raised by linter #323

Merged
merged 4 commits into from Aug 4, 2023

Conversation

boreyuk
Copy link
Contributor

@boreyuk boreyuk commented Jul 19, 2023

Linked to #320

@YOU54F YOU54F requested a review from mefellows July 19, 2023 14:44
@YOU54F
Copy link
Member

YOU54F commented Jul 19, 2023

thanks @boreyuk appreciate the contribution and response on the issue. I've tagged Matt and let the PR run.

I've also updated the release pipeline to 1.20 so this linter probably wants to run against that as well. (I think we can probably drop 1.17/1.18 as they are unsupported for go, but that probably warrants another PR)

@boreyuk
Copy link
Contributor Author

boreyuk commented Jul 19, 2023

Oops, seems like the CI fails in the 1.19.x env 😅
The error is as follows:

2023-07-19T14:53:27.3368205Z signal 17 received but handler not on signal stack
2023-07-19T14:53:27.3368767Z fatal error: non-Go code set up signal handler without SA_ONSTACK flag
...
2023-07-19T14:53:27.3464264Z FAIL	github.com/pact-foundation/pact-go/v2/examples/protobuf-message	0.508s
2023-07-19T14:53:27.3464771Z ?   	github.com/pact-foundation/pact-go/v2/examples/types	[no test files]
2023-07-19T14:53:27.3465044Z FAIL

I'm trying to check if this is related to some code I modified 😅

@boreyuk boreyuk marked this pull request as ready for review July 19, 2023 19:35
@mefellows
Copy link
Member

2023-07-19T14:53:27.3368767Z fatal error: non-Go code set up signal handler without SA_ONSTACK flag

This relates to #269, I think. We have yet to chase down that nasty bug.

@mefellows
Copy link
Member

This is great, thank you. I think for the test files and the unused functions, I'll take those as is. For the real ones where we swallow the errors, perhaps we actually need to panic (dramatic, but there is no other pathway in many of them) or at the very least, log an ERROR level statement. Thoughts based on the contexts?

@boreyuk
Copy link
Contributor Author

boreyuk commented Jul 20, 2023

I agree - i think that it's better to explicitely panic than silently fail 😛
I will add another commit with the ERROR logs and the panics for unrecoverable errors.

@YOU54F
Copy link
Member

YOU54F commented Aug 3, 2023

thanks for updated commit @boreyuk have kicked off the workflow now

@boreyuk
Copy link
Contributor Author

boreyuk commented Aug 3, 2023

Thanks @YOU54F !

After checking, the tests are currently failing due to the panic() added when checking for errors in func (i *V4InteractionWithPluginResponseBuilder) PluginContents(contentType string, contents string) *V4InteractionWithPluginResponseBuilder.
The error, which was ignored before, now causes a panic 😅
The detailed error is: Failed to call out to plugin - Request to configure interaction failed: Config item with key 'pact:proto' and path to the proto file is required

Do you prefer to keep the panic and modify the test, or should I remove the panic() to keep the same behavior than before?

@YOU54F
Copy link
Member

YOU54F commented Aug 3, 2023

So that is a plugin specific error (the plugins themselves define the content make up of their messages, and can choose to error)

I think that error will be coming from the underlying plugin we are calling.

As we can't proceed in that case, and we need to perform the action in the message provided, it would make sense for this to be an error for the user.

the plugins communicate with the central pact framework via grpc so there is room for error here for a number of variables.

Having this swallowed here I think would be disadvantageous all round, so given that I would suggest a panic (provided it that also give us that detail)

Thanks for having a look again my friend, really do appreciate it

@boreyuk
Copy link
Contributor Author

boreyuk commented Aug 3, 2023

Thanks for your feedback ! I just modified the test in order to make it pass, and I commited before seeing your comment 😅
I can add another test to check if we "correctly panic" if we have an error on the plugin - anyway, the workflows should pass now 😄

@YOU54F
Copy link
Member

YOU54F commented Aug 3, 2023

No worries @boreyuk I'll let @mefellows make the final call, as he is the core maintainer of the repo.

@YOU54F
Copy link
Member

YOU54F commented Aug 3, 2023

I think we should drop 1.17 due it being out of support

https://endoflife.date/go

is there value is testing across the different supported versions of go with golanglint-ci or just the latest version we use to build/release

@coveralls
Copy link

coveralls commented Aug 3, 2023

Coverage Status

coverage: 37.197% (-0.1%) from 37.338% when pulling 520e776 on boreyuk:golangci-lint-fixes into 7d9ed69 on pact-foundation:master.

@YOU54F
Copy link
Member

YOU54F commented Aug 3, 2023

I think we need to skip linting of the C directive in internal/native/lib.go or maybe there is an option to allow it.

either way it works, once built so I assume this is a bit of a red herring?

@boreyuk
Copy link
Contributor Author

boreyuk commented Aug 3, 2023

I think we need to skip linting of the C directive in internal/native/lib.go or maybe there is an option to allow it.

either way it works, once built so I assume this is a bit of a red herring?

I added a commit which modifies the golangci-lint in order to ignore the internal/native/lib.go. I'm not familiar with configuring golangci-lint through Github Actions, so I hope this will work!

@YOU54F
Copy link
Member

YOU54F commented Aug 3, 2023

I'm not familiar with configuring golangci-lint through Github Actions, so I hope this will work!

😄 s'all good, nothing like a bit of experimentation 👍🏾

Copy link
Member

@YOU54F YOU54F left a comment

Choose a reason for hiding this comment

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

Awesome!

Man it will be nice to be able to see green in the pipeline again. Thanks dude

@mefellows
Copy link
Member

This is great, thanks.

Those additional TODOs are also good food for thought, but we can pick them up in the future.

@mefellows mefellows merged commit 7dabae0 into pact-foundation:master Aug 4, 2023
9 checks passed
@boreyuk boreyuk deleted the golangci-lint-fixes branch August 4, 2023 05:52
@boreyuk
Copy link
Contributor Author

boreyuk commented Aug 4, 2023

Nice ! Thanks to you two 🎉

@mefellows
Copy link
Member

You're so welcome, we really appreciate it. If you're up for me, I'd love to chat with you (just hit me up in the #pact-go channel in slack.pact.io).

@YOU54F YOU54F linked an issue Aug 4, 2023 that may be closed by this pull request
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.

golangci-lint failing against master branch
4 participants