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

fix(lint): always produce Sonar report even when lint fails

parent afb1e27f
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -167,10 +167,9 @@ stages:
  }

  function sonar_lint_report() {
    if [[ -n "$SONAR_URL" ]]
    if [[ "${SONAR_HOST_URL:-$SONAR_URL}" ]]
    then
      mkdir -p reports
      log_info "SonarQube template detected (\$SONAR_URL): generate golangci-lint report for SonarQube (\\e[33;1mreports/golangci-lint-report.xml\\e[0m)"
      log_info "SonarQube template detected (\$SONAR_HOST_URL or \$SONAR_URL): generate golangci-lint report for SonarQube (\\e[33;1mreports/golangci-lint-report.xml\\e[0m)"
      # shellcheck disable=SC2086
      golangci-lint run --out-format checkstyle $GO_CI_LINT_ARGS > reports/golangci-lint-report.xml
    fi
@@ -371,8 +370,11 @@ go-ci-lint:
  stage: build
  image: $GO_CI_LINT_IMAGE
  script:
    - mkdir -p reports
    # maybe produce Sonar lint report (not failing)
    - sonar_lint_report || true
    # console output report (failing)
    - golangci-lint run $GO_CI_LINT_ARGS
    - sonar_lint_report
  artifacts:
    name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
    expire_in: 1 day
@@ -390,7 +392,7 @@ go-mod-outdated:
  stage: test
  dependencies: []
  script:
    - mkdir reports
    - mkdir -p reports
    - install_go_mod_outdated
    - go $GO_LIST_ARGS | $GOBIN/go-mod-outdated $GO_MOD_OUTDATED_ARGS > reports/go-mod-outdated-report.md
  artifacts: