Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mysql pipeline job #54

Merged
merged 24 commits into from
Apr 19, 2024
Merged
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
64 changes: 59 additions & 5 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ on:
push:
branches:
- master

pull_request:

jobs:
build:
postgres:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
name: Ruby ${{ matrix.ruby }} with PostgreSQL
strategy:
matrix:
ruby:
Expand All @@ -19,10 +18,13 @@ jobs:
postgres:
image: postgres:latest
env:
DATABASE_ADAPTER: postgresql
DATABASE_PORT: 5432
POSTGRES_USER: outboxer_developer
POSTGRES_PASSWORD: outboxer_password
POSTGRES_DB: outboxer_test
ports: ['5432:5432']
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v3
Expand All @@ -38,5 +40,57 @@ jobs:
psql -h localhost -U outboxer_developer -d outboxer_test -c 'SELECT version();'
- name: Run Database Migrations
run: RAILS_ENV=test bin/rake outboxer:db:migrate
- name: Run the default task
- name: Run Tests
run: RAILS_ENV=test bin/rspec spec

mysql:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }} with MySQL
strategy:
matrix:
ruby:
- '3.3.0'
services:
mysql:
image: mysql:latest
env:
DATABASE_ADAPTER: mysql2
DATABASE_PORT: 3306
MYSQL_ROOT_PASSWORD: outboxer_password
MYSQL_DATABASE: outboxer_test
MYSQL_USER: outboxer_developer
MYSQL_PASSWORD: outboxer_password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Check MySQL
run: |
sudo apt-get -qq install -y mysql-client
export MYSQL_PWD=outboxer_password
mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();'
- name: Run Database Migrations
env:
RAILS_ENV: test
DATABASE_ADAPTER: mysql2
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: 3306
run: |
bin/rake outboxer:db:migrate
- name: Run Tests
env:
RAILS_ENV: test
DATABASE_ADAPTER: mysql2
DATABASE_PORT: 3306
DATABASE_HOST: 127.0.0.1
run: bin/rspec spec
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gem "rubocop", "~> 1.55"
gem "yard", "~> 0.9.34"

gem "pg", "~> 1.5"
gem 'mysql2', '~> 0.5.6'
gem "activerecord", "~> 7.1", ">= 7.1.2"

gem "sidekiq", "~> 7.2"
Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ GEM
method_source (1.0.0)
minitest (5.20.0)
mutex_m (0.2.0)
mysql2 (0.5.6)
nokogiri (1.16.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-darwin)
Expand All @@ -85,7 +86,7 @@ GEM
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pg (1.5.3)
pg (1.5.6)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -162,6 +163,7 @@ DEPENDENCIES
database_cleaner (~> 2.0, >= 2.0.2)
factory_bot (~> 6.4, >= 6.4.6)
foreman (~> 0.87.2)
mysql2 (~> 0.5.6)
outboxer!
pg (~> 1.5)
pry-byebug (~> 3.10)
Expand Down
20 changes: 10 additions & 10 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
development:
adapter: postgresql
encoding: unicode
host: localhost
port: 5432
adapter: <%= ENV.fetch('DATABASE_ADAPTER') { 'postgresql' } %>
encoding: utf8
host: <%= ENV.fetch('DATABASE_HOST') { 'localhost' } %>
port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %>
username: outboxer_developer
password: outboxer_password
database: outboxer_development
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 26 } %>
pool: <%= ENV.fetch('DATABASE_POOL') { 5 } %>

test:
adapter: postgresql
encoding: unicode
host: localhost
port: 5432
adapter: <%= ENV.fetch('DATABASE_ADAPTER') { 'postgresql' } %>
encoding: utf8
host: <%= ENV.fetch('DATABASE_HOST') { 'localhost' } %>
port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %>
username: outboxer_developer
password: outboxer_password
database: outboxer_test
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 26 } %>
pool: <%= ENV.fetch('DATABASE_POOL') { 5 } %>
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
DatabaseCleaner.clean

ActiveRecord::Base.connection.tables.each do |table|
ActiveRecord::Base.connection.reset_pk_sequence!(table)
if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
ActiveRecord::Base.connection.reset_pk_sequence!(table)
end
end
rescue ActiveRecord::DatabaseConnectionError,
ActiveRecord::ConnectionNotEstablished,
Expand Down
Loading