Skip to content

Commit

Permalink
Merge pull request #30 from blocknotes/test/improve-test-suite-2
Browse files Browse the repository at this point in the history
test: improve test suite
  • Loading branch information
blocknotes authored Oct 21, 2023
2 parents 7b05c62 + dbe9d8d commit 65a0bb7
Show file tree
Hide file tree
Showing 14 changed files with 858 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/specs_mysql_60.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/specs_mysql_61.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/specs_mysql_70.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/specs_mysql_71.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: Specs Rails 7.1 MySQL

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
tests:
runs-on: ubuntu-latest

strategy:
matrix:
ruby: ['3.0', '3.1', '3.2']
gemfile: ['rails_7_1_mysql']

env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
DB_TEST: mysql
MYSQL_DB_HOST: 127.0.0.1
MYSQL_DB_USERNAME: root
MYSQL_DB_PASSWORD: root
RAILS: '7.0'

services:
mysql:
image: mysql
env:
MYSQL_USER: root
MYSQL_PASSWORD: root
# options: >-
# --health-cmd="mysqladmin ping"
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
ports:
- 3306:3306

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Start database service
run: sudo /etc/init.d/mysql start

- name: Create database
run: bundle exec rails db:create

- name: Apply migrations
run: bundle exec rails db:migrate

- name: Run tests
run: bundle exec rspec --profile
2 changes: 1 addition & 1 deletion .github/workflows/specs_postgres_60.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/specs_postgres_61.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/specs_postgres_70.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/specs_postgres_71.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: Specs Rails 7.1 Postgres

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
tests:
runs-on: ubuntu-latest

strategy:
matrix:
ruby: ['3.0', '3.1', '3.2']
gemfile: ['rails_7_1_postgres']

env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
DB_TEST: postgres
PG_DB_HOST: 127.0.0.1
PG_DB_USERNAME: postgres
PG_DB_PASSWORD: postgres
RAILS: '7.0'

services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Create database
run: bundle exec rails db:create

- name: Apply migrations
run: bundle exec rails db:migrate

- name: Run tests
run: bundle exec rspec --profile

- name: Code Climate test coverage
uses: paambaati/codeclimate-action@v3.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: |
${{github.workspace}}/coverage/lcov/active_storage_db.lcov:lcov
# - name: Upload coverage results
# uses: actions/upload-artifact@main
# if: always()
# with:
# name: coverage-report
# path: coverage/index.html
10 changes: 10 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ appraise 'rails-7_0-postgres' do
gem 'rails', '~> 7.0.0'
end

appraise 'rails-7_1-postgres' do
gem 'pg'
gem 'rails', '~> 7.1.0'
end

appraise 'rails-6_0-mysql' do
gem 'mysql2'
gem 'rails', '~> 6.0.0'
Expand All @@ -29,3 +34,8 @@ appraise 'rails-7_0-mysql' do
gem 'mysql2'
gem 'rails', '~> 7.0.0'
end

appraise 'rails-7_1-mysql' do
gem 'mysql2'
gem 'rails', '~> 7.1.0'
end
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[![maintainability](https://api.codeclimate.com/v1/badges/92e1e703c308744a0f66/maintainability)](https://codeclimate.com/github/blocknotes/active_storage_db/maintainability)

[![linters](https://github.com/blocknotes/active_storage_db/actions/workflows/linters.yml/badge.svg)](https://github.com/blocknotes/active_storage_db/actions/workflows/linters.yml)
[![specs Postgres](https://github.com/blocknotes/active_storage_db/actions/workflows/specs_postgres_70.yml/badge.svg)](https://github.com/blocknotes/active_storage_db/actions/workflows/specs_postgres_70.yml)
[![Specs MySQL](https://github.com/blocknotes/active_storage_db/actions/workflows/specs_mysql_70.yml/badge.svg)](https://github.com/blocknotes/active_storage_db/actions/workflows/specs_mysql_70.yml)
[![specs Postgres](https://github.com/blocknotes/active_storage_db/actions/workflows/specs_postgres_71.yml/badge.svg)](https://github.com/blocknotes/active_storage_db/actions/workflows/specs_postgres_71.yml)
[![specs MySQL](https://github.com/blocknotes/active_storage_db/actions/workflows/specs_mysql_71.yml/badge.svg)](https://github.com/blocknotes/active_storage_db/actions/workflows/specs_mysql_71.yml)

An Active Storage service upload/download plugin that stores files in a PostgreSQL or MySQL database.

Expand Down
25 changes: 25 additions & 0 deletions gemfiles/rails_7_1_mysql.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mysql2"
gem "rails", "~> 7.1.0"

group :development, :test do
gem "simplecov"
gem "simplecov-lcov"
gem "capybara"
gem "rspec_junit_formatter"
gem "rspec-rails"
gem "selenium-webdriver"
gem "brakeman"
gem "fasterer"
gem "rubocop"
gem "rubocop-packaging"
gem "rubocop-performance"
gem "rubocop-rails"
gem "rubocop-rspec"
gem "pry-rails"
end

gemspec path: "../"
Loading

0 comments on commit 65a0bb7

Please sign in to comment.