Skip to content

Instantly share code, notes, and snippets.

@kmcphillips
Created February 23, 2024 02:17
Show Gist options
  • Save kmcphillips/55043742fcf6e882a7e2eb90611a4910 to your computer and use it in GitHub Desktop.
Save kmcphillips/55043742fcf6e882a7e2eb90611a4910 to your computer and use it in GitHub Desktop.
Working MySQL 8 with Trilogy and Rails in Github Actions CI
name: CI
on: [ push, pull_request ]
jobs:
rspec:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: test
MYSQL_PASSWORD: password
MYSQL_DATABASE: example_test
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_USER=test -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=example_test --entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
env:
RAILS_ENV: test
DATABASE_URL: trilogy://test:password@127.0.0.1:3306/example_test?charset=utf8mb4&collation=utf8mb4_unicode_ci
name: Run tests in CI
steps:
- uses: actions/checkout@v1
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
bundler-cache: true
- name: Setup DB
run: |
rm config/database.yml
bin/rails db:create
bin/rails db:test:prepare
- name: Run tests
run: |
bundle exec rspec --format doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment