From 6f825500ea320fa3b27677daae0efe22b454ed77 Mon Sep 17 00:00:00 2001
From: Ilia Eriomenco <ilia.eriomenco@endava.com>
Date: Mon, 29 Mar 2021 13:33:12 +0300
Subject: [PATCH] ci: added services in eLife pipeline test-chrome section

---
 ._gitlab-ci.elife.yml | 273 ------------------------------------------
 .gitlab-ci.elife.yml  |   4 +-
 2 files changed, 2 insertions(+), 275 deletions(-)
 delete mode 100644 ._gitlab-ci.elife.yml

diff --git a/._gitlab-ci.elife.yml b/._gitlab-ci.elife.yml
deleted file mode 100644
index 9b924f5105..0000000000
--- a/._gitlab-ci.elife.yml
+++ /dev/null
@@ -1,273 +0,0 @@
-variables:
-  IMAGE_ORG: kotahi
-  IMAGE_NAME: kotahi
-  ELIFE_SERVER_IP: 54.87.88.111
-
-stages:
-  - build
-  - deploy
-  - test
-
-build:
-  image: docker:20.10.5
-  variables:
-    DOCKER_BUILDKIT: 1
-  services:
-    - docker:20.10.5-dind
-  stage: build
-  before_script:
-    - cp app/brand-instances-configs/elife.json app/brandConfig.json
-  script:
-    - |
-      if [ -z "$DOCKERHUB_USERNAME_ELIFE" ] || [ -z "$DOCKERHUB_PASSWORD_ELIFE" ]; then echo "Not pushing" && exit 0; fi
-      docker login -u $DOCKERHUB_USERNAME_ELIFE -p $DOCKERHUB_PASSWORD_ELIFE
-      docker pull $IMAGE_ORG/$IMAGE_NAME:latest || true
-      docker build \
-      --file ./Dockerfile-production \
-      --cache-from $CI_REGISTRY_IMAGE:latest \
-      --tag $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA \
-      --tag $IMAGE_ORG/$IMAGE_NAME:latest .
-      docker build --file ./Dockerfile-ci --cache-from $IMAGE_ORG/$IMAGE_NAME-dev:latest --tag $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA --tag $IMAGE_ORG/$IMAGE_NAME-dev:latest .
-      docker push $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA
-      docker push $IMAGE_ORG/$IMAGE_NAME:latest
-      docker push $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA
-      docker push $IMAGE_ORG/$IMAGE_NAME-dev:latest
-
-deploy:
-  stage: deploy
-  image: docker:19.03.13
-  before_script:
-    - export SSH_KEY=$SSH_KEY_ELIFE
-    - export DOCKERHUB_USERNAME=$DOCKERHUB_USERNAME_ELIFE
-    - export DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD_ELIFE
-    - export IMAGE_ORG=$IMAGE_ORG
-    - export IMAGE_NAME=$IMAGE_NAME
-    - eval $(ssh-agent -s)
-    - echo "$SSH_KEY" | tr -d '\r' | ssh-add -
-    - mkdir -p ~/.ssh
-    - chmod 700 ~/.ssh
-    - ssh-keyscan $ELIFE_SERVER_IP >> ~/.ssh/known_hosts
-    - chmod 644 ~/.ssh/known_hosts
-  script:
-    - |
-      ssh ubuntu@$ELIFE_SERVER_IP "sudo docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD &&
-      sudo docker pull $IMAGE_ORG/$IMAGE_NAME:latest &&
-      sudo supervisorctl stop kotahi &&
-      cd /home/ubuntu/kotahi &&
-      sudo docker-compose down &&
-      sudo supervisorctl start kotahi"
-
-lint:
-  allow_failure: true
-  image: $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA
-  stage: test
-  variables:
-    GIT_STRATEGY: none
-  script:
-    - cd ${HOME}
-    - npm run lint
-
-.test_template: &run_test_template
-  image: $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA
-  stage: test
-  variables:
-    GIT_STRATEGY: none
-    # setup data for postgres image
-    POSTGRES_USER: kotahidev
-    POSTGRES_PASSWORD: kotahidev
-    # used by psql
-    PGUSER: kotahidev
-    PGPASSWORD: kotahidev
-    INSTANCE_NAME: elife
-  services:
-    - postgres
-
-.script_template: &run_script_template
-    - cd ${HOME}
-    - apt-get -y install postgresql-client
-    # this is needed for pgboss initial setup
-    - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-    # use the example env for tests
-    - cp .env.example .env
-    # specify host here else it confuses the linked postgres image
-    - POSTGRES_HOST=postgres yarn test:all:chrome:$TEST_ITEM
-    
-test-chrome:
-  <<: *run_test_template
-  variables:
-    TEST_ITEM: elife
-  script:
-    - *run_script_template
-
-# .test_template: &run_test_template
-#   image: $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA
-#   stage: test
-#   variables:
-#     GIT_STRATEGY: none
-#     # setup data for postgres image
-#     POSTGRES_USER: kotahidev
-#     POSTGRES_PASSWORD: kotahidev
-#     # used by psql
-#     PGUSER: kotahidev
-#     PGPASSWORD: kotahidev
-#     # this is used to ignore self signed certs
-#     START_SERVER_AND_TEST_INSECURE: 1
-#     INSTANCE_NAME: elife
-#   services:
-#     - postgres
-
-# #.script_template: &run_script_template
-# #    - cd ${HOME}
-# #    - apt-get -y install postgresql-client
-# #    # this is needed for pgboss initial setup
-# #    - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-# #    # use the example env for tests
-# #    - cp .env.example .env
-# #    - # specify host here else it confuses the linked postgres image
-# #    - POSTGRES_HOST=postgres yarn test:all:chrome:$TEST_ITEM
-
-# test-chrome:
-#   <<: *run_test_template
-#   variables:
-#     TEST_ITEM: elife
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:chrome:elife
-
-# test-chrome-samsung:
-#   <<: *run_test_template
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:chrome:elife:samsung
-
-# test-chrome-samsung-tablet:
-#   <<: *run_test_template
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:chrome:elife:samsung:tablet
-
-# test-chrome-iPhone:
-#   <<: *run_test_template
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:chrome:elife:iPhone
-
-# test-chrome-iPhone-tablet:
-#   <<: *run_test_template
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:chrome:elife:iPhone:tablet
-
-# test-chrome-hd-laptop:
-#   <<: *run_test_template
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:chrome:elife:hd:laptop
-
-# test-firefox:
-#   <<: *run_test_template
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:firefox:elife
-
-# test-firefox-samsung:
-#   <<: *run_test_template
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:firefox:elife:samsung
-
-# test-firefox-samsung-tablet:
-#   <<: *run_test_template
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:firefox:elife:samsung:tablet
-
-# test-firefox-iPhone:
-#   <<: *run_test_template
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:firefox:elife:iPhone
-
-# test-firefox-iPhone-tablet:
-#   <<: *run_test_template
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:firefox:elife:iPhone:tablet
-
-# test-firefox-hd-laptop:
-#   <<: *run_test_template
-#   script:
-#     - cd ${HOME}
-#     - apt-get -y install postgresql-client
-#     # this is needed for pgboss initial setup
-#     - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
-#     # use the example env for tests
-#     - cp .env.example .env
-#     # specify host here else it confuses the linked postgres image
-#     - POSTGRES_HOST=postgres yarn test:all:firefox:elife:hd:laptop
\ No newline at end of file
diff --git a/.gitlab-ci.elife.yml b/.gitlab-ci.elife.yml
index 842ff1d2a7..33367b96f5 100644
--- a/.gitlab-ci.elife.yml
+++ b/.gitlab-ci.elife.yml
@@ -80,8 +80,6 @@ lint:
     PGUSER: kotahidev
     PGPASSWORD: kotahidev
     INSTANCE_NAME: elife
-  services:
-    - postgres
 
 .script_template: &run_script_template
     - cd ${HOME}
@@ -99,6 +97,8 @@ test-chrome:
     TEST_ITEM: "chrome:elife"
   script:
     - *run_script_template
+  services:
+    - postgres
 
 # test-chrome-samsung:
 #   <<: *run_test_template
-- 
GitLab