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 YAML linting for golangci-lint config files #661

Open
atc0005 opened this issue Jun 19, 2022 · 3 comments
Open

Add YAML linting for golangci-lint config files #661

atc0005 opened this issue Jun 19, 2022 · 3 comments
Assignees
Labels
CI enhancement New feature or request linting
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented Jun 19, 2022

The https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml extension might be a resource that can be leveraged here.

@atc0005 atc0005 added enhancement New feature or request CI linting labels Jun 19, 2022
@atc0005 atc0005 added this to the Future milestone Jun 19, 2022
@atc0005 atc0005 self-assigned this Jun 19, 2022
@atc0005 atc0005 pinned this issue Jun 20, 2022
@atc0005
Copy link
Owner Author

atc0005 commented Jun 20, 2022

https://github.com/adrienverge/yamllint seems like it might do the job.

A recent enough version is available for installation via apt repos, or via pip for the latest version.

@atc0005
Copy link
Owner Author

atc0005 commented Jun 20, 2022

$ docker run -it --rm -v $PWD:$PWD -w $PWD ghcr.io/atc0005/go-ci:go-ci-stable
root@a5d5a7803615:/home/ubuntu/Desktop/go-ci# ls -la
total 116
drwxrwxr-x 8 1000 1000  4096 Jun 19 13:48 .
drwxr-xr-x 3 root root  4096 Jun 20 10:22 ..
drwxrwxr-x 8 1000 1000  4096 Jun 20 10:11 .git
drwxrwxr-x 3 1000 1000  4096 Apr 25 10:07 .github
-rw-rw-r-- 1 1000 1000   446 Nov 29  2020 .gitignore
-rw-rw-r-- 1 1000 1000   676 Jun 19 12:46 .markdownlint.yml
-rw-rw-r-- 1 1000 1000 41928 Jun  2 11:48 CHANGELOG.md
-rw-rw-r-- 1 1000 1000  1070 Jul 30  2020 LICENSE
-rw-rw-r-- 1 1000 1000 17950 Jun 19 13:48 Makefile
-rw-rw-r-- 1 1000 1000  7892 Jun 19 13:48 README.md
drwxrwxr-x 2 1000 1000  4096 Jun 20 10:18 oldstable
drwxrwxr-x 5 1000 1000  4096 Jun 20 10:03 stable
drwxrwxr-x 2 1000 1000  4096 Jun 19 13:48 tools
drwxrwxr-x 2 1000 1000  4096 Jun 20 10:18 unstable
root@a5d5a7803615:/home/ubuntu/Desktop/go-ci# yamllint ./.markdownlint.yml 
./.markdownlint.yml
  13:1      warning  missing document start "---"  (document-start)

root@a5d5a7803615:/home/ubuntu/Desktop/go-ci# echo $?
0
root@a5d5a7803615:/home/ubuntu/Desktop/go-ci# yamllint ./stable/.golangci.yml 
./stable/.golangci.yml
  15:1      warning  missing document start "---"  (document-start)
  28:81     error    line too long (103 > 80 characters)  (line-length)
  86:81     error    line too long (82 > 80 characters)  (line-length)
  87:81     error    line too long (82 > 80 characters)  (line-length)

root@a5d5a7803615:/home/ubuntu/Desktop/go-ci# echo $?
1
root@a5d5a7803615:/home/ubuntu/Desktop/go-ci# yamllint ./stable/.golangci.yml 
./stable/.golangci.yml
  15:1      warning  missing document start "---"  (document-start)
  28:81     error    line too long (103 > 80 characters)  (line-length)

root@a5d5a7803615:/home/ubuntu/Desktop/go-ci# yamllint ./stable/.golangci.yml 
./stable/.golangci.yml
  15:1      warning  missing document start "---"  (document-start)

This is from a local build of what will be the v0.6.14 version of the go-ci-stable image.

The errors were resolved by fixing the line length:

diff --git a/stable/.golangci.yml b/stable/.golangci.yml
index 6c3a6b0..ab5ece2 100644
--- a/stable/.golangci.yml
+++ b/stable/.golangci.yml
@@ -25,7 +25,10 @@ issues:
 run:
   # Define the Go version limit.
   # Mainly related to generics support in go1.18.
-  # Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17
+  #
+  # Default: use Go version from the go.mod file, fallback on the env var
+  # `GOVERSION`, fallback on 1.17
+  #
   # https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
   go: "1.18"
 
@@ -83,9 +86,9 @@ linters-settings:
     enable-all: true
     disable:
       #
-      # Disable fieldalignment settings until the Go team offers more control over
-      # the types of checks provided by the fieldalignment linter or golangci-lint
-      # does so.
+      # Disable fieldalignment settings until the Go team offers more control
+      # over the types of checks provided by the fieldalignment linter or
+      # golangci-lint does so.
       #
       # See https://github.com/atc0005/go-ci/issues/302 for more information.
       #

@atc0005
Copy link
Owner Author

atc0005 commented Jun 20, 2022

FWIW, yamllint doesn't flag this out of the box:

run:
  go: 1.18

whereas the https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml VSCode extension does:

image

@atc0005 atc0005 unpinned this issue Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI enhancement New feature or request linting
Projects
None yet
Development

No branches or pull requests

1 participant