publiclab/spectral-workbench

View on GitHub
.github/actions/setup-test-environment/action.yml

Summary

Maintainability
Test Coverage
name: 'Set up test environment'
description: 'Set up test environment for spectral-workbench'

services:
  mysql:
    image: mysql:5.7
    env:
      MYSQL_ROOT_PASSWORD: root
    ports:
    - 3306
    options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
runs:
  using: "composite"
  steps:

  - name: Install JavaScript dependencies with Yarn
    shell: bash
    run: yarn check || yarn install --frozen-lockfile;

  - name: Setup database
    shell: bash
    env:
      RAILS_ENV: test
      DB_USER: root
      DB_PASS: root
      # tell Rails to use proper port for MySQL
      DB_PORT: ${{ job.services.mysql.ports[3306] }}
      DISABLE_BOOTSNAP: true # bootsnap cache failing when multiple parallel builds try to access it at the same time
    run: |
      cp config/database.yml.example config/database.yml
      cp db/schema.rb.example db/schema.rb
      cp config/config.yml.example config/config.yml
      sudo systemctl start mysql
      mysql -uroot -proot -e "CREATE DATABASE swbench_test;"
      mysql -uroot -proot -e "SET @@global.sql_mode=(SELECT REPLACE(@@global.sql_mode, 'ONLY_FULL_GROUP_BY', ''));"
      bundle exec rake db:schema:load;
      bundle exec rake db:migrate; # --trace