diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c3cb56765e1eb330d4001fc8a53c3df198c44394..3f57c7e88f2c164e155539243fc3008c438ecd35 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,36 +7,56 @@ 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 build --cache-from "${CI_REGISTRY_IMAGE}:latest" -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 + variables: + 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 . + +########################################################################################################## + +#### RELEASE SECTION release: + <<: *common stage: release - image: docker:latest - services: - - docker:dind variables: GIT_STRATEGY: "none" GIT_DEPTH: 0 @@ -44,8 +64,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 diff --git a/Dockerfile b/Dockerfile index bc864d684f71ef3bb3441324e6f4378336b7efd3..2123f8f5f2f6616c7c735c1540de6c729b03899c 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 diff --git a/README.md b/README.md index a41b6d47be1588f3e9ecdb3e538037b761c7d468..5f0b259ff0aae2e2ee299060a2f99740765fb71e 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# Ansible linter +# Ansible w/ linter