Skip to content

Commit c9205ef

Browse files
committed
CLEANUP/MINOR: ci: restrict pipelines to MRs and consolidate job rules
Add a global workflow block to restrict pipeline execution to merge requests and manual triggers (web/API)
1 parent 22cad16 commit c9205ef

5 files changed

Lines changed: 21 additions & 24 deletions

File tree

.gitlab-ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Pipelines run only for MRs and manual (web/API) runs; branch pushes create none.
2+
workflow:
3+
rules:
4+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
5+
- if: $CI_PIPELINE_SOURCE == 'api'
6+
- if: $CI_PIPELINE_SOURCE == 'web'
7+
8+
# Extend to run in every allowed pipeline; rule-less jobs drop out of MR pipelines.
9+
.all-pipelines:
10+
rules:
11+
- when: on_success
12+
113
stages:
214
- lint
315
- security

.gitlab/build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
build:
22
stage: build
33
needs: []
4-
rules:
5-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
6-
- if: $CI_PIPELINE_SOURCE == 'push'
4+
extends: .all-pipelines
75
image:
86
name: $HAPROXY_REGISTRY_GO/golang:latest-alpine
97
entrypoint: [""]

.gitlab/lint.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
tidy:
22
stage: lint
33
needs: []
4-
rules:
5-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
6-
- if: $CI_PIPELINE_SOURCE == 'push'
4+
extends: .all-pipelines
75
image:
86
name: $HAPROXY_REGISTRY_GO/golang:latest-alpine
97
entrypoint: [""]
@@ -30,9 +28,7 @@ tidy:
3028
format:
3129
stage: lint
3230
needs: []
33-
rules:
34-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
35-
- if: $CI_PIPELINE_SOURCE == 'push'
31+
extends: .all-pipelines
3632
image:
3733
name: $HAPROXY_REGISTRY_GO/golang:latest-alpine
3834
entrypoint: [""]
@@ -60,9 +56,7 @@ format:
6056
lint:
6157
stage: lint
6258
needs: []
63-
rules:
64-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
65-
- if: $CI_PIPELINE_SOURCE == 'push'
59+
extends: .all-pipelines
6660
image:
6761
name: $HAPROXY_REGISTRY_GO/golang:latest-alpine
6862
entrypoint: [""]
@@ -91,6 +85,7 @@ commit-policy:
9185
needs: []
9286
variables:
9387
GIT_DEPTH: "0"
88+
# MR-only: needs an MR commit range.
9489
rules:
9590
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
9691
image:

.gitlab/security.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
license:
22
stage: security
33
needs: ["tidy"]
4-
rules:
5-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
6-
- if: $CI_PIPELINE_SOURCE == 'push'
4+
extends: .all-pipelines
75
image:
86
name: $HAPROXY_REGISTRY_GO/golang:latest-alpine
97
entrypoint: [""]
@@ -27,9 +25,7 @@ license:
2725
govulncheck:
2826
stage: security
2927
needs: []
30-
rules:
31-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
32-
- if: $CI_PIPELINE_SOURCE == 'push'
28+
extends: .all-pipelines
3329
image:
3430
name: $HAPROXY_REGISTRY_GO/golang:latest-alpine
3531
entrypoint: [""]

.gitlab/test.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
test-e2e:
55
stage: test
66
needs: []
7-
rules:
8-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
9-
- if: $CI_PIPELINE_SOURCE == 'push'
7+
extends: .all-pipelines
108
image: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION
119
services:
1210
- name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind
@@ -40,9 +38,7 @@ test-e2e:
4038
test:
4139
stage: test
4240
needs: []
43-
rules:
44-
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
45-
- if: $CI_PIPELINE_SOURCE == 'push'
41+
extends: .all-pipelines
4642
image:
4743
name: $HAPROXY_REGISTRY_GO/golang:latest-alpine
4844
entrypoint: [""]

0 commit comments

Comments
 (0)