amatriain/openreader

View on GitHub
.gitlab-ci.yml

Summary

Maintainability
Test Coverage
default:
  image: ruby:2.7.2

variables:
  RAILS_ENV: ci

cache:
  key: default
  paths:
    - 'FeedBunch-app/vendor/gems'
    - 'apt-cache'
    - 'geckodriver-cache'

stages:
  - install_dependencies
  - static_analysis
  - setup_database
  - test
  - build_images

install_deps:
  stage: install_dependencies
  script:
    # Install nodejs and firefox
    - apt-get update -qy
    - apt-get -o dir::cache::archives="apt-cache" install -y nodejs iceweasel

    # Install geckodriver
    - mkdir -p geckodriver-cache
    - cd geckodriver-cache
    - GECKODRIVER_VERSION=$(curl https://github.com/mozilla/geckodriver/releases/latest | grep -Po 'v[0-9]+.[0-9]+.[0-9]+')
    - wget --no-clobber https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz
    - tar -zxf geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz -C /usr/local/bin
    - chmod +x /usr/local/bin/geckodriver

    # Install gems in bundle
    - cd ../FeedBunch-app
    - bundle config set deployment 'true'
    - bundle config set path 'vendor/gems'
    - bundle config set without 'development production'
    - bundle install

bundle_audit:
  stage: static_analysis
  script:
    # Install gems in bundle
    - cd FeedBunch-app
    - bundle config set deployment 'true'
    - bundle config set path 'vendor/gems'
    - bundle config set without 'development production'
    - bundle install

    # Run bundle-audit
    - bundle exec bundle-audit update
    - bundle exec bundle-audit check

brakeman:
  stage: static_analysis
  script:
    # Install gems in bundle
    - cd FeedBunch-app
    - bundle config set deployment 'true'
    - bundle config set path 'vendor/gems'
    - bundle config set without 'development production'
    - bundle install

    # Run brakeman
    - bundle exec brakeman -z --no-pager

load_db:
  stage: setup_database
  script:
    # Install nodejs
    - apt-get update -qy
    - apt-get -o dir::cache::archives="apt-cache" install -y nodejs

    # Install gems in bundle
    - cd FeedBunch-app
    - bundle config set deployment 'true'
    - bundle config set path 'vendor/gems'
    - bundle config set without 'development production'
    - bundle install

    # Copy config files
    - cp config/secrets_ci.yml config/secrets.yml
    - cp config/database.yml.ci config/database.yml

    # Load database
    - bundle exec rake db:schema:load

unit_tests:
  stage: test
  variables:
    TEST_SUITE: unit
  script:
    # Install nodejs
    - apt-get update -qy
    - apt-get -o dir::cache::archives="apt-cache" install -y nodejs

    # Install gems in bundle
    - cd FeedBunch-app
    - bundle config set deployment 'true'
    - bundle config set path 'vendor/gems'
    - bundle config set without 'development production'
    - bundle install

    # Copy config files
    - cp config/secrets_ci.yml config/secrets.yml
    - cp config/database.yml.ci config/database.yml

    # Run unit tests
    - bundle exec rake spec:ci

acceptance_tests_1:
  stage: test
  variables:
    TEST_SUITE: acceptance_1
  script:
    # Install nodejs and firefox
    - apt-get update -qy
    - apt-get -o dir::cache::archives="apt-cache" install -y nodejs iceweasel

    # Install geckodriver
    - mkdir -p geckodriver-cache
    - cd geckodriver-cache
    - GECKODRIVER_VERSION=$(curl https://github.com/mozilla/geckodriver/releases/latest | grep -Po 'v[0-9]+.[0-9]+.[0-9]+')
    - wget --no-clobber https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz
    - tar -zxf geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz -C /usr/local/bin
    - chmod +x /usr/local/bin/geckodriver

    # Install gems in bundle
    - cd ../FeedBunch-app
    - bundle config set deployment 'true'
    - bundle config set path 'vendor/gems'
    - bundle config set without 'development production'
    - bundle install

    # Copy config files
    - cp config/secrets_ci.yml config/secrets.yml
    - cp config/database.yml.ci config/database.yml

    # Run acceptance tests
    - bundle exec rake spec:ci

acceptance_tests_2:
  stage: test
  variables:
    TEST_SUITE: acceptance_2
  script:
    # Install nodejs and firefox
    - apt-get update -qy
    - apt-get -o dir::cache::archives="apt-cache" install -y nodejs iceweasel

    # Install geckodriver
    - mkdir -p geckodriver-cache
    - cd geckodriver-cache
    - GECKODRIVER_VERSION=$(curl https://github.com/mozilla/geckodriver/releases/latest | grep -Po 'v[0-9]+.[0-9]+.[0-9]+')
    - wget --no-clobber https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz
    - tar -zxf geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz -C /usr/local/bin
    - chmod +x /usr/local/bin/geckodriver

    # Install gems in bundle
    - cd ../FeedBunch-app
    - bundle config set deployment 'true'
    - bundle config set path 'vendor/gems'
    - bundle config set without 'development production'
    - bundle install

    # Copy config files
    - cp config/secrets_ci.yml config/secrets.yml
    - cp config/database.yml.ci config/database.yml

    # Run acceptance tests
    - bundle exec rake spec:ci

acceptance_tests_3:
  stage: test
  variables:
    TEST_SUITE: acceptance_3
  script:
    # Install nodejs and firefox
    - apt-get update -qy
    - apt-get -o dir::cache::archives="apt-cache" install -y nodejs iceweasel

    # Install geckodriver
    - mkdir -p geckodriver-cache
    - cd geckodriver-cache
    - GECKODRIVER_VERSION=$(curl https://github.com/mozilla/geckodriver/releases/latest | grep -Po 'v[0-9]+.[0-9]+.[0-9]+')
    - wget --no-clobber https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz
    - tar -zxf geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz -C /usr/local/bin
    - chmod +x /usr/local/bin/geckodriver

    # Install gems in bundle
    - cd ../FeedBunch-app
    - bundle config set deployment 'true'
    - bundle config set path 'vendor/gems'
    - bundle config set without 'development production'
    - bundle install

    # Copy config files
    - cp config/secrets_ci.yml config/secrets.yml
    - cp config/database.yml.ci config/database.yml

    # Run acceptance tests
    - bundle exec rake spec:ci

acceptance_tests_4:
  stage: test
  variables:
    TEST_SUITE: acceptance_4
  script:
    # Install nodejs and firefox
    - apt-get update -qy
    - apt-get -o dir::cache::archives="apt-cache" install -y nodejs iceweasel

    # Install geckodriver
    - mkdir -p geckodriver-cache
    - cd geckodriver-cache
    - GECKODRIVER_VERSION=$(curl https://github.com/mozilla/geckodriver/releases/latest | grep -Po 'v[0-9]+.[0-9]+.[0-9]+')
    - wget --no-clobber https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz
    - tar -zxf geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz -C /usr/local/bin
    - chmod +x /usr/local/bin/geckodriver

    # Install gems in bundle
    - cd ../FeedBunch-app
    - bundle config set deployment 'true'
    - bundle config set path 'vendor/gems'
    - bundle config set without 'development production'
    - bundle install

    # Copy config files
    - cp config/secrets_ci.yml config/secrets.yml
    - cp config/database.yml.ci config/database.yml

    # Run acceptance tests
    - bundle exec rake spec:ci

build_webapp_image:
  image: docker:19.03.12
  stage: build_images
  variables:
    DOCKER_TLS_CERTDIR: "/certs"
    FEEDBUNCH_TAG: ${CI_COMMIT_TAG}
  services:
    - docker:19.03.12-dind
  before_script:
    - echo "$DOCKER_REGISTRY_PASSWORD" | docker login --username="$DOCKER_REGISTRY_USER" --password-stdin
  script:
    - cd FeedBunch-docker/FeedBunch-webapp
    - docker build --tag=amatriain/feedbunch-webapp:$CI_COMMIT_TAG --tag=amatriain/feedbunch-webapp:latest .
    - docker push amatriain/feedbunch-webapp:$CI_COMMIT_TAG
    - docker push amatriain/feedbunch-webapp:latest
  rules:
    - if: $CI_COMMIT_TAG

build_background_image:
  image: docker:19.03.12
  stage: build_images
  variables:
    DOCKER_TLS_CERTDIR: "/certs"
    FEEDBUNCH_TAG: ${CI_COMMIT_TAG}
  services:
    - docker:19.03.12-dind
  before_script:
    - echo "$DOCKER_REGISTRY_PASSWORD" | docker login --username="$DOCKER_REGISTRY_USER" --password-stdin
  script:
    - cd FeedBunch-docker/FeedBunch-background
    - docker build --tag=amatriain/feedbunch-background:$CI_COMMIT_TAG --tag=amatriain/feedbunch-background:latest .
    - docker push amatriain/feedbunch-background:$CI_COMMIT_TAG
    - docker push amatriain/feedbunch-background:latest
  rules:
    - if: $CI_COMMIT_TAG

build_redis-cache_image:
  image: docker:19.03.12
  stage: build_images
  variables:
    DOCKER_TLS_CERTDIR: "/certs"
    IMAGE_TAG: "1.0.0"
  services:
    - docker:19.03.12-dind
  before_script:
    - echo "$DOCKER_REGISTRY_PASSWORD" | docker login --username="$DOCKER_REGISTRY_USER" --password-stdin
  script:
    - cd FeedBunch-docker/FeedBunch-redis-cache
    - docker build --tag=amatriain/feedbunch-redis-cache:$IMAGE_TAG --tag=amatriain/feedbunch-redis-cache:latest .
    - docker push amatriain/feedbunch-redis-cache:$IMAGE_TAG
    - docker push amatriain/feedbunch-redis-cache:latest
  rules:
    - if: $CI_COMMIT_TAG

build_redis-sidekiq_image:
  image: docker:19.03.12
  stage: build_images
  variables:
    DOCKER_TLS_CERTDIR: "/certs"
    IMAGE_TAG: "1.0.0"
  services:
    - docker:19.03.12-dind
  before_script:
    - echo "$DOCKER_REGISTRY_PASSWORD" | docker login --username="$DOCKER_REGISTRY_USER" --password-stdin
  script:
    - cd FeedBunch-docker/FeedBunch-redis-sidekiq
    - docker build --tag=amatriain/feedbunch-redis-sidekiq:$IMAGE_TAG --tag=amatriain/feedbunch-redis-sidekiq:latest .
    - docker push amatriain/feedbunch-redis-sidekiq:$IMAGE_TAG
    - docker push amatriain/feedbunch-redis-sidekiq:latest
  rules:
    - if: $CI_COMMIT_TAG

build_cron_image:
  image: docker:19.03.12
  stage: build_images
  variables:
    DOCKER_TLS_CERTDIR: "/certs"
    IMAGE_TAG: "1.0.0"
  services:
    - docker:19.03.12-dind
  before_script:
    - echo "$DOCKER_REGISTRY_PASSWORD" | docker login --username="$DOCKER_REGISTRY_USER" --password-stdin
  script:
    - cd FeedBunch-docker/FeedBunch-cron
    - docker build --tag=amatriain/feedbunch-cron:$IMAGE_TAG --tag=amatriain/feedbunch-cron:latest .
    - docker push amatriain/feedbunch-cron:$IMAGE_TAG
    - docker push amatriain/feedbunch-cron:latest
  rules:
    - if: $CI_COMMIT_TAG