diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml index 41dd554..fab89b1 100644 --- a/.github/workflows/rubyonrails.yml +++ b/.github/workflows/rubyonrails.yml @@ -1,5 +1,3 @@ -# This workflow will install a prebuilt Ruby version, install dependencies, and -# run tests and linters. name: "Ruby on Rails CI" on: push: @@ -9,10 +7,23 @@ on: jobs: test: runs-on: ubuntu-latest - env: - RAILS_ENV: test - DB_ADAPTER: sqlite3 - DATABASE_URL: db/test.sqlite3 + services: + mysql: + image: mysql + ports: + - 3306:3306 + env: + MYSQL_ROOT_PASSWORD: mysql + MYSQL_DATABASE: test + MYSQL_USER: test + MYSQL_PASSWORD: test + # Set health checks to wait until mysql has started + options: >- + --health-cmd "mysqladmin ping -h 127.0.0.1 -u root -p$$MYSQL_ROOT_PASSWORD" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: - name: Checkout code uses: actions/checkout@v3 @@ -21,8 +32,12 @@ jobs: with: bundler-cache: true - name: Run tests + env: + RAILS_ENV: test + DATABASE_URL: mysql2://test:test@127.0.0.1:3306/test run: | + sudo apt install -y libmariadb-dev bundle install - bundle exec rails db:create + bundle exec rails db:migrate bundle exec rails test