Skip to content

Commit

Permalink
Add PostgreSQL to CI (#307)
Browse files Browse the repository at this point in the history
Run the audiences gem tests on both MySQL and PostgreSQL to ensure
compatibility.
  • Loading branch information
xjunior authored May 21, 2024
1 parent 99142c5 commit 977d2fc
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 31 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/audiences-ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: audiences-ruby

on:
push:

jobs:
build:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }}
env:
DATABASE_USER: dbuser
DATABASE_PASS: dbpass
DATABASE_HOST: 127.0.0.1
strategy:
fail-fast: false
matrix:
ruby:
- 3.0
- 3.1
- 3.2
- 3.3
gemfile:
- gemfiles/rails_6_1.gemfile
- gemfiles/rails_7_0.gemfile
- gemfiles/rails_7_1.gemfile
exclude:
- ruby: 3.2
gemfile: gemfiles/rails_6_1.gemfile
- ruby: 3.3
gemfile: gemfiles/rails_6_1.gemfile
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: ${{ env.DATABASE_USER }}
POSTGRES_PASSWORD: ${{ env.DATABASE_PASS }}
POSTGRES_DB: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mysql:
image: mysql:latest
env:
MYSQL_USER: ${{ env.DATABASE_USER }}
MYSQL_PASSWORD: ${{ env.DATABASE_PASS }}
MYSQL_RANDOM_ROOT_PASSWORD: yes
MYSQL_DATABASE: test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v3
- name: Install non-ruby dependencies
run: sudo apt-get install libpq-dev
- name: 'mysql2 adapter'
uses: powerhome/github-actions-workflows/build-ruby-gem@main
env:
DATABASE_ADAPTER: mysql2
DATABASE_PORT: 3306
with:
workdir: audiences
ruby: ${{ matrix.ruby }}
gemfile: ${{ matrix.gemfile }}
- name: 'postgresql adapter'
uses: powerhome/github-actions-workflows/build-ruby-gem@main
env:
DATABASE_ADAPTER: postgresql
DATABASE_PORT: 5432
with:
workdir: audiences
ruby: ${{ matrix.ruby }}
gemfile: ${{ matrix.gemfile }}

license-compliance:
uses: powerhome/github-actions-workflows/.github/workflows/license-compliance.yml@main
with:
workdir: audiences

release:
needs: [build, license-compliance]
runs-on: ubuntu-latest
if: ${{ contains(github.ref, 'refs/tags/v') && contains(github.ref, 'audiences-ruby') }}
steps:
- uses: actions/checkout@v3
- uses: cadwallion/publish-rubygems-action@master
env:
RELEASE_COMMAND: rake build release:guard_clean release:rubygem_push
RUBYGEMS_API_KEY: ${{ secrets.rubygems_api_key }}
WORKDIR: audiences
20 changes: 0 additions & 20 deletions .github/workflows/audiences.yml

This file was deleted.

1 change: 1 addition & 0 deletions audiences/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ gem "webmock", "~> 3.18"

# Development environment dependencies
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.0"
gem "puma", "~> 6.3"
2 changes: 2 additions & 0 deletions audiences/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ GEM
parser (3.3.1.0)
ast (~> 2.4.1)
racc
pg (1.5.6)
psych (5.1.2)
stringio
public_suffix (5.0.5)
Expand Down Expand Up @@ -296,6 +297,7 @@ DEPENDENCIES
foreman (~> 0.88.0)
license_finder (>= 7.0)
mysql2 (~> 0.5.6)
pg (~> 1.0)
puma (~> 6.3)
rails (~> 6.1.7.0)
rake (>= 13.0)
Expand Down
2 changes: 1 addition & 1 deletion audiences/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require "bundler/setup"
require "bundler/gem_tasks"

require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(spec: %w[app:db:drop app:db:prepare])
RSpec::Core::RakeTask.new(spec: %w[app:db:prepare])

require "rubocop/rake_task"
RuboCop::RakeTask.new(:rubocop)
Expand Down
1 change: 1 addition & 0 deletions audiences/gemfiles/rails_6_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gem "shoulda-matchers", "~> 5.0"
gem "vite_rails", "~> 3.0"
gem "webmock", "~> 3.18"
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.0"
gem "puma", "~> 6.3"

gemspec path: "../"
2 changes: 2 additions & 0 deletions audiences/gemfiles/rails_6_1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ GEM
parser (3.3.1.0)
ast (~> 2.4.1)
racc
pg (1.5.6)
psych (5.1.2)
stringio
public_suffix (5.0.5)
Expand Down Expand Up @@ -294,6 +295,7 @@ DEPENDENCIES
foreman (~> 0.88.0)
license_finder (>= 7.0)
mysql2 (~> 0.5.6)
pg (~> 1.0)
puma (~> 6.3)
rails (~> 6.1)
rake (>= 13.0)
Expand Down
1 change: 1 addition & 0 deletions audiences/gemfiles/rails_7_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gem "shoulda-matchers", "~> 5.0"
gem "vite_rails", "~> 3.0"
gem "webmock", "~> 3.18"
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.0"
gem "puma", "~> 6.3"

gemspec path: "../"
2 changes: 2 additions & 0 deletions audiences/gemfiles/rails_7_0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ GEM
parser (3.3.1.0)
ast (~> 2.4.1)
racc
pg (1.5.6)
psych (5.1.2)
stringio
public_suffix (5.0.5)
Expand Down Expand Up @@ -293,6 +294,7 @@ DEPENDENCIES
foreman (~> 0.88.0)
license_finder (>= 7.0)
mysql2 (~> 0.5.6)
pg (~> 1.0)
puma (~> 6.3)
rails (~> 7.0, < 7.1)
rake (>= 13.0)
Expand Down
1 change: 1 addition & 0 deletions audiences/gemfiles/rails_7_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gem "shoulda-matchers", "~> 5.0"
gem "vite_rails", "~> 3.0"
gem "webmock", "~> 3.18"
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.0"
gem "puma", "~> 6.3"

gemspec path: "../"
2 changes: 2 additions & 0 deletions audiences/gemfiles/rails_7_1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ GEM
parser (3.3.1.0)
ast (~> 2.4.1)
racc
pg (1.5.6)
psych (5.1.2)
stringio
public_suffix (5.0.5)
Expand Down Expand Up @@ -313,6 +314,7 @@ DEPENDENCIES
foreman (~> 0.88.0)
license_finder (>= 7.0)
mysql2 (~> 0.5.6)
pg (~> 1.0)
puma (~> 6.3)
rails (~> 7.1, < 7.2)
rake (>= 13.0)
Expand Down
20 changes: 10 additions & 10 deletions audiences/spec/dummy/config/database.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
development:
adapter: mysql2
adapter: <%= ENV.fetch("DATABASE_ADAPTER") { "mysql2" } %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
username: <%= ENV.fetch("MYSQL_USER", "root") %>
password: <%= ENV.fetch("MYSQL_PASS", "root") %>
host: <%= ENV.fetch("MYSQL_HOST", "127.0.0.1") %>
port: 3306
username: <%= ENV.fetch("DATABASE_USER") { "root" } %>
password: <%= ENV.fetch("DATABASE_PASS") { "root" } %>
host: <%= ENV.fetch("DATABASE_HOST") { "127.0.0.1" } %>
port: <%= ENV.fetch("DATABASE_PORT") { "3306" } %>
database: development

test:
adapter: mysql2
adapter: <%= ENV.fetch("DATABASE_ADAPTER") { "mysql2" } %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
username: <%= ENV.fetch("MYSQL_USER", "root") %>
password: <%= ENV.fetch("MYSQL_PASS", "root") %>
host: <%= ENV.fetch("MYSQL_HOST", "127.0.0.1") %>
port: 3306
username: <%= ENV.fetch("DATABASE_USER") { "root" } %>
password: <%= ENV.fetch("DATABASE_PASS") { "root" } %>
host: <%= ENV.fetch("DATABASE_HOST") { "127.0.0.1" } %>
port: <%= ENV.fetch("DATABASE_PORT") { "3306" } %>
database: test

0 comments on commit 977d2fc

Please sign in to comment.