Skip to content

Commit

Permalink
Fix MySQL CI setup (#1)
Browse files Browse the repository at this point in the history
Use Docker
  • Loading branch information
a-lavis authored Sep 4, 2023
1 parent e5b316f commit c1f8227
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
31 changes: 10 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,8 @@ on:
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: trilogy-aurora-test
ports:
- 3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
name: Test Ruby ${{ matrix.ruby }}
timeout-minutes: 10
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
Expand All @@ -35,15 +22,17 @@ jobs:
- '3.1'
- '3.2'

env:
RUBY_VERSION: ${{ matrix.ruby }}

steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake spec
- name: Docker Build
run: docker-compose build --build-arg RUBY_VERSION=$RUBY_VERSION
- name: Docker MySQL Healthcheck
run: docker-compose run --rm app echo "MySQL Healthy"
- name: Run tests with Docker
run: docker-compose run --rm app ./bin/test

rubocop:
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM ruby:3.2-alpine
ARG RUBY_VERSION=3.2

FROM ruby:${RUBY_VERSION}-alpine

# Create application directory.
RUN mkdir /app
Expand Down
10 changes: 8 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ services:
volumes:
- .:/app
depends_on:
- mysql
mysql:
condition: service_healthy
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: ''
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_ALLOW_EMPTY_PASSWORD: 1
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h mysql"]
interval: 10s
timeout: 5s
retries: 3
6 changes: 3 additions & 3 deletions spec/trilogy_aurora_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

let :trilogy do
Trilogy.new(
host: ENV.fetch("TEST_DB_HOST", nil),
username: ENV.fetch("TEST_DB_USER", nil),
password: ENV.fetch("TEST_DB_PASS", nil),
host: ENV.fetch("TEST_DB_HOST"),
username: ENV.fetch("TEST_DB_USER"),
password: ENV.fetch("TEST_DB_PASS"),
aurora_max_retry: 10,
aurora_disconnect_on_readonly: aurora_disconnect_on_readonly
)
Expand Down

0 comments on commit c1f8227

Please sign in to comment.