Skip to content
Snippets Groups Projects
Commit 1575aa1b authored by André Sterba's avatar André Sterba
Browse files

Merge branch 'develop' into istaester/update-deps

parents ec6a1002 a181a3de
No related branches found
No related tags found
1 merge request!212Update dependencies to mitigate security warnings
Pipeline #86725 passed
...@@ -5,9 +5,9 @@ variables: ...@@ -5,9 +5,9 @@ variables:
GOLANG_VERSION: "1.16" GOLANG_VERSION: "1.16"
stages: stages:
- .pre
- build - build
- test - test
- analyze
- apply - apply
- integration-test - integration-test
- deploy - deploy
...@@ -15,11 +15,17 @@ stages: ...@@ -15,11 +15,17 @@ stages:
workflow: workflow:
rules: rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - if: '$CI_PIPELINE_SOURCE == "push" && $CI_OPEN_MERGE_REQUESTS'
when: never when: never
- when: always - 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'
......
...@@ -5,6 +5,14 @@ ...@@ -5,6 +5,14 @@
entrypoint: [ "" ] entrypoint: [ "" ]
variables: variables:
TAG: $CI_COMMIT_BRANCH TAG: $CI_COMMIT_BRANCH
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\"},\"$CI_DEPENDENCY_PROXY_SERVER\":{\"username\":\"$CI_DEPENDENCY_PROXY_USER\",\"password\":\"$CI_DEPENDENCY_PROXY_TOKEN\"}}}" > /kaniko/.docker/config.json
needs: []
build-testing-image:
rules: rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables: variables:
...@@ -13,9 +21,10 @@ ...@@ -13,9 +21,10 @@
variables: variables:
TAG: develop TAG: develop
BUILDARGS: -race BUILDARGS: -race
- when: always - !reference [.push_event, rules]
- !reference [.merge_request, rules]
before_script: before_script:
# replace all slashes in the tag with hyphen, because slashes are not allowed in tags # replace all slashes in the tag with hyphen, because slashes are not allowed in tags
- TAG=${TAG//\//-} - TAG=${TAG//\//-}
- mkdir -p /kaniko/.docker - mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" >/kaniko/.docker/config.json - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" >/kaniko/.docker/config.json
...@@ -29,11 +38,23 @@ build-testing-image: ...@@ -29,11 +38,23 @@ build-testing-image:
--dockerfile "Dockerfile" --dockerfile "Dockerfile"
--build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "GOLANG_VERSION=$GOLANG_VERSION"
--build-arg "BUILDARGS=$BUILDARGS" --build-arg "BUILDARGS=$BUILDARGS"
--build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/"
--destination "$GOSDN_TESTING_IMAGE" --destination "$GOSDN_TESTING_IMAGE"
--target "installer" --target "installer"
<<: *build <<: *build
build-image: build-image:
rules:
- if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
TAG: latest
- if: $CI_COMMIT_BRANCH == "develop"
variables:
TAG: develop
BUILDARGS: -race
- when: always
script: script:
- /kaniko/executor - /kaniko/executor
--cache=true --cache=true
...@@ -41,6 +62,9 @@ build-image: ...@@ -41,6 +62,9 @@ build-image:
--dockerfile "Dockerfile" --dockerfile "Dockerfile"
--build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "GOLANG_VERSION=$GOLANG_VERSION"
--build-arg "BUILDARGS=$BUILDARGS" --build-arg "BUILDARGS=$BUILDARGS"
--build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/"
--destination "$GOSDN_IMAGE" --destination "$GOSDN_IMAGE"
--destination "$CI_REGISTRY_IMAGE:$TAG" --destination "$CI_REGISTRY_IMAGE:$TAG"
<<: *build <<: *build
#--build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/"
code-quality: code-quality:
image: golangci/golangci-lint:latest-alpine image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/golangci/golangci-lint:latest-alpine
stage: test stage: analyze
script: script:
# writes golangci-lint output to gl-code-quality-report.json # writes golangci-lint output to gl-code-quality-report.json
- golangci-lint run --config .gitlab/ci/.golangci-config/.golangci.yml --out-format code-climate | tee gl-code-quality-report.json - golangci-lint run --config .gitlab/ci/.golangci-config/.golangci.yml --out-format code-climate | tee gl-code-quality-report.json
...@@ -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
...@@ -5,6 +5,10 @@ variables: ...@@ -5,6 +5,10 @@ variables:
# Templates for Job Types # Templates for Job Types
.containerlab_deploy: &containerlab_deploy .containerlab_deploy: &containerlab_deploy
stage: apply stage: apply
rules:
- if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
when: never
- when: on_success
tags: tags:
- shell - shell
before_script: before_script:
...@@ -16,8 +20,12 @@ variables: ...@@ -16,8 +20,12 @@ variables:
- docker pull ${CEOS_IMAGE} - docker pull ${CEOS_IMAGE}
.containerlab_template: &containerlab_template .containerlab_template: &containerlab_template
image: alpine:latest image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/alpine:latest
stage: build stage: build
rules:
- if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
when: never
- when: on_success
before_script: before_script:
- export PATH="${PATH}:${CI_PROJECT_DIR}/.gitlab/ci/scripts" - export PATH="${PATH}:${CI_PROJECT_DIR}/.gitlab/ci/scripts"
- firstOctet=$(generate_octet.sh $CI_COMMIT_SHA) - firstOctet=$(generate_octet.sh $CI_COMMIT_SHA)
...@@ -35,6 +43,8 @@ variables: ...@@ -35,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:
...@@ -58,9 +68,16 @@ containerlab:deploy:integration: ...@@ -58,9 +68,16 @@ 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:
rules:
- if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
when: never
- when: always
stage: .post stage: .post
tags: tags:
- shell - shell
...@@ -72,7 +89,8 @@ containerlab:destroy: ...@@ -72,7 +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
when: always rules:
- !reference [.containerlab_cleanup, rules]
#containerlab:template:develop: #containerlab:template:develop:
......
build:k8s-bot: build:k8s-bot:
stage: build stage: build
image: golang:$GOLANG_VERSION image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/golang:$GOLANG_VERSION
rules: rules:
- if: $CI_COMMIT_BRANCH == "develop" - if: $CI_COMMIT_BRANCH == "develop"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
...@@ -14,7 +14,7 @@ build:k8s-bot: ...@@ -14,7 +14,7 @@ build:k8s-bot:
.deploy: &deploy .deploy: &deploy
image: image:
name: bitnami/kubectl:latest name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/bitnami/kubectl:latest
entrypoint: [""] entrypoint: [""]
before_script: before_script:
- echo "override global before script" - echo "override global before script"
......
.integration-test: &integration-test .integration-test: &integration-test
image: $GOSDN_TESTING_IMAGE image: $GOSDN_TESTING_IMAGE
stage: integration-test stage: integration-test
rules:
- if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
when: never
- when: on_success
needs: needs:
- job: "containerlab:deploy:integration" - job: "containerlab:deploy:integration"
tags: tags:
...@@ -22,6 +26,8 @@ integration-test:nucleus: ...@@ -22,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
...@@ -30,3 +36,5 @@ integration-test:api: ...@@ -30,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
.rules: &rules
stage: analyze
rules:
- if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
when: never
- when: always
needs: []
sast: sast:
variables: variables:
SAST_ANALYZER_IMAGE_TAG: '2' SAST_ANALYZER_IMAGE_TAG: '2'
...@@ -8,3 +16,34 @@ include: ...@@ -8,3 +16,34 @@ 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/Container-Scanning.gitlab-ci.yml
license_scanning:
rules:
- !reference [.merge_request_and_changed_dependency, rules]
gemnasium-dependency_scanning:
rules:
- !reference [.merge_request_and_changed_dependency, rules]
gosec-sast:
rules:
- !reference [.nightly_pipeline, rules]
semgrep-sast:
rules:
- !reference [.nightly_pipeline, rules]
container_scanning:
stage: analyze
rules:
- if: '$CI_PIPELINE_SOURCE != "merge_request_event"'
when: never
- when: always
variables:
DOCKER_IMAGE: "${GOSDN_IMAGE}"
DOCKER_USER: "${CI_REGISTRY_USER}"
DOCKER_PASSWORD: "${CI_REGISTRY_PASSWORD}"
needs:
- build-image
.test: &test .test: &test
image: $GOSDN_TESTING_IMAGE image: $GOSDN_TESTING_IMAGE
stage: test stage: test
rules:
- when: on_success
variables: variables:
GOSDN_LOG: "nolog" GOSDN_LOG: "nolog"
GOSDN_CHANGE_TIMEOUT: "100ms" GOSDN_CHANGE_TIMEOUT: "100ms"
...@@ -19,8 +21,20 @@ unit-test: ...@@ -19,8 +21,20 @@ 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:
artifacts:
when: never
script:
- GOOS=linux go build $BUILDARGS ./cmd/gosdn
<<: *test
goplantuml: goplantuml:
image: golang:$GOLANG_VERSION image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/golang:$GOLANG_VERSION
stage: .post stage: .post
only: only:
- develop - develop
......
ARG GOLANG_VERSION=1.16 ARG GOLANG_VERSION=1.16
ARG BUILDARGS ARG BUILDARGS
ARG $GITLAB_PROXY
FROM golang:$GOLANG_VERSION-buster AS installer FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-buster AS installer
WORKDIR /src/gosdn WORKDIR /src/gosdn
COPY go.* ./ COPY go.* ./
...@@ -13,7 +14,7 @@ COPY . ./ ...@@ -13,7 +14,7 @@ COPY . ./
RUN GOOS=linux go build $BUILDARGS ./cmd/gosdn RUN GOOS=linux go build $BUILDARGS ./cmd/gosdn
FROM debian:bullseye FROM ${GITLAB_PROXY}debian:bullseye
EXPOSE 8080 EXPOSE 8080
EXPOSE 55055 EXPOSE 55055
COPY --from=builder /src/gosdn/gosdn . COPY --from=builder /src/gosdn/gosdn .
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment