<commit_before>image:
  name: ruby:2.5.3

variables:
  GOVUK_APP_DOMAIN: test
  POSTGRES_DB: tariffadmin_test
  DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB"
  REDIS_URL: redis://redis:6379

services:
  - name: redis:3.2.11
  - name: postgres:9.6-alpine
    alias: postgres

stages:
  - test
  - deploy

test:
  stage: test
  before_script:
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan gitlab.bitzesty.com > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
    - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
    - chmod 400 ~/.ssh/id_rsa
    - apt-get update -qy
    - apt-get install -y build-essential postgresql libpq-dev nodejs rake
    - gem install bundler
    - bundle install --jobs 4 --retry 3 --path vendor
    - RAILS_ENV=test bundle exec rake db:migrate --trace
  script:
    - RAILS_ENV=test RAILS_DISABLE_TEST_LOG=true bundle exec rspec spec/ --tag '~skip_ci' --profile 10 --format RspecJunitFormatter --out rspec.xml --format progress
  artifacts:
    reports:
      junit: rspec.xml
  cache:
    key: gems-cache
    paths:
      - vendor/ruby

code_quality:
  image: docker:stable
  variables:
    DOCKER_DRIVER: overlay2
  allow_failure: true
  services:
    - docker:stable-dind
  script:
    - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
    - docker run
        --env SOURCE_CODE="$PWD"
        --volume "$PWD":/code
        --volume /var/run/docker.sock:/var/run/docker.sock
        "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
  artifacts:
    paths:
      - gl-code-quality-report.json

deploy_dev:
  stage: deploy
  script:
    - curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&source=github'
    - dpkg -i cf-cli_amd64.deb
    - cf -v
    - curl -v -L -o autopilot https://github.com/contraband/autopilot/releases/download/0.0.3/autopilot-linux
    - chmod +x autopilot
    - cf install-plugin autopilot -f
    - CF_SPACE=development CF_APP=tariff-admin-dev CF_APP_WORKER=tariff-admin-worker-dev ./bin/deploy
  only:
    - master

deploy_staging:
  stage: deploy
  script:
    - curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&source=github'
    - dpkg -i cf-cli_amd64.deb
    - cf -v
    - curl -v -L -o autopilot https://github.com/contraband/autopilot/releases/download/0.0.3/autopilot-linux
    - chmod +x autopilot
    - cf install-plugin autopilot -f
    - CF_SPACE=staging CF_APP=tariff-admin-staging CF_APP_WORKER=tariff-admin-worker-staging ./bin/deploy
  only:
    - staging

deploy_production:
  stage: deploy
  script:
    - curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&source=github'
    - dpkg -i cf-cli_amd64.deb
    - cf -v
    - curl -v -L -o autopilot https://github.com/contraband/autopilot/releases/download/0.0.3/autopilot-linux
    - chmod +x autopilot
    - cf install-plugin autopilot -f
    - CF_SPACE=production CF_APP=tariff-admin-production CF_APP_WORKER=tariff-admin-worker-production ./bin/deploy
  when: manual
  only:
    - production<commit_msg>Switch to Kubernetes CI Runner<commit_after>image:
  name: circleci/ruby:2.5-node-browsers

variables:
  GOVUK_APP_DOMAIN: test
  POSTGRES_DB: tariffadmin_test
  DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/$POSTGRES_DB"
  REDIS_URL: redis://localhost:6379

services:
  - name: redis:3.2.11
  - name: postgres:9.6-alpine
    alias: postgres

stages:
  - test
  - deploy

test:
  stage: test
  before_script:
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan gitlab.bitzesty.com > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
    - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
    - chmod 400 ~/.ssh/id_rsa
    - sudo apt-get update -qy
    - sudo apt-get install -y build-essential postgresql libpq-dev nodejs rake
    - bundle install --jobs 4 --retry 3 --path vendor
    - RAILS_ENV=test bundle exec rake db:migrate --trace
  script:
    - RAILS_ENV=test RAILS_DISABLE_TEST_LOG=true bundle exec rspec spec/ --tag '~skip_ci' --profile 10 --format RspecJunitFormatter --out rspec.xml --format progress
  artifacts:
    reports:
      junit: rspec.xml
  cache:
    key: gems-cache
    paths:
      - vendor/ruby

code_quality:
  image: docker:stable
  variables:
    DOCKER_DRIVER: overlay2
  allow_failure: true
  services:
    - docker:stable-dind
  script:
    - export DOCKER_HOST=tcp://localhost:2375
    - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
    - docker run
        --env SOURCE_CODE="$PWD"
        --volume "$PWD":/code
        --volume /var/run/docker.sock:/var/run/docker.sock
        "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
  artifacts:
    paths:
      - gl-code-quality-report.json

deploy_dev:
  stage: deploy
  script:
    - curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&source=github'
    - sudo dpkg -i cf-cli_amd64.deb
    - cf -v
    - curl -v -L -o autopilot https://github.com/contraband/autopilot/releases/download/0.0.3/autopilot-linux
    - chmod +x autopilot
    - cf install-plugin autopilot -f
    - CF_SPACE=development CF_APP=tariff-admin-dev CF_APP_WORKER=tariff-admin-worker-dev ./bin/deploy
  only:
    - master

deploy_staging:
  stage: deploy
  script:
    - curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&source=github'
    - sudo dpkg -i cf-cli_amd64.deb
    - cf -v
    - curl -v -L -o autopilot https://github.com/contraband/autopilot/releases/download/0.0.3/autopilot-linux
    - chmod +x autopilot
    - cf install-plugin autopilot -f
    - CF_SPACE=staging CF_APP=tariff-admin-staging CF_APP_WORKER=tariff-admin-worker-staging ./bin/deploy
  only:
    - staging

deploy_production:
  stage: deploy
  script:
    - curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&source=github'
    - sudo dpkg -i cf-cli_amd64.deb
    - cf -v
    - curl -v -L -o autopilot https://github.com/contraband/autopilot/releases/download/0.0.3/autopilot-linux
    - chmod +x autopilot
    - cf install-plugin autopilot -f
    - CF_SPACE=production CF_APP=tariff-admin-production CF_APP_WORKER=tariff-admin-worker-production ./bin/deploy
  when: manual
  only:
    - production
{'fraction_non_alphanumeric': 0.136053412462908, 'fraction_numerical': 0.01943620178041543, 'mean_word_length': 2.701812191103789, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2827225', 'n_tokens_mistral': 2738, 'n_tokens_neox': 2542, 'n_words': 507}