<commit_before>stages:
  - static-test
  - integration-test
  - build
  - deploy

variables:
  POSTGRES_DB: zoe
  POSTGRES_USER: zoeuser
  POSTGRES_PASSWORD: <PASSWORD>
  ZOE_TEST_IMAGE: zoe:$CI_BUILD_REF
  ZOE_COMMON_OPTIONS: --debug --backend-swarm-url ${SWARM_URL} --deployment-name test${CI_BUILD_REF} --dbuser ${POSTGRES_USER} --dbhost postgres --dbport 5432 --dbname ${POSTGRES_DB} --dbpass ${POSTGRES_PASSWORD} --master-url tcp://localhost:4850 --auth-type text --proxy-type none --listen-port 5100 --workspace-base-path /tmp

#lint:
#  stage: static-test
#  image: python:3.4
#  script:
#    - pip install -r requirements.txt
#    - pip install -r requirements_tests.txt
#    - chmod 755 run_tests.sh && ./run_tests.sh
#
#SonarQube:
#  stage: static-test
#  image: zoerepo/sonar-scanner
#  variables:
#    SONAR_PROJECT_KEY: "zoe.devel"
#    SONAR_BRANCH: "$CI_BUILD_REF_NAME"
#    SONAR_PROJECT_NAME: "Zoe devel"
#    SONAR_PROJECT_VERSION: "$CI_BUILD_REF"
#    SONARQUBE_SERVER_URL: "$SONARQUBE_SERVER_URL"
#  script:
#    - /usr/bin/sonar-scanner-run.sh
#
##frontend-unittest:
##  stage: static-test
##  image: node:latest
##  script:
##    - cd zoe_fe
##    - npm install
##    - npm install -g @angular/cli
##    - ng test
#
#api-test:
#  stage: integration-test
#  services:
#    - postgres:9.3
#  image: python:3.4
#  before_script:
#    - pip install -r requirements.txt
#    - pip install -r requirements_tests.txt
#    - echo "admin,admin,admin" > zoepass.csv
#    - mkdir /tmp/test${CI_BUILD_REF}
#    - python3 create_db_tables.py ${ZOE_COMMON_OPTIONS}
#    - python3 zoe-api.py ${ZOE_COMMON_OPTIONS} --log-file zoe-api-${CI_BUILD_REF}.log &
#    - sleep 1
#    - python3 zoe-master.py ${ZOE_COMMON_OPTIONS} --log-file zoe-master-${CI_BUILD_REF}.log &
#    - sleep 1
#  script:
#    - cd tests
#    - coverage run -p basic_auth_success_test.py localhost:5100
#    - coverage run -p cookie_auth_success_test.py localhost:5100
#    - coverage combine
#    - coverage report
#  artifacts:
#    paths:
#      - zoe-api-${CI_BUILD_REF}.log
#      - zoe-master-${CI_BUILD_REF}.log
#      - tests
#
#images:
#  image: docker:latest
#  stage: build
#  before_script:
#    - mkdir -p /etc/docker/certs.d/$DOCKER_REGISTRY
#    - cp /registry-ca.crt /etc/docker/certs.d/$DOCKER_REGISTRY/ca.crt
#    - docker login -u gitlab-ci-runner -p $REGISTRY_PASSWORD $DOCKER_REGISTRY
#  script:
#    - docker build --pull -t ${DOCKER_REGISTRY}/ci/${ZOE_TEST_IMAGE} .
#    - docker push ${DOCKER_REGISTRY}/ci/${ZOE_TEST_IMAGE}
#  only:
#    - master
#
#docs:
#  stage: deploy
#  image: ${DOCKER_REGISTRY}/ci/${ZOE_TEST_IMAGE}
#  before_script:
#    - which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
#    - eval $(ssh-agent -s)
#    - ssh-add <(echo "$SSH_PRIVATE_KEY")
#    - mkdir -p ~/.ssh
#    - 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
#    - apt-get update -y && apt-get install rsync -y
#  script:
#    - sh ./build_docs.sh
#    - rsync -avz docs/_build/html/ ubuntu@${STAGING_IP}:${WEB_STAGING_PATH}/docs
#  environment:
#    name: staging
#  only:
#    - master

frontend:
  stage: deploy
  image: node:latest
  before_script:
    - which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
    - mkdir -p ~/.ssh
    - 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    - apt-get update -y && apt-get install rsync -y
  script:
    - rsync -avz . ubuntu@${STAGING_IP}:${ZOE_STAGING_PATH}
    - ssh ubuntu@${STAGING_IP} sudo pip install --upgrade -r /srv/zoe/requirements.txt
    - ssh ubuntu@${STAGING_IP} sudo supervisorctl restart zoe-api
    - ssh ubuntu@${STAGING_IP} sudo supervisorctl restart zoe-master
    - cd zoe_fe
    - npm install
    - npm install -g --save-dev @angular/cli
    - 'sed -i -e "s/cors: false,/cors: true,/" src/environments/environment.prod.ts'
    - 'sed -i -e "s/localhost/192.168.45.189/" src/environments/environment.prod.ts'
    - 'sed -i -e "s/\/0.6/\/0.7/" src/environments/environment.prod.ts'
    - ng build --env=prod --output-path=build/prod
    - rsync -avz build/prod/ ubuntu@${STAGING_IP}:${WEB_STAGING_PATH}
  environment:
    name: staging<commit_msg>Set endpoint in frontend configuration<commit_after>stages:
  - static-test
  - integration-test
  - build
  - deploy

variables:
  POSTGRES_DB: zoe
  POSTGRES_USER: zoeuser
  POSTGRES_PASSWORD: <PASSWORD>
  ZOE_TEST_IMAGE: zoe:$CI_BUILD_REF
  ZOE_COMMON_OPTIONS: --debug --backend-swarm-url ${SWARM_URL} --deployment-name test${CI_BUILD_REF} --dbuser ${POSTGRES_USER} --dbhost postgres --dbport 5432 --dbname ${POSTGRES_DB} --dbpass ${POSTGRES_PASSWORD} --master-url tcp://localhost:4850 --auth-type text --proxy-type none --listen-port 5100 --workspace-base-path /tmp

#lint:
#  stage: static-test
#  image: python:3.4
#  script:
#    - pip install -r requirements.txt
#    - pip install -r requirements_tests.txt
#    - chmod 755 run_tests.sh && ./run_tests.sh
#
#SonarQube:
#  stage: static-test
#  image: zoerepo/sonar-scanner
#  variables:
#    SONAR_PROJECT_KEY: "zoe.devel"
#    SONAR_BRANCH: "$CI_BUILD_REF_NAME"
#    SONAR_PROJECT_NAME: "Zoe devel"
#    SONAR_PROJECT_VERSION: "$CI_BUILD_REF"
#    SONARQUBE_SERVER_URL: "$SONARQUBE_SERVER_URL"
#  script:
#    - /usr/bin/sonar-scanner-run.sh
#
##frontend-unittest:
##  stage: static-test
##  image: node:latest
##  script:
##    - cd zoe_fe
##    - npm install
##    - npm install -g @angular/cli
##    - ng test
#
#api-test:
#  stage: integration-test
#  services:
#    - postgres:9.3
#  image: python:3.4
#  before_script:
#    - pip install -r requirements.txt
#    - pip install -r requirements_tests.txt
#    - echo "admin,admin,admin" > zoepass.csv
#    - mkdir /tmp/test${CI_BUILD_REF}
#    - python3 create_db_tables.py ${ZOE_COMMON_OPTIONS}
#    - python3 zoe-api.py ${ZOE_COMMON_OPTIONS} --log-file zoe-api-${CI_BUILD_REF}.log &
#    - sleep 1
#    - python3 zoe-master.py ${ZOE_COMMON_OPTIONS} --log-file zoe-master-${CI_BUILD_REF}.log &
#    - sleep 1
#  script:
#    - cd tests
#    - coverage run -p basic_auth_success_test.py localhost:5100
#    - coverage run -p cookie_auth_success_test.py localhost:5100
#    - coverage combine
#    - coverage report
#  artifacts:
#    paths:
#      - zoe-api-${CI_BUILD_REF}.log
#      - zoe-master-${CI_BUILD_REF}.log
#      - tests
#
#images:
#  image: docker:latest
#  stage: build
#  before_script:
#    - mkdir -p /etc/docker/certs.d/$DOCKER_REGISTRY
#    - cp /registry-ca.crt /etc/docker/certs.d/$DOCKER_REGISTRY/ca.crt
#    - docker login -u gitlab-ci-runner -p $REGISTRY_PASSWORD $DOCKER_REGISTRY
#  script:
#    - docker build --pull -t ${DOCKER_REGISTRY}/ci/${ZOE_TEST_IMAGE} .
#    - docker push ${DOCKER_REGISTRY}/ci/${ZOE_TEST_IMAGE}
#  only:
#    - master
#
#docs:
#  stage: deploy
#  image: ${DOCKER_REGISTRY}/ci/${ZOE_TEST_IMAGE}
#  before_script:
#    - which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
#    - eval $(ssh-agent -s)
#    - ssh-add <(echo "$SSH_PRIVATE_KEY")
#    - mkdir -p ~/.ssh
#    - 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
#    - apt-get update -y && apt-get install rsync -y
#  script:
#    - sh ./build_docs.sh
#    - rsync -avz docs/_build/html/ ubuntu@${STAGING_IP}:${WEB_STAGING_PATH}/docs
#  environment:
#    name: staging
#  only:
#    - master

frontend:
  stage: deploy
  image: node:latest
  before_script:
    - which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
    - mkdir -p ~/.ssh
    - 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    - apt-get update -y && apt-get install rsync -y
  script:
    - rsync -avz . ubuntu@${STAGING_IP}:${ZOE_STAGING_PATH}
    - ssh ubuntu@${STAGING_IP} sudo pip install --upgrade -r /srv/zoe/requirements.txt
    - ssh ubuntu@${STAGING_IP} sudo supervisorctl restart zoe-api
    - ssh ubuntu@${STAGING_IP} sudo supervisorctl restart zoe-master
    - cd zoe_fe
    - npm install
    - npm install -g --save-dev @angular/cli
    - 'sed -i -e "s/cors: false,/cors: true,/" src/environments/environment.prod.ts'
    - 'sed -i -e "s/apiEndpoint: .*,/apiEndpoint: http:\/\/192.168.45.189:5001\/api\/0.7/" src/environments/environment.prod.ts'
    - ng build --env=prod --output-path=build/prod
    - rsync -avz build/prod/ ubuntu@${STAGING_IP}:${WEB_STAGING_PATH}
  environment:
    name: staging
{'fraction_non_alphanumeric': 0.15574058871818927, 'fraction_numerical': 0.011727453969743168, 'mean_word_length': 2.942672214516875, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '53873', 'n_tokens_mistral': 3551, 'n_tokens_neox': 3356, 'n_words': 660}