Commit 2473416c authored by Alexander Jajzler's avatar Alexander Jajzler
Browse files

CI: Run only test's

parent 6e3419ca
......@@ -3,94 +3,94 @@ variables:
stages:
- test
- analyze
- build
- deploy
.build_template: &build_template
stage: build
services:
- name: docker:19.03.1-dind
alias: docker
variables:
DOCKER_TLS_CERTDIR: ""
tags:
- docker-compose
artifacts:
expire_in: 2 mins
paths:
- variables
- private_key
.docker_push_template: &docker_push |
docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
docker build -t $CI_IMAGE_NAME:$VERSION .
docker push "$CI_IMAGE_NAME:$VERSION"
.staging_server_env_template: &staging_server_env |
echo "export CI_CONTAINER_INSTANCE_NAME=$CI_CONTAINER_INSTANCE_NAME" >> variables
echo "export SSH_URL=$STAGING_BACKEND_URL" >> variables
echo "export SSH_CMD=$STAGING_SSH" >> variables
echo "export VERSION=$VERSION" >> variables
echo "export SERVICE_NAME=$SERVICE_NAME" >> variables
echo "$STAGING_SSH_PRIVATE_KEY" >> private_key
.production_server_env_template: &production_server_env |
echo "export CI_CONTAINER_INSTANCE_NAME=$CI_CONTAINER_INSTANCE_NAME" >> variables
echo "export SSH_URL=$PRODUCTION_BACKEND_URL" >> variables
echo "export SSH_CMD=$PRODUCTION_SSH" >> variables
echo "export VERSION=$VERSION" >> variables
echo "export SERVICE_NAME=$SERVICE_NAME" >> variables
echo "$PRODUCTION_SSH_PRIVATE_KEY" >> private_key
.server_deploy_template: &server_deploy |
source variables
eval $(ssh-agent -s)
mkdir ~/.ssh
ssh-keyscan "$SSH_URL" >> ~/.ssh/known_hosts
ssh-add <(cat private_key)
build_master:
<<: *build_template
only:
- master
environment:
name: Master
variables:
VERSION: 2.0.0
SERVICE_NAME: master
CI_CONTAINER_INSTANCE_NAME: arsnova-click-backend-master
script:
- *production_server_env
- *docker_push
build_staging:
<<: *build_template
only:
- staging
environment:
name: Staging
variables:
VERSION: 2.0.0-staging
SERVICE_NAME: staging
CI_CONTAINER_INSTANCE_NAME: arsnova-click-backend-staging
script:
- *staging_server_env
- *docker_push
build_beta:
<<: *build_template
only:
- beta
environment:
name: Beta
variables:
VERSION: 2.0.0-beta
SERVICE_NAME: beta
CI_CONTAINER_INSTANCE_NAME: arsnova-click-backend-beta
script:
- *staging_server_env
- *docker_push
# - analyze
# - build
# - deploy
# .build_template: &build_template
# stage: build
# services:
# - name: docker:19.03.1-dind
# alias: docker
# variables:
# DOCKER_TLS_CERTDIR: ""
# tags:
# - docker-compose
# artifacts:
# expire_in: 2 mins
# paths:
# - variables
# - private_key
# .docker_push_template: &docker_push |
# docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# docker build -t $CI_IMAGE_NAME:$VERSION .
# docker push "$CI_IMAGE_NAME:$VERSION"
# .staging_server_env_template: &staging_server_env |
# echo "export CI_CONTAINER_INSTANCE_NAME=$CI_CONTAINER_INSTANCE_NAME" >> variables
# echo "export SSH_URL=$STAGING_BACKEND_URL" >> variables
# echo "export SSH_CMD=$STAGING_SSH" >> variables
# echo "export VERSION=$VERSION" >> variables
# echo "export SERVICE_NAME=$SERVICE_NAME" >> variables
# echo "$STAGING_SSH_PRIVATE_KEY" >> private_key
# .production_server_env_template: &production_server_env |
# echo "export CI_CONTAINER_INSTANCE_NAME=$CI_CONTAINER_INSTANCE_NAME" >> variables
# echo "export SSH_URL=$PRODUCTION_BACKEND_URL" >> variables
# echo "export SSH_CMD=$PRODUCTION_SSH" >> variables
# echo "export VERSION=$VERSION" >> variables
# echo "export SERVICE_NAME=$SERVICE_NAME" >> variables
# echo "$PRODUCTION_SSH_PRIVATE_KEY" >> private_key
# .server_deploy_template: &server_deploy |
# source variables
# eval $(ssh-agent -s)
# mkdir ~/.ssh
# ssh-keyscan "$SSH_URL" >> ~/.ssh/known_hosts
# ssh-add <(cat private_key)
# build_master:
# <<: *build_template
# only:
# - master
# environment:
# name: Master
# variables:
# VERSION: 2.0.0
# SERVICE_NAME: master
# CI_CONTAINER_INSTANCE_NAME: arsnova-click-backend-master
# script:
# - *production_server_env
# - *docker_push
# build_staging:
# <<: *build_template
# only:
# - staging
# environment:
# name: Staging
# variables:
# VERSION: 2.0.0-staging
# SERVICE_NAME: staging
# CI_CONTAINER_INSTANCE_NAME: arsnova-click-backend-staging
# script:
# - *staging_server_env
# - *docker_push
# build_beta:
# <<: *build_template
# only:
# - beta
# environment:
# name: Beta
# variables:
# VERSION: 2.0.0-beta
# SERVICE_NAME: beta
# CI_CONTAINER_INSTANCE_NAME: arsnova-click-backend-beta
# script:
# - *staging_server_env
# - *docker_push
ts_lint:
stage: test
......@@ -119,53 +119,53 @@ npm_test:
- export NODE_ENV='test'
- node_modules/nyc/bin/nyc.js --reporter=text --reporter=lcov --report-dir=.lcov_output node_modules/mocha/bin/mocha
sonarqube:
stage: analyze
tags:
- nodejs
dependencies:
- npm_test
only:
- staging
script:
- npm i
- sonar-scanner -Dsonar.login=$SONAR_TOKEN -Dsonar.host.url=https://scm.thm.de/sonar/
deploy:
stage: deploy
only:
- staging
- beta
tags:
- ssh
script:
- *server_deploy
- ssh $SSH_CMD "docker pull $CI_IMAGE_NAME:$VERSION && docker rm -f $CI_CONTAINER_INSTANCE_NAME ; docker-compose -f /home/arsnova/arsnova-click-docker/docker-compose-backend.yml -p arsnova-click-backend up --no-deps -d $SERVICE_NAME && docker image prune -af"
deploy_master:
stage: deploy
only:
- master
tags:
- ssh
script:
- *server_deploy
- ssh $SSH_CMD "docker pull $CI_IMAGE_NAME:$VERSION && docker rm -f $CI_CONTAINER_INSTANCE_NAME ; docker-compose -f /root/docker-compose.yml up --no-deps -d backend && docker image prune -af"
sync_mirror:
stage: deploy
tags:
- git
when: always
allow_failure: true
dependencies: []
only:
- master
- staging
script:
- eval $(ssh-agent -s)
- mkdir ~/.ssh && echo "$SYNC_SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- ssh-add <(echo "$SYNC_SSH_PRIVATE_KEY")
- git clone --bare "$CI_REPOSITORY_URL" mirror.git
- cd mirror.git
- git push --mirror "$MIRROR_REPO"
# sonarqube:
# stage: analyze
# tags:
# - nodejs
# dependencies:
# - npm_test
# only:
# - staging
# script:
# - npm i
# - sonar-scanner -Dsonar.login=$SONAR_TOKEN -Dsonar.host.url=https://scm.thm.de/sonar/
# deploy:
# stage: deploy
# only:
# - staging
# - beta
# tags:
# - ssh
# script:
# - *server_deploy
# - ssh $SSH_CMD "docker pull $CI_IMAGE_NAME:$VERSION && docker rm -f $CI_CONTAINER_INSTANCE_NAME ; docker-compose -f /home/arsnova/arsnova-click-docker/docker-compose-backend.yml -p arsnova-click-backend up --no-deps -d $SERVICE_NAME && docker image prune -af"
# deploy_master:
# stage: deploy
# only:
# - master
# tags:
# - ssh
# script:
# - *server_deploy
# - ssh $SSH_CMD "docker pull $CI_IMAGE_NAME:$VERSION && docker rm -f $CI_CONTAINER_INSTANCE_NAME ; docker-compose -f /root/docker-compose.yml up --no-deps -d backend && docker image prune -af"
# sync_mirror:
# stage: deploy
# tags:
# - git
# when: always
# allow_failure: true
# dependencies: []
# only:
# - master
# - staging
# script:
# - eval $(ssh-agent -s)
# - mkdir ~/.ssh && echo "$SYNC_SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
# - ssh-add <(echo "$SYNC_SSH_PRIVATE_KEY")
# - git clone --bare "$CI_REPOSITORY_URL" mirror.git
# - cd mirror.git
# - git push --mirror "$MIRROR_REPO"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment