ci: golangci_lint job to use dedicated script

This MR:

  • Replaces the inline golangci_lint CI job script with a call to scripts/golangci-lint.sh
  • Extends the script to run both Go modules and correctly capture their exit codes independently, so a lint failure in one module doesn't prevent the other from running
  • In CI, generates a code climate report per module and merges them into a single gl-code-quality-report.json, as artifacts.reports.codequality only accepts one file
    • Prior to this we were only collecting a quality report for v1.

A patch file is provided below to introduce a lint error in both the v1 and v2 modules, allowing you to verify the full report generation and merge flow.

diff --git a/metrics/handler.go b/metrics/handler.go
index 769d63f..ea1acbd 100644
--- a/metrics/handler.go
+++ b/metrics/handler.go
@@ -5,6 +5,7 @@ import (
 
 	"github.com/prometheus/client_golang/prometheus"
 	"github.com/prometheus/client_golang/prometheus/promhttp"
+	"fmt"
 )
 
 // Metric names for the recorded metrics.
diff --git a/v2/metrics/metrics_test.go b/v2/metrics/metrics_test.go
index b21d261..d2a1b8a 100644
--- a/v2/metrics/metrics_test.go
+++ b/v2/metrics/metrics_test.go
@@ -6,6 +6,7 @@ import (
 	"net/http/httptest"
 	"strings"
 	"testing"
+	"fmt"
 
 	"github.com/prometheus/client_golang/prometheus"
 	"github.com/stretchr/testify/assert"
  • Copy the patch to a local file
  • git apply $path
  • Run locally, simulating running in CI: CI=true ./scripts/golangci-lint.sh

Verify:

  • The script exits with code 1 (lint errors found)
  • Both modules run to completion (errors from both appear in output)
  • gl-code-quality-report.json is created at the repo root containing a JSON array with one entry per finding across both modules
Edited by Luke Hollinda

Merge request reports

Loading
Loading