Skip to content
Snippets Groups Projects
Commit dadd38da authored by Neil-Jocelyn Schark's avatar Neil-Jocelyn Schark
Browse files

stnescha/init monorepo/ci

parent 8e4e848b
Branches
Tags
2 merge requests!254stnescha/init monorepo/ci,!253Migration in monorepo
Pipeline #98001 passed
This commit is part of merge request !253. Comments created here will be created in the context of that merge request.
.build: &build .build: &build
stage: build stage: build
image: tags:
name: gcr.io/kaniko-project/executor:debug - shell-builder
entrypoint: [""]
variables: variables:
TAG: $CI_COMMIT_BRANCH TAG: $CI_COMMIT_SHA
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
- cd controller/
- TAG=${TAG//\//-} - 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: [] needs: []
build-testing-image: build-testing-image:
...@@ -24,15 +20,9 @@ build-testing-image: ...@@ -24,15 +20,9 @@ build-testing-image:
BUILDARGS: -race BUILDARGS: -race
- when: always - when: always
script: script:
- /kaniko/executor - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
--cache=true - docker build -t "$GOSDN_TESTING_IMAGE" -f "${CI_PROJECT_DIR}/controller/Dockerfile" --target "installer" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "BUILDARGS=$BUILDARGS" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" .
--context "$CI_PROJECT_DIR" - docker push "$GOSDN_TESTING_IMAGE"
--dockerfile "Dockerfile"
--build-arg "GOLANG_VERSION=$GOLANG_VERSION"
--build-arg "BUILDARGS=$BUILDARGS"
--build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/"
--destination "$GOSDN_TESTING_IMAGE"
--target "installer"
<<: *build <<: *build
build-image: build-image:
...@@ -48,13 +38,7 @@ build-image: ...@@ -48,13 +38,7 @@ build-image:
BUILDARGS: -race BUILDARGS: -race
- when: always - when: always
script: script:
- /kaniko/executor - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
--cache=true - docker build -t "$CI_REGISTRY_IMAGE:$TAG" -f "${CI_PROJECT_DIR}/controller/Dockerfile" --target "installer" --build-arg "GOLANG_VERSION=$GOLANG_VERSION" --build-arg "BUILDARGS=$BUILDARGS" --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" .
--context "$CI_PROJECT_DIR" - docker push "$CI_REGISTRY_IMAGE:$TAG"
--dockerfile "Dockerfile"
--build-arg "GOLANG_VERSION=$GOLANG_VERSION"
--build-arg "BUILDARGS=$BUILDARGS"
--build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/"
--destination "$GOSDN_IMAGE"
--destination "$CI_REGISTRY_IMAGE:$TAG"
<<: *build <<: *build
...@@ -48,7 +48,7 @@ variables: ...@@ -48,7 +48,7 @@ variables:
containerlab:template:integration: containerlab:template:integration:
extends: .containerlab_template extends: .containerlab_template
variables: variables:
CLAB_TEMPLATE: "${CI_PROJECT_DIR}/test/containerlab/int01.clab.tmpl.yml" CLAB_TEMPLATE: "${CI_PROJECT_DIR}/controller/test/containerlab/int01.clab.tmpl.yml"
containerlab:deploy:integration: containerlab:deploy:integration:
extends: .containerlab_deploy extends: .containerlab_deploy
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
unit-test: unit-test:
script: script:
- cd controller
- make ci-unit-test - make ci-unit-test
after_script: after_script:
- go tool cover -func=coverage.out - go tool cover -func=coverage.out
...@@ -22,6 +23,7 @@ unit-test: ...@@ -22,6 +23,7 @@ unit-test:
controller-test: controller-test:
script: script:
- cd controller
- make ci-controller-test - make ci-controller-test
<<: *test <<: *test
...@@ -29,5 +31,5 @@ test-build: ...@@ -29,5 +31,5 @@ test-build:
artifacts: artifacts:
when: never when: never
script: script:
- GOOS=linux go build $BUILDARGS ./cmd/gosdn - make build
<<: *test <<: *test
FROM scratch ARG GOLANG_VERSION=1.18
ARG BUILDARGS
ARG $GITLAB_PROXY
FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-buster AS installer
WORKDIR /src/gosdn/controller
COPY go.* ./
RUN go mod download
FROM installer as builder
COPY ./controller ./
RUN make build
FROM scratch as gosdn
COPY artifacts/gosdn / COPY artifacts/gosdn /
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment