Skip to content

Commit

Permalink
use mysql db to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amtuannguyen committed Mar 31, 2024
1 parent 7d9d455 commit 667c3f0
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/rubyonrails.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -21,8 +32,12 @@ jobs:
with:
bundler-cache: true
- name: Run tests
env:
RAILS_ENV: test
DATABASE_URL: mysql2://test:[email protected]: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

0 comments on commit 667c3f0

Please sign in to comment.