From 88324d9d60a60abaf50a62dc4ce0e4b93e20d566 Mon Sep 17 00:00:00 2001
From: Yann D'Isanto <ydisanto@gmail.com>
Date: Sun, 21 Nov 2021 14:39:00 +0000
Subject: [PATCH] feat: make lint job auto on feature branches

---
 README.md                      | 1 +
 kicker.json                    | 1 +
 templates/gitlab-ci-golang.yml | 7 +++++--
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 706be14..44182d5 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,7 @@ It is bound to the `build` stage, and uses the following variables:
 | --------------------- | -------------------------------------------- | ----------------- |
 | `GO_CI_LINT_IMAGE`    | The Docker image used to run `golangci-lint` | `golangci/golangci-lint:latest-alpine` |
 | `GO_CI_LINT_ARGS`     | `golangci-lint` [command line arguments](https://github.com/golangci/golangci-lint#command-line-options) | `-E gosec,goimports ./...`       |
+| `GO_CI_LINT_DISABLED` | Set to `true` to disable this job            | _none_(enabled)       |
 
 Golang Security Checker can be a long operation and therefore the job is configured to be ran **manually** by default (overridable).
 
diff --git a/kicker.json b/kicker.json
index be374c9..95a0387 100644
--- a/kicker.json
+++ b/kicker.json
@@ -43,6 +43,7 @@
       "id": "golangci-lint",
       "name": "GolangCI-Lint",
       "description": "[GolangCI-Lint](https://github.com/golangci/golangci-lint) analysis",
+      "disable_with": "GO_CI_LINT_DISABLED",
       "variables": [
         {
           "name": "GO_CI_LINT_IMAGE",
diff --git a/templates/gitlab-ci-golang.yml b/templates/gitlab-ci-golang.yml
index 29d928f..2121ec6 100644
--- a/templates/gitlab-ci-golang.yml
+++ b/templates/gitlab-ci-golang.yml
@@ -358,10 +358,13 @@ go-ci-lint:
     # exclude merge requests
     - if: $CI_MERGE_REQUEST_ID
       when: never
+    # exclude if GO_CI_LINT_DISABLED set
+    - if: '$GO_CI_LINT_DISABLED == "true"'
+      when: never
     # on production or integration branches: auto
     - if: '$CI_COMMIT_REF_NAME =~ $PROD_REF || $CI_COMMIT_REF_NAME =~ $INTEG_REF'
-    # else (development branches): manual & non-blocking
-    - when: manual
+    # else (development branches): non-blocking
+    - if: $CI_COMMIT_REF_NAME # useless but prevents GitLab from warning
       allow_failure: true
 
 go-mod-outdated:
-- 
GitLab