From 57e12db43e59c124a2e954a4a0029b1ce1b193ba Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Sat, 11 Apr 2020 16:38:47 +0300 Subject: [PATCH 1/5] Build with local docker images. Tests --- .gitlab-ci.yml | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c3cb567..e17a458 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,36 +7,55 @@ variables: ########################################################################################################## -### PIPELINE DEFINITION +## PIPELINE DEFINITION stages: - build + - test - release ########################################################################################################## -### BUILD SECTION +### COMMON SECTION +.common: &common + image: registry.cyberbrain.pw/docker/docker + services: + - registry.cyberbrain.pw/docker/dind + before_script: + - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY + +########################################################################################################## + +#### BUILD SECTION build: + <<: *common stage: build - image: docker:latest - services: - - docker:dind variables: GIT_DEPTH: 1 DIRECTORY: '.' - before_script: - - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY script: - docker build -t "${CI_REGISTRY_IMAGE}:temp-${CI_PIPELINE_IID}" -f "./${DIRECTORY}/Dockerfile" "./${DIRECTORY}" - docker push "${CI_REGISTRY_IMAGE}:temp-$CI_PIPELINE_IID" ########################################################################################################## -### RELEASE SECTION +#### TEST SECTION +test: + <<: *common + stage: test + image: "${CI_REGISTRY_IMAGE}:temp-$CI_PIPELINE_IID" + variables: + GIT_STRATEGY: "none" + GIT_DEPTH: 0 + script: + - ansible-lint --version + - ansible-lint . + +########################################################################################################## + +#### RELEASE SECTION release: + <<: *common stage: release - image: docker:latest - services: - - docker:dind variables: GIT_STRATEGY: "none" GIT_DEPTH: 0 @@ -44,8 +63,6 @@ release: - /^development$/ - /^staging$/ - /^master$/ - before_script: - - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY script: - export VERSION_OLD=temp-$CI_PIPELINE_IID - export VERSION_NEW=$CI_COMMIT_REF_SLUG -- GitLab From c7aedd5e45864fa3d700b2aac6439ac7b7ce492a Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Sat, 11 Apr 2020 16:43:49 +0300 Subject: [PATCH 2/5] Fix tests --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e17a458..ee6cb65 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,8 +47,8 @@ test: GIT_STRATEGY: "none" GIT_DEPTH: 0 script: - - ansible-lint --version - - ansible-lint . + - docker run --rm "${CI_REGISTRY_IMAGE}:temp-$CI_PIPELINE_IID" ansible-lint --version + - docker run --rm "${CI_REGISTRY_IMAGE}:temp-$CI_PIPELINE_IID" ansible-lint . ########################################################################################################## -- GitLab From c4486f97829605cf950f4d6a251ab4b846b6253a Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Sat, 11 Apr 2020 16:53:20 +0300 Subject: [PATCH 3/5] Fix tests 2 --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee6cb65..1aab624 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,7 +42,6 @@ build: test: <<: *common stage: test - image: "${CI_REGISTRY_IMAGE}:temp-$CI_PIPELINE_IID" variables: GIT_STRATEGY: "none" GIT_DEPTH: 0 -- GitLab From 9326d17d116e2b682dc27b872d721a4bb06e73d3 Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Sat, 11 Apr 2020 17:02:33 +0300 Subject: [PATCH 4/5] Fix tests 3 --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1aab624..abbbdca 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,6 +46,8 @@ test: GIT_STRATEGY: "none" GIT_DEPTH: 0 script: + - docker run --rm "${CI_REGISTRY_IMAGE}:temp-$CI_PIPELINE_IID" ansible --version + - docker run --rm "${CI_REGISTRY_IMAGE}:temp-$CI_PIPELINE_IID" ansible -m ping localhost - docker run --rm "${CI_REGISTRY_IMAGE}:temp-$CI_PIPELINE_IID" ansible-lint --version - docker run --rm "${CI_REGISTRY_IMAGE}:temp-$CI_PIPELINE_IID" ansible-lint . -- GitLab From 68ee3091077ab07b7bdbb2b72d7f66cb9f2af442 Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Sat, 11 Apr 2020 17:27:46 +0300 Subject: [PATCH 5/5] openssh-client --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bc864d6..2123f8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM pipelinecomponents/ansible-lint MAINTAINER Dmitriy Safronov ENV LANG C.UTF-8 -ARG DEPENDENCIES_RUNTIME="git" +ARG DEPENDENCIES_RUNTIME="git openssh-client" RUN apk add --no-cache $DEPENDENCIES_RUNTIME WORKDIR /opt/ansible -- GitLab