Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: read
pull-requests: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check_test_execution_conditions:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: xt0rted/block-autosquash-commits-action@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

rspec:
runs-on: ubuntu-latest
strategy:
matrix:
ruby:
- 3.0.6
- 3.1.4
mysql:
- 5.6
- 5.7
needs:
- check_test_execution_conditions
services:
mysql:
image: mysql:${{ matrix.mysql }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- "3306:3306"
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run RSpec for ${{ matrix.mysql }}
run: bundle exec rake spec
env:
MYSQL5_7: ${{ matrix.mysql == '5.7' && '1' || '0' }}
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ruby:3.1.6

WORKDIR /usr/src/app

RUN mkdir -p /usr/src/app/lib/gratan
COPY Gemfile gratan.gemspec /usr/src/app/
COPY lib/gratan/version.rb /usr/src/app/lib/gratan/
RUN bundle install

COPY . .

ENTRYPOINT ["gratan"]
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ end
## Run tests

```sh
bundle install
docker-compose up -d
bundle exec rake
# MYSQL57=1 bundle exec rake
docker compose build
# for MySQL 5.6
docker compose run --rm -e MYSQL_HOST=mysql5_6 rake spec
# for MySQL 5.7
docker compose run --rm -e MYSQL_HOST=mysql5_7 -e MYSQL5_7=1 rake spec
```

## Similar tools
Expand Down
44 changes: 32 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
mysql56:
image: "mysql:5.6"
ports:
- "14406:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
mysql57:
image: "mysql:5.7"
ports:
- "14407:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
services:
mysql5_6:
image: "mysql:5.6"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
healthcheck:
test: ["CMD", "mysql", "-h", "localhost", "-u", "root", "--execute", "SHOW DATABASES;"]
start_period: 30s
timeout: 5s
interval: 5s
retries: 5
mysql5_7:
image: "mysql:5.7"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
healthcheck:
test: ["CMD", "mysql", "-h", "localhost", "-u", "root", "--execute", "SHOW DATABASES;"]
start_period: 30s
timeout: 5s
interval: 5s
retries: 5
rake:
build: .
depends_on:
mysql5_6:
condition: service_healthy
mysql5_7:
condition: service_healthy
entrypoint: ["rake"]
volumes:
- .:/usr/src/app
working_dir: /usr/src/app
4 changes: 3 additions & 1 deletion lib/gratan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ module Gratan; end
require 'gratan/logger'
require 'gratan/template_helper'
require 'gratan/client'
require 'gratan/driver'
require 'gratan/mysql5'
require 'gratan/mysql5/client'
require 'gratan/mysql5/driver'
require 'gratan/dsl'
require 'gratan/dsl/validator'
require 'gratan/dsl/context'
Expand Down
Loading