Skip to content
Snippets Groups Projects

updated logic of the test-job

Closed Dobromir Palushev requested to merge just-a-test into main
1 file
+ 1
4
Compare changes
  • Side-by-side
  • Inline
+ 27
10
@@ -7,9 +7,10 @@ workflow:
@@ -7,9 +7,10 @@ workflow:
variables:
variables:
DOCKER_VERSION: '20.10.17'
DOCKER_VERSION: '20.10.17'
K8S_VERSION: '1.24'
MONGO_VERSION: '4.4'
GOOGLE_CLOUD_SDK_IMAGE_VERSION: '400.0.0'
K8S_NAMESPACE: 'todoapp-devops'
K8S_NAMESPACE: 'todoapp-devops'
 
GOOGLE_CLOUD_SDK_IMAGE_VERSION: '400.0.0'
 
GCP_COMPUTE_REGION: 'europe-west4a'
CONTAINER_TAG: '${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}-${CI_COMMIT_SHORT_SHA}'
CONTAINER_TAG: '${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}-${CI_COMMIT_SHORT_SHA}'
stages:
stages:
@@ -26,27 +27,46 @@ stages:
@@ -26,27 +27,46 @@ stages:
- gcloud config set compute/zone ${GCP_COMPUTE_REGION}
- gcloud config set compute/zone ${GCP_COMPUTE_REGION}
- gcloud container clusters get-credentials ${GCP_PROJECT_ID}-gke
- gcloud container clusters get-credentials ${GCP_PROJECT_ID}-gke
test-image:
run-tests:
stage: test
stage: test
tags:
tags:
- docker-priviliged
- docker-privileged
 
# - docker
image: docker:${DOCKER_VERSION}
image: docker:${DOCKER_VERSION}
 
# image: node:16.17.0-alpine
services:
services:
- name: docker:${DOCKER_VERSION}-dind
- name: docker:${DOCKER_VERSION}-dind
script:
script:
 
- docker run -p 27017:27017 -d --name mongo-container --rm --add-host=host.docker.internal:host-gateway mongo:${MONGO_VERSION}
- docker build
- docker build
--tag "${CONTAINER_TAG}-test"
--tag "${CONTAINER_TAG}-test"
--target=test
--target=test
"./"
--add-host=host.docker.internal:host-gateway
 
"./app"
 
# - echo ‘http://dl-cdn.alpinelinux.org/alpine/v3.6/main’ >> /etc/apk/repositories
 
# - echo ‘http://dl-cdn.alpinelinux.org/alpine/v3.6/community’ >> /etc/apk/repositories
 
# - apk update
 
# - apk add mongodb mongodb-tools
 
# - mkdir -p /data/db/
 
# - mongod --config "./app/server/dev.mongo.conf"
 
# - cd "./app/client"
 
# - npm ci --no-audit --no-fund
 
# - npm run test
 
# - cd "../server"
 
# - npm ci --no-audit --no-fund
 
# - MONGODB_URL=mongodb://localhost:27017/todo-app JWT_SECRET=a-big-secret npm run test
 
# - jest --ci
after_script:
after_script:
 
- docker stop mongo-container
 
- docker images -a | grep "mongo" | awk '{print $3}' | xargs docker rmi --force
- docker image rm --force "${CONTAINER_TAG}-test"
- docker image rm --force "${CONTAINER_TAG}-test"
build-image:
build-image:
stage: build
stage: build
needs:
needs:
- 'test-image'
- 'run-tests'
tags:
tags:
- docker-priviliged
- docker-privileged
image: docker:${DOCKER_VERSION}
image: docker:${DOCKER_VERSION}
services:
services:
- name: docker:${DOCKER_VERSION}-dind
- name: docker:${DOCKER_VERSION}-dind
@@ -67,9 +87,6 @@ build-image:
@@ -67,9 +87,6 @@ build-image:
create-release_image:
create-release_image:
stage: release
stage: release
rules:
- if: $CI_COMMIT_REF_NAME =~ /main/
when: 'always'
tags:
tags:
- docker-privileged
- docker-privileged
image: docker:${DOCKER_VERSION}
image: docker:${DOCKER_VERSION}
Loading