Commit a9bc1cbe authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'fix/golangci-lint-v2' into 'master'

Fix/golangci lint v2

Closes #43

See merge request to-be-continuous/golang!76
parents 21e3659e 2f6c0203
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ It is bound to the `build` stage, and uses the following variables:
| Input / Variable | Description                                                                                              | Default value                          |
|-----------------------|----------------------------------------------------------------------------------------------------------|----------------------------------------|
| `ci-lint-image` / `GO_CI_LINT_IMAGE` | The Docker image used to run `golangci-lint`                                                             | `registry.hub.docker.com/golangci/golangci-lint:latest-alpine` <br/>[![Trivy Badge](https://to-be-continuous.gitlab.io/doc/secu/trivy-badge-GO_CI_LINT_IMAGE.svg)](https://to-be-continuous.gitlab.io/doc/secu/trivy-GO_CI_LINT_IMAGE) |
| `ci-lint-args` / `GO_CI_LINT_ARGS` | `golangci-lint` [command line arguments](https://github.com/golangci/golangci-lint#command-line-options) | `-E gosec,goimports ./...`             |
| `ci-lint-args` / `GO_CI_LINT_ARGS` | `golangci-lint` [command line arguments](https://github.com/golangci/golangci-lint#command-line-options) | `-E gosec ./...`             |
| `ci-lint-disabled` / `GO_CI_LINT_DISABLED` | Set to `true` to disable this job                                                                        | _none_ (enabled)                        |

In addition to a textual report in the console, this job produces the following reports, kept for one day:
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@
        {
          "name": "GO_CI_LINT_ARGS",
          "description": "`golangci-lint` [command line arguments](https://github.com/golangci/golangci-lint#command-line-options)",
          "default": "-E gosec,goimports ./...",
          "default": "-E gosec ./...",
          "advanced": true
        }
      ]
+9 −2
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ spec:
      default: registry.hub.docker.com/golangci/golangci-lint:latest-alpine
    ci-lint-args:
      description: '`golangci-lint` [command line arguments](https://github.com/golangci/golangci-lint#command-line-options)'
      default: -E gosec,goimports ./...
      default: -E gosec ./...
    semgrep-image:
      description: The Docker image used to run [Semgrep](https://semgrep.dev/docs/)
      default: registry.hub.docker.com/semgrep/semgrep:latest
@@ -719,7 +719,14 @@ go-ci-lint:
  script:
    - mkdir -p -m 777 reports
    # produce all reports at once
    - golangci-lint run --out-format "colored-line-number:stdout,code-climate:reports/go-ci-lint.codeclimate.json,checkstyle:reports/go-ci-lint.checkstyle.xml" $GO_CI_LINT_ARGS
    - |
      glc_ver_major=$(golangci-lint version | cut -d' ' -f4 | cut -d'.' -f1)
      if [[ "$glc_major_ver" == "1" ]]
      then
        golangci-lint run --out-format "colored-line-number:stdout,code-climate:reports/go-ci-lint.codeclimate.json,checkstyle:reports/go-ci-lint.checkstyle.xml" $GO_CI_LINT_ARGS
      else
        golangci-lint run --output.text.path stdout --output.code-climate.path reports/go-ci-lint.codeclimate.json --output.checkstyle.path reports/go-ci-lint.checkstyle.xml $GO_CI_LINT_ARGS
      fi
  artifacts:
    name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
    expire_in: 1 day