test ci
This commit is contained in:
parent
02a64f34ef
commit
d9b0cd4a25
|
@ -3,7 +3,6 @@ image: docker:20.10.22
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- build
|
- build
|
||||||
- push
|
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# TEST STAGE #
|
# 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-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"
|
- docker exec -t v3-auth-api sh -c "npm run test:integration:ci"
|
||||||
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
|
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 #
|
# BUILD STAGE #
|
||||||
|
@ -37,42 +39,14 @@ build:
|
||||||
before_script:
|
before_script:
|
||||||
- echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
|
- echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
|
||||||
script:
|
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 pull $CI_REGISTRY_IMAGE:latest || true
|
||||||
- >
|
- >
|
||||||
docker build
|
docker build
|
||||||
--pull
|
--pull
|
||||||
--cache-from $CI_REGISTRY_IMAGE:latest
|
--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
|
- docker push $CI_REGISTRY_IMAGE:latest
|
||||||
|
|
||||||
##############
|
|
||||||
# PUSH STAGE #
|
|
||||||
##############
|
|
||||||
|
|
||||||
push latest:
|
|
||||||
stage: push
|
|
||||||
variables:
|
|
||||||
GIT_STRATEGY: none
|
|
||||||
only:
|
only:
|
||||||
- main
|
- 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
|
|
||||||
|
|
Loading…
Reference in New Issue