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 golangci lint GH action #2976

Merged
merged 10 commits into from
Oct 22, 2020
Merged

add golangci lint GH action #2976

merged 10 commits into from
Oct 22, 2020

Conversation

Glyphack
Copy link
Contributor

@Glyphack Glyphack commented Oct 2, 2020

use golangci-lint action to lint new code changes on PRs.

Fixes #2972

Signed-off-by: Shayegan Hooshyari [email protected]

@codecov
Copy link

codecov bot commented Oct 2, 2020

Codecov Report

Merging #2976 into main will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2976      +/-   ##
==========================================
+ Coverage   73.35%   73.38%   +0.03%     
==========================================
  Files          95       95              
  Lines        6046     6046              
==========================================
+ Hits         4435     4437       +2     
+ Misses       1510     1509       -1     
+ Partials      101      100       -1     
Impacted Files Coverage Δ
internal/dag/cache.go 96.13% <0.00%> (+0.77%) ⬆️

use https://github.com/marketplace/actions/run-golangci-lint to lint code for new changes on PRs.

Fixes #2972

Signed-off-by: Shayegan Hooshyari <[email protected]>
@jpeach
Copy link
Contributor

jpeach commented Oct 3, 2020

@Glyphack Could you add a lint error to this PR to see how the GH action displays it?

@Glyphack
Copy link
Contributor Author

Glyphack commented Oct 3, 2020

@jpeach I added a unused function here is how it looks when action fails:
image
The implementation of commenting on PRs is not available yet. see: golangci/golangci-lint-action#5

@jpeach
Copy link
Contributor

jpeach commented Oct 4, 2020

@jpeach I added a unused function here is how it looks when action fails:
image
The implementation of commenting on PRs is not available yet. see: golangci/golangci-lint-action#5

@stevesloka I think this is a worthwhile improvement, WDYT?

Copy link
Member

@stevesloka stevesloka left a comment

Choose a reason for hiding this comment

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

Also will need to remove the steps which run this in the PR GH Action currently: https://github.com/projectcontour/contour/blob/main/.github/workflows/prbuild.yaml#L48-L58

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.29
Copy link
Member

Choose a reason for hiding this comment

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

Any way we can keep the versions in sync with the Makefile? (https://github.com/projectcontour/contour/blob/main/hack/golangci-lint#L15)

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 did not quite understand what you mean. Do you mean is there any way to sync these two versions or syncing it now from v1.29 to v.1.31.0?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't think of a great way to have only a single place with the version. We might just have to live with it in multiple places like we do with the Go version :(

Copy link
Member

Choose a reason for hiding this comment

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

There's a version in the hacks/golanglint-ci script as well as now in this GH Action PR. So we need to be diligent in keeping the two in in sync. This is the benefit of just leaving the Makefile doing the work and not having a separate action.

@Glyphack Glyphack requested a review from stevesloka October 7, 2020 07:04
@skriss
Copy link
Member

skriss commented Oct 19, 2020

Can someone catch me up on projectcontour/.github#3 and this PR? Reading the backscroll, the idea of the .github repo PR was that it would then be available to all org repos, so in theory we shouldn't need this PR. Is that not the case? (I'm not familiar with how the org-level action sharing works).

@Glyphack
Copy link
Contributor Author

Can someone catch me up on projectcontour/.github#3 and this PR? Reading the backscroll, the idea of the .github repo PR was that it would then be available to all org repos, so in theory we shouldn't need this PR. Is that not the case? (I'm not familiar with how the org-level action sharing works).

Me and @jpeach thought that placing workflows under .github directory will be used as default actions, like CONTRIBUTING.md and CODE_OF_CONDUCT.md. But now I searched for it and found this link simply it means having actions under workflow-templates directory will allow you to copy a workflow between org repositories.
I don't know having it under .github directory have same effect or not. If it's not working(your can check whether it's available in workflow templates or not) I can send another PR and fix it.

@jpeach
Copy link
Contributor

jpeach commented Oct 19, 2020

Can someone catch me up on projectcontour/.github#3 and this PR? Reading the backscroll, the idea of the .github repo PR was that it would then be available to all org repos, so in theory we shouldn't need this PR. Is that not the case? (I'm not familiar with how the org-level action sharing works).

I don't know having it under .github directory have same effect or not. If it's not working(your can check whether it's available in workflow templates or not) I can send another PR and fix it.

Yeh, I thought that .github worked for workflows, but it turns out that knative has custom automation that copies the workflows around. So that was a bust :(

@Glyphack
Copy link
Contributor Author

Glyphack commented Oct 19, 2020

@jpeach We can still move it into workflow-templates and It works according to github, right?

@jpeach
Copy link
Contributor

jpeach commented Oct 20, 2020

@jpeach We can still move it into workflow-templates and It works according to github, right?

IIUC, that copies the workflow to each repo, and doesn't update when the template does. I'd be happy if I was wrong about that though :)

Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @Glyphack!

I'm personally fine with or without this PR, I don't really have a preference either way for if the linting runs as an action or not. I do find the integrated comments from the codecov action annoying and wish we could toggle them off, but this one probably won't be as spammy.

See one specific comment.

.github/workflows/golangci-lint.yaml Outdated Show resolved Hide resolved
@jpeach
Copy link
Contributor

jpeach commented Oct 20, 2020

I do find the integrated comments from the codecov action annoying and wish we could toggle them off

I also find the codecov annotations annoying when I'm reviewing. There's a toggle to turn them off in the top right of the source diff view.

@skriss
Copy link
Member

skriss commented Oct 20, 2020

I do find the integrated comments from the codecov action annoying and wish we could toggle them off

I also find the codecov annotations annoying when I'm reviewing. There's a toggle to turn them off in the top right of the source diff view.

Where is this toggle?! I still can't find it. Ah, found it. It's in the per-file options (under the ... at the top-right of each file in the diff).

Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me!

Copy link
Member

@youngnick youngnick left a comment

Choose a reason for hiding this comment

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

LGTM

@skriss skriss merged commit df3f1b1 into projectcontour:main Oct 22, 2020
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.

Use the Github Action for Go linting
5 participants