From 609ed3f4b9304d469b286732cdb6ecf72535ee49 Mon Sep 17 00:00:00 2001
From: Dobromir Palushev <dobromir@peaksandpies.com>
Date: Fri, 2 Sep 2022 21:40:02 +0200
Subject: [PATCH] switched to node alpine image for the tests

---
 .gitlab-ci.yml | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 94bdc94..c4bfe6c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -27,19 +27,32 @@ stages:
     - gcloud config set compute/zone ${GCP_COMPUTE_REGION}
     - gcloud container clusters get-credentials ${GCP_PROJECT_ID}-gke
 
-test-image:
+run-tests:
   stage: test
   tags:
-    - docker-privileged
-  image: docker:${DOCKER_VERSION}
-  services:
-    - name: docker:${DOCKER_VERSION}-dind
+    # - docker-privileged
+    - docker
+  # image: docker:${DOCKER_VERSION}
+  image:  node:16.17.0-alpine
+  # services:
+  #   - name: docker:${DOCKER_VERSION}-dind
   script:
-    - docker run -p 27017:27017 -d --name mongo-container --rm mongo:${MONGO_VERSION}
-    - docker build
-      --tag "${CONTAINER_TAG}-test"
-      --target=test
-      "./app"
+    # - docker run -p 27017:27017 -d --name mongo-container --rm mongo:${MONGO_VERSION}
+    # - docker build
+    #   --tag "${CONTAINER_TAG}-test"
+    #   --target=test
+    #   "./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 add  mongodb mongodb-tools
+    - 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:
     - docker stop mongo-container
     - docker images -a | grep "mongo" | awk '{print $3}' | xargs docker rmi --force
@@ -48,7 +61,7 @@ test-image:
 build-image:
   stage: build
   needs:
-    - 'test-image'
+    - 'run-tests'
   tags:
     - docker-privileged
   image: docker:${DOCKER_VERSION}
-- 
GitLab