From f4104617bf52efd84f347ce194be4b7e862d3a5b Mon Sep 17 00:00:00 2001
From: Alina <s72799@bht-berlin.de>
Date: Tue, 12 Nov 2024 22:00:24 +0100
Subject: [PATCH] test linter job

---
 .../webservice/.gitlab-ci.yml                 | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/DefineAndRunPipeline/webservice/.gitlab-ci.yml b/DefineAndRunPipeline/webservice/.gitlab-ci.yml
index b6afd7d..817d6c4 100644
--- a/DefineAndRunPipeline/webservice/.gitlab-ci.yml
+++ b/DefineAndRunPipeline/webservice/.gitlab-ci.yml
@@ -16,6 +16,7 @@ variables:
 stages:
   - build
   - test
+  - lint
   - deploy
 
 .image:
@@ -43,6 +44,31 @@ test-job:
     - go mod download
     - go test -v ./...
 
+lint-job:
+  stage: lint
+  extends:
+    - .image
+  image: golangci/golangci-lint:v1.55.2-alpine
+  variables:
+    CONFIG_FILE_LINK: https://gitlab.com/gitlab-ci-utils/config-files/-/raw/10.1.1/Linters/.golangci.yml
+  rules:
+    - exists:
+        - '**/*.go'
+  before_script:
+    - apk add jq
+    - if [ ! -f .golangci.yml ]; then (wget $CONFIG_FILE_LINK) fi
+    - cd DefineAndRunPipeline/webservice
+  script:
+    - >
+      golangci-lint run --out-format code-climate $LINT_GO_CLI_ARGS |
+      tee gl-code-quality-report.json |
+      jq -r '.[] | "\(.location.path):\(.location.lines.begin) \(.description)"'
+  artifacts:
+    reports:
+      codequality: gl-code-quality-report.json
+    paths:
+      - DefineAndRunPipeline/webservice/$GO_BIN_PATH*/gl-code-quality-report.json
+  allow_failure: true
 
 deploy-job:
   stage: deploy
-- 
GitLab