Skip to content
Snippets Groups Projects
Commit 4b344d8e authored by Felix Ohms's avatar Felix Ohms
Browse files

Add rules to pipelines

parent 0f6732b8
No related branches found
No related tags found
7 merge requests!246Develop,!245Develop into Master,!244Master into develop2 into master,!219Draft: Testing,!214Test pipelines,!207Add rules to pipelines,!138Develop
...@@ -13,8 +13,19 @@ stages: ...@@ -13,8 +13,19 @@ stages:
- deploy - deploy
- .post - .post
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
- if: '$CI_PIPELINE_SOURCE == "push"'
when: always
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: always
include: include:
- local: '/.gitlab/ci/.ruleset.yml'
- local: '/.gitlab/ci/.build-container.yml' - local: '/.gitlab/ci/.build-container.yml'
- local: '/.gitlab/ci/.code-quality-ci.yml' - local: '/.gitlab/ci/.code-quality-ci.yml'
- local: '/.gitlab/ci/.security-and-compliance-ci.yml' - local: '/.gitlab/ci/.security-and-compliance-ci.yml'
......
...@@ -21,7 +21,16 @@ build-testing-image: ...@@ -21,7 +21,16 @@ build-testing-image:
variables: variables:
TAG: develop TAG: develop
BUILDARGS: -race BUILDARGS: -race
- when: always - !reference [.push_event, rules]
- !reference [.merge_request, rules]
before_script:
# replace all slashes in the tag with hyphen, because slashes are not allowed in tags
- TAG=${TAG//\//-}
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" >/kaniko/.docker/config.json
needs: []
build-testing-image:
script: script:
- /kaniko/executor - /kaniko/executor
--cache=true --cache=true
......
...@@ -9,5 +9,6 @@ code-quality: ...@@ -9,5 +9,6 @@ code-quality:
codequality: gl-code-quality-report.json codequality: gl-code-quality-report.json
paths: paths:
- gl-code-quality-report.json - gl-code-quality-report.json
rules:
- !reference [.merge_request, rules]
needs: [] needs: []
\ No newline at end of file
...@@ -43,6 +43,8 @@ variables: ...@@ -43,6 +43,8 @@ variables:
name: ${CLAB_NAME} name: ${CLAB_NAME}
paths: paths:
- ${CLAB_NAME}.clab.yml - ${CLAB_NAME}.clab.yml
rules:
- !reference [.merge_request, rules]
# JOBS # JOBS
containerlab:template:integration: containerlab:template:integration:
...@@ -66,6 +68,9 @@ containerlab:deploy:integration: ...@@ -66,6 +68,9 @@ containerlab:deploy:integration:
artifacts: artifacts:
reports: reports:
dotenv: ${CI_PROJECT_DIR}/build.env dotenv: ${CI_PROJECT_DIR}/build.env
rules:
- !reference [.merge_request, rules]
containerlab:destroy: containerlab:destroy:
...@@ -84,6 +89,8 @@ containerlab:destroy: ...@@ -84,6 +89,8 @@ containerlab:destroy:
- docker volume rm -f ${CLAB_NAME}-volume - docker volume rm -f ${CLAB_NAME}-volume
- docker image rm -f ${GOSDN_IMAGE} - docker image rm -f ${GOSDN_IMAGE}
allow_failure: true allow_failure: true
rules:
- !reference [.containerlab_cleanup, rules]
#containerlab:template:develop: #containerlab:template:develop:
......
...@@ -26,6 +26,8 @@ integration-test:nucleus: ...@@ -26,6 +26,8 @@ integration-test:nucleus:
- go test -race -v -run TestGnmi_GetIntegration - go test -race -v -run TestGnmi_GetIntegration
- go test -race -v -run TestGnmi_SubscribeIntegration - go test -race -v -run TestGnmi_SubscribeIntegration
- go test -race -v -run TestGnmi_CapabilitiesIntegration - go test -race -v -run TestGnmi_CapabilitiesIntegration
rules:
- !reference [.merge_request, rules]
integration-test:api: integration-test:api:
<<: *integration-test <<: *integration-test
...@@ -34,3 +36,5 @@ integration-test:api: ...@@ -34,3 +36,5 @@ integration-test:api:
script: script:
- cd ./api - cd ./api
- go test -race -v -run TestApiIntegration - go test -race -v -run TestApiIntegration
rules:
- !reference [.merge_request, rules]
.push_event:
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
when: on_success
.merge_request:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: on_success
.containerlab_cleanup:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
.merge_request_and_changed_dependency:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- go.mod
- go.sum
when: always
.nightly_pipeline:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: always
.nightly_develop_pipeline:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_NIGHTLY == "develop"'
when: always
.nightly_main_pipeline:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_NIGHTLY == "mainline"'
when: always
...@@ -16,23 +16,24 @@ include: ...@@ -16,23 +16,24 @@ include:
- template: Security/SAST.gitlab-ci.yml - template: Security/SAST.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml - template: Dependency-Scanning.gitlab-ci.yml
- template: Security/License-Scanning.gitlab-ci.yml - template: Security/License-Scanning.gitlab-ci.yml
# - template: Security/Secret-Detection.gitlab-ci.yml # - template: Security/Secret-Detection.gitlab-ci.yml
- template: Security/Container-Scanning.gitlab-ci.yml - template: Security/Container-Scanning.gitlab-ci.yml
license_scanning:
rules:
- !reference [.merge_request_and_changed_dependency, rules]
gemnasium-dependency_scanning: gemnasium-dependency_scanning:
<<: *rules rules:
- !reference [.merge_request_and_changed_dependency, rules]
gosec-sast: gosec-sast:
<<: *rules rules:
- !reference [.nightly_pipeline, rules]
license_scanning:
<<: *rules
semgrep-sast: semgrep-sast:
<<: *rules rules:
- !reference [.nightly_pipeline, rules]
#secret_detection:
# <<: *rules
container_scanning: container_scanning:
stage: analyze stage: analyze
...@@ -44,5 +45,5 @@ container_scanning: ...@@ -44,5 +45,5 @@ container_scanning:
DOCKER_IMAGE: "${GOSDN_IMAGE}" DOCKER_IMAGE: "${GOSDN_IMAGE}"
DOCKER_USER: "${CI_REGISTRY_USER}" DOCKER_USER: "${CI_REGISTRY_USER}"
DOCKER_PASSWORD: "${CI_REGISTRY_PASSWORD}" DOCKER_PASSWORD: "${CI_REGISTRY_PASSWORD}"
needs: needs:
- build-image - build-image
...@@ -21,11 +21,16 @@ unit-test: ...@@ -21,11 +21,16 @@ unit-test:
after_script: after_script:
- go tool cover -func=coverage.out - go tool cover -func=coverage.out
<<: *test <<: *test
rules:
- !reference [.push_event, rules]
- !reference [.merge_request, rules]
controller-test: controller-test:
script: script:
- gotestsum --junitfile report.xml --format testname -- -race -v -run TestRun - gotestsum --junitfile report.xml --format testname -- -race -v -run TestRun
<<: *test <<: *test
rules:
- !reference [.merge_request, rules]
test-build: test-build:
artifacts: artifacts:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment