scottwillson/racing_on_rails

View on GitHub
.semaphore/semaphore.yml

Summary

Maintainability
Test Coverage
version: v1.0
name: CI tests
agent:
  machine:
    type: e1-standard-2
    os_image: ubuntu1804

global_job_config:
  secrets:
    - name: semaphore-github-obra
    - name: semaphore-github-registration-engine
    - name: semaphore_ssh_config

blocks:
  - name: "Bundle gems"
    task:
      jobs:
      - name: bundle gems
        commands:
          - sem-version ruby 3.2.1
          - checkout
          - git clone https://github.com/scottwillson/registration_engine_public_stub.git registration_engine
          - sudo apt-get install -y libmysqlclient-dev
          - cache restore gems-$SEMAPHORE_GIT_BRANCH-$(checksum Gemfile.lock),gems-$SEMAPHORE_GIT_BRANCH-,gems-main-
          - gem install rake
          - bundle config set deployment 'true'
          - bundle config set path 'vendor/bundle'
          - bundle config set without 'production,staging'
          - bundle install -j 4
          - cache store gems-$SEMAPHORE_GIT_BRANCH-$(checksum Gemfile.lock) vendor/bundle

  - name: "Security"
    task:
      prologue:
        commands:
          - sem-version ruby 3.2.1
          - checkout
          - git clone https://github.com/scottwillson/registration_engine_public_stub.git registration_engine
          - sudo apt-get install -y libmysqlclient-dev
          - cache restore gems-$SEMAPHORE_GIT_BRANCH-$(checksum Gemfile.lock),gems-$SEMAPHORE_GIT_BRANCH-,gems-main-
          - bundle config set deployment 'true'
          - bundle config set path 'vendor/bundle'
          - bundle config set without 'production,staging'
          - bundle install -j 4
      jobs:
      - name: Brakeman
        commands:
          - bundle exec brakeman
          - bundle exec bundle-audit

  - name: "Unit tests"
    task:
      prologue:
        commands:
          - sem-version ruby 3.2.1
          - checkout
          - mkdir -p local/app/assets/images
          - sudo apt-get install -y libmysqlclient-dev
          - git clone https://github.com/scottwillson/registration_engine_public_stub.git registration_engine
          - cache restore gems-$SEMAPHORE_GIT_BRANCH-$(checksum Gemfile.lock),gems-$SEMAPHORE_GIT_BRANCH-,gems-main-
          - bundle config set deployment 'true'
          - bundle config set path 'vendor/bundle'
          - bundle config set without 'production,staging'
          - bundle install -j 4
          - sem-service start mysql 5.7
          - mv config/semaphore_database.yml config/database.yml
          - bundle exec rake db:setup
          - bundle exec rake db:test:prepare
      jobs:
      - name: unit tests
        commands:
          - bin/test_ruby && bundle exec rails test
          - exitcode=$(if [ "$SEMAPHORE_JOB_RESULT" == "failed" ]; then echo 1; else echo 0; fi)
      secrets:
        - name: environmental_variables

  - name: "System tests"
    task:
      prologue:
        commands:
          - sem-version ruby 3.2.1
          - checkout
          - git clone https://github.com/scottwillson/registration_engine_public_stub.git registration_engine
          - sudo apt-get install -y libmysqlclient-dev
          - cache restore gems-$SEMAPHORE_GIT_BRANCH-$(checksum Gemfile.lock),gems-$SEMAPHORE_GIT_BRANCH-,gems-main-
          - bundle config set deployment 'true'
          - bundle config set path 'vendor/bundle'
          - bundle config set without 'production,staging'
          - bundle install -j 4
          - sem-service start mysql 5.7
          - mv config/semaphore_database.yml config/database.yml
          - bundle exec rake db:setup
          - bundle exec rake db:test:prepare
      jobs:
      - name: system tests
        commands:
          - bundle exec rails test:system

      epilogue:
        on_fail:
          commands:
            - artifact push job log/test.log
            - artifact push job tmp/screenshots

  - name: "Registration engine security"
    task:
      prologue:
        commands:
          - sem-version ruby 3.2.1
          - checkout
          - cat /home/semaphore/semaphore_ssh_config >> /home/semaphore/.ssh/config
          - chmod 0600 /home/semaphore/.ssh/semaphore-github-obra
          - git clone git@github.com-obra:scottwillson/obra-local.git local
          - chmod 0600 /home/semaphore/.ssh/semaphore-github-registration-engine
          - rm -rf registration_engine
          - git clone git@github.com-registration-engine:scottwillson/registration_engine.git
          - sudo apt-get install -y libmysqlclient-dev
          - cache restore gems-$SEMAPHORE_GIT_BRANCH-$(checksum Gemfile.lock),gems-$SEMAPHORE_GIT_BRANCH-,gems-main-
          - bundle config set deployment 'true'
          - bundle config set path 'vendor/bundle'
          - bundle config set without 'production,staging'
          - bundle install -j 4
      jobs:
      - name: Brakeman
        commands:
          - bundle exec brakeman
          - bundle exec bundle-audit

  - name: "OBRA unit tests"
    task:
      prologue:
        commands:
          - sem-version ruby 3.2.1
          - checkout
          - cat /home/semaphore/semaphore_ssh_config >> /home/semaphore/.ssh/config
          - chmod 0600 /home/semaphore/.ssh/semaphore-github-obra
          - git clone git@github.com-obra:scottwillson/obra-local.git local
          - chmod 0600 /home/semaphore/.ssh/semaphore-github-registration-engine
          - rm -rf registration_engine
          - git clone git@github.com-registration-engine:scottwillson/registration_engine.git
          - sudo apt-get install -y libmysqlclient-dev
          - cache restore gems-$SEMAPHORE_GIT_BRANCH-$(checksum Gemfile.lock),gems-$SEMAPHORE_GIT_BRANCH-,gems-main-
          - bundle config set deployment 'true'
          - bundle config set path 'vendor/bundle'
          - bundle config set without 'production,staging'
          - bundle install -j 4
          - sem-service start mysql 5.7
          - mv config/semaphore_database.yml local/config/database.yml
          - bundle exec rake db:setup
          - bundle exec rake db:test:prepare
      jobs:
      - name: unit tests
        commands:
          - bin/test_ruby && bundle exec rails test && bundle exec rails t registration_engine/test/{controllers,helpers,integration,mailers,models}/**/*_test.rb
          - exitcode=$(if [ "$SEMAPHORE_JOB_RESULT" == "failed" ]; then echo 1; else echo 0; fi)
      secrets:
        - name: environmental_variables

  - name: "OBRA system tests"
    task:
      prologue:
        commands:
          - sem-version ruby 3.2.1
          - checkout
          - cat /home/semaphore/semaphore_ssh_config >> /home/semaphore/.ssh/config
          - chmod 0600 /home/semaphore/.ssh/semaphore-github-obra
          - git clone git@github.com-obra:scottwillson/obra-local.git local
          - chmod 0600 /home/semaphore/.ssh/semaphore-github-registration-engine
          - rm -rf registration_engine
          - git clone git@github.com-registration-engine:scottwillson/registration_engine.git
          - sudo apt-get install -y libmysqlclient-dev
          - cache restore gems-$SEMAPHORE_GIT_BRANCH-$(checksum Gemfile.lock),gems-$SEMAPHORE_GIT_BRANCH-,gems-main-
          - bundle config set deployment 'true'
          - bundle config set path 'vendor/bundle'
          - bundle config set without 'production,staging'
          - bundle install -j 4
          - sem-service start mysql 5.7
          - mv config/semaphore_database.yml local/config/database.yml
          - bundle exec rake db:setup
          - bundle exec rake db:test:prepare
      jobs:
      - name: system tests
        commands:
          - bundle exec rails test:system && bundle exec rails t registration_engine/test/system

      epilogue:
        on_fail:
          commands:
            - artifact push job log/test.log
            - artifact push job tmp/screenshots