From d9b0cd4a259f518ce5c55f67db8b54df829beaf1 Mon Sep 17 00:00:00 2001 From: sbriat Date: Tue, 4 Apr 2023 12:27:40 +0200 Subject: [PATCH] test ci --- .gitlab-ci.yml | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6038ab4..176ccdf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,6 @@ image: docker:20.10.22 stages: - test - build - - push ############## # TEST STAGE # @@ -22,6 +21,9 @@ test: - docker-compose -f docker-compose.ci.service.yml -p auth-service --env-file ci/.env.ci up -d - docker exec -t v3-auth-api sh -c "npm run test:integration:ci" coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/ + rules: + - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_COMMIT_MESSAGE =~ /--check/ || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + when: always ############### # BUILD STAGE # @@ -37,42 +39,14 @@ build: before_script: - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY script: - # fetches the latest image (not failing if image is not found) + - export VERSION=$(docker run --rm -v "$PWD":/usr/src/app:ro -w /usr/src/app node:slim node -p "require('./package.json').version") - docker pull $CI_REGISTRY_IMAGE:latest || true - > docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest - --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$VERSION $CI_REGISTRY_IMAGE:latest . - - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA - -############## -# PUSH STAGE # -############## - -push latest: - stage: push - variables: - GIT_STRATEGY: none + - docker push $CI_REGISTRY_IMAGE:latest only: - main - before_script: - - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - script: - - export VERSION=$(docker run --rm -v "$PWD":/usr/src/app:ro -w /usr/src/app node:slim node -p "require('./package.json').version") - - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA - - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$VERSION $CI_REGISTRY_IMAGE:latest - - docker push $CI_REGISTRY_IMAGE:latest -# push tag: -# stage: push -# variables: -# GIT_STRATEGY: none -# only: -# - tags -# before_script: -# - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY -# script: -# - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA -# - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME -# - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME