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(lint): add pre-commit linting setup #573

Closed
wants to merge 8 commits into from

Conversation

rriski
Copy link
Contributor

@rriski rriski commented Dec 18, 2023

Best reviewed commit by commit.

  • run linting with pre-commit
  • add markdownlint check
  • add codespell check
  • add yamllint check
  • add yamlfix check
  • add hadolint check

Most of the diff is autofixed.

@rriski rriski requested a review from a team December 18, 2023 15:09
Copy link
Contributor

@Serpentiel Serpentiel left a comment

Choose a reason for hiding this comment

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

can we please have markdownlint added to the CI pipeline?

@Serpentiel
Copy link
Contributor

also, please rename it to docs(readme): run markdownlint or something like that

@rriski rriski force-pushed the rriski-chore-lint-readme branch from 683173c to 59d894a Compare December 19, 2023 09:01
@rriski rriski changed the title chore(readme): markdownlint readme chore(readme): add pre-commit linting setup Dec 19, 2023
@rriski rriski force-pushed the rriski-chore-lint-readme branch from 59d894a to 1efde3f Compare December 19, 2023 09:08
@rriski rriski changed the title chore(readme): add pre-commit linting setup feat(lintint): add pre-commit linting setup Dec 19, 2023
@rriski rriski force-pushed the rriski-chore-lint-readme branch from 1efde3f to ab77d2f Compare December 19, 2023 10:37
@rriski rriski requested a review from Serpentiel December 19, 2023 10:38
@rriski rriski force-pushed the rriski-chore-lint-readme branch 2 times, most recently from 0cf0a5b to 24a7566 Compare December 19, 2023 11:05
@rriski rriski force-pushed the rriski-chore-lint-readme branch from 24a7566 to 03dead3 Compare December 19, 2023 11:26
@rriski rriski changed the title feat(lintint): add pre-commit linting setup feat(lint): add pre-commit linting setup Dec 19, 2023
Copy link
Contributor

@Serpentiel Serpentiel left a comment

Choose a reason for hiding this comment

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

WDYT about reusing our existing linting solutions, such as this one, which is then used like that?

@@ -1,4 +1,6 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

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

this isn't how YAML should start

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact it is, see section 2.2 of the YAML specification: https://yaml.org/spec/1.2.2/

Copy link
Contributor

Choose a reason for hiding this comment

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

It's only mandatory to have them if you use directives in the YAML document. Directives are optional for usage, please see section 3.2.3.4 of the YAML specification. Please see examples in section 6.8.1 to have a better understanding.

Copy link
Contributor Author

@rriski rriski Dec 21, 2023

Choose a reason for hiding this comment

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

Indeed its not mandatory and we can choose to leave it out. But stating "this isn't how YAML should start" isn't constructive.

Copy link
Contributor

Choose a reason for hiding this comment

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

we can choose to leave it out

If we choose not to, then we also need to add directives. I think leaving it out is the best option, WDYT?

@Serpentiel Serpentiel self-assigned this Dec 21, 2023
@Serpentiel Serpentiel added the enhancement New feature or request label Dec 21, 2023
@rriski
Copy link
Contributor Author

rriski commented Dec 21, 2023

WDYT about reusing our existing linting solutions, such as this one, which is then used like that?

I don't mink trunk vs pre-commit. It looks like trunk doesn't support autofixable yaml linter which might be annoying. Trunk i a for-profit company whereas pre-commit is more open. It also looks like trunk is missing some of the nice trailing whitespace, end-of-file, and shebang checks that come with pre-commit, didn't find any reference to something like that in their docs.Pre-commit also seems to be more widely used within Aiven.

I can create an alternate version of this PR that utilizes trunk.

@Serpentiel
Copy link
Contributor

looks like trunk doesn't support autofixable yaml linter which might be annoying

there's a YAML linter and it's autofixable, you can see it in the example that I linked to you, it's called yamllint (https://github.com/trunk-io/plugins/tree/main/linters/yamllint)

Trunk i a for-profit company

it's free for Open Source usage :)

trailing whitespace, end-of-file, and shebang checks

trailing whitespace checks are included in golangci-lint; end-of-file and shebang checks aren't needed—it's very hard to justify need of an empty file, because those aren't generally needed/used, and bash files aren't used either because they're not cross-platform, while Go is

Pre-commit also seems to be more widely used within Aiven.

in our Go projects it's not really used, and the only such solution that we ever used is Trunk

I can create an alternate version of this PR that utilizes trunk.

sounds good; you can as well adjust this PR if you feel like it

@rriski
Copy link
Contributor Author

rriski commented Dec 21, 2023

looks like trunk doesn't support autofixable yaml linter which might be annoying

there's a YAML linter and it's autofixable, you can see it in the example that I linked to you, it's called yamllint (https://github.com/trunk-io/plugins/tree/main/linters/yamllint)

Trunk i a for-profit company

it's free for Open Source usage :)

trailing whitespace, end-of-file, and shebang checks

trailing whitespace checks are included in golangci-lint; end-of-file and shebang checks aren't needed—it's very hard to justify need of an empty file, because those aren't generally needed/used, and bash files aren't used either because they're not cross-platform, while Go is

Pre-commit also seems to be more widely used within Aiven.

in our Go projects it's not really used, and the only such solution that we ever used is Trunk

I can create an alternate version of this PR that utilizes trunk.

sounds good; you can as well adjust this PR if you feel like it

Yep, makes sense. Alternate Trunk based approach can be found here: #578.

@rriski
Copy link
Contributor Author

rriski commented Dec 21, 2023

Closed in favor of #578

@rriski rriski closed this Dec 21, 2023
@Serpentiel Serpentiel removed the enhancement New feature or request label Dec 21, 2023
@Serpentiel Serpentiel added the duplicate This issue or pull request already exists label Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants