Skip to content

fix mysql ci wait

fix mysql ci wait #7

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ['3.3', '3.2', '3.1']
database: ['sqlite', 'mysql', 'postgres']
services:
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
options: >-
--health-cmd "mysqladmin ping --silent"
--health-interval 10s
--health-timeout 5s
--health-retries 10
postgres:
image: postgres:14
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{matrix.ruby}}
bundler-cache: true
- name: Setup database configuration
run: |
case ${{matrix.database}} in
sqlite)
echo "DATABASE_URL=sqlite3::memory:" >> $GITHUB_ENV
;;
mysql)
echo "DATABASE_URL=mysql2://root:root@localhost/test" >> $GITHUB_ENV
;;
postgres)
echo "DATABASE_URL=postgres://postgres:postgres@localhost/test" >> $GITHUB_ENV
;;
esac
- name: Wait for MySQL
if: matrix.database == 'mysql'
run: |
until mysqladmin ping -h"localhost" --silent; do
echo "Waiting for MySQL to be ready..."
sleep 1
done
- name: Wait for Postgres
if: matrix.database == 'postgres'
run: |
until pg_isready -h "localhost" -U "postgres"; do
echo "Waiting for Postgres to be ready..."
sleep 1
done
- name: Test
run: bundle exec rake test
# sqlite is not supported yet because it doesn't support
# the union syntax we're using
continue-on-error: ${{matrix.database == 'sqlite'}}