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

ci: add golangci-lint #116

Merged
merged 6 commits into from
Apr 8, 2024
Merged

ci: add golangci-lint #116

merged 6 commits into from
Apr 8, 2024

Conversation

dylanhitt
Copy link
Collaborator

@dylanhitt dylanhitt commented Apr 5, 2024

Any interest in adding staticcheck here?

I've been adding linters to most my repos today and thought I'd hit this one.

I'll fix the staticcheck issues once I hear back.

Have a good weekend. Feel free to close if there isn't any interest.

After discussion this PR ended up adding golangci-lint rather than staticcheck

@dylanhitt dylanhitt force-pushed the ci/staticcheck branch 2 times, most recently from 00d1a57 to 4572090 Compare April 5, 2024 21:48
Copy link
Member

@EwenQuim EwenQuim left a comment

Choose a reason for hiding this comment

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

Good ideas !

I suggest to look at the Makefile and

  • directly use make ci-full command so we have the same checks locally and in the CI
  • Copy the Makefile steps in the CI. It would create 2 different ways to check things (inconsistent) but is probably better for performance and we would be able to have the tests decompositionore clearly.

What do you think about it ?

.github/workflows/go.yml Outdated Show resolved Hide resolved
@@ -5,7 +5,6 @@ name: Go

on:
push:
branches: ["main"]
Copy link
Member

Choose a reason for hiding this comment

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

Please keep this one, I want to make sure main is OK at any moment!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same behavior as before.

see: https://github.com/commander-cli/cmd/blob/main/.github/workflows/lint.yaml#L3 for a reference. We can keep it explicit if you want.

Copy link
Member

Choose a reason for hiding this comment

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

This isn't the exact same setup than what's proposed here

image

@dylanhitt
Copy link
Collaborator Author

dylanhitt commented Apr 6, 2024

Sure. Looks like the makefile could use some work here as well.

So a little look here.

steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v3
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v4

Or

steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v3
      - run: make golangci-lint

My two cents is we decompose with actions and we use the makefile for local testing. Yes, syncing the two will be a burden, but we can mitigate that by using these tools file based config when possible. To me CI is the real truth local ci is optional.

I personally use make to automate local tasks and prefer making the ci as concise as possible using the ci tools native commands.

I think I'm gonna go with using native github actions unless you strongly object. I'll create another PR with some work the Makefile as well.

Edit: turns on golang-ci lint simplifies this greatly. I will try to provide make targets that will compliment fixing issues that golangci-lint catches.

@dylanhitt
Copy link
Collaborator Author

dylanhitt commented Apr 6, 2024

Too add for tools that use the native go toolchain. I will more than likely elect to still use the make commands.

And I'll get something using golangci-lint starting next week and honestly. I don't think we'd have a large syncing issue if we move everything to golangci-lint anyway.

@dylanhitt dylanhitt force-pushed the ci/staticcheck branch 3 times, most recently from 33feb87 to a148aca Compare April 6, 2024 16:20
@dylanhitt
Copy link
Collaborator Author

dylanhitt commented Apr 6, 2024

Okay. I think I landed on something that works well. I chose to leverage golangci-lint heavily. If we find it too slow in the future. (I mean we're under a minute now so probably not). We can decompose the commands to individual jobs. If this looks good I'll fix the few issues.

Note: I elected to raise the gofumpt check to have -extra. I think moving forward we should focus on linting through golangci-lint and providing targets in the Makefile to auto resolve them.

Another developer tool we can add the ability to opt in to pre-commit hooks for common mistakes, but that is out of the scope of the goal here. Also I will be editing the PR title to reflect this change.

@dylanhitt dylanhitt changed the title ci: add staticcheck to Go workflow ci: add golangci-lint Apr 6, 2024
@@ -5,7 +5,6 @@ name: Go

on:
push:
branches: ["main"]
Copy link
Member

Choose a reason for hiding this comment

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

This isn't the exact same setup than what's proposed here

image

.github/workflows/go.yml Show resolved Hide resolved
Makefile Show resolved Hide resolved
@dylanhitt
Copy link
Collaborator Author

dylanhitt commented Apr 8, 2024

Looking through the golangci-lint issues. It seems we only have two options to deal with the "unescaped html". Well 3 maybe 4

  1. ignore it with a comment annotation
  2. change our api around (playing with this it seems to just feel bad) unless you see another pattern
  3. Do what the maintainers of gomarkdown suggest

We don't protect against malicious content. When dealing with user-provided markdown, run renderer HTML through HTML sanitizer such as Bluemonday.
We don't protect against malicious content. When dealing with user-provided markdown, run renderer HTML through HTML sanitizer such as Bluemonday.

  1. Or four i guess. It's put onto the caller.

@EwenQuim
Copy link
Member

EwenQuim commented Apr 8, 2024

Right now:

There are 100 options for markdown. Fuego provide one basic method for ease of use / rapid prototyping. Let's just ignore by commenting the warning, and warn the user that it might be a dangerous method in the docs. The user will create its own custom markdown parser if needed anyway.


For the future (I could do this work in a separate PR):

Cf Fuego Extra #118

@EwenQuim
Copy link
Member

EwenQuim commented Apr 8, 2024

Thank you for all this, this is a really important PR, good job 👍🏼

@dylanhitt
Copy link
Collaborator Author

@EwenQuim I believe this is officially done.

@EwenQuim
Copy link
Member

EwenQuim commented Apr 8, 2024

All green, that's wonderful

image

@EwenQuim EwenQuim merged commit fd1ae03 into go-fuego:main Apr 8, 2024
4 checks passed
@dylanhitt dylanhitt deleted the ci/staticcheck branch April 10, 2024 23:07
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.

2 participants