Skip to content

Commit b828b5f

Browse files
committed
feat: setup CI
1 parent 9e9c13b commit b828b5f

File tree

6 files changed

+54
-71
lines changed

6 files changed

+54
-71
lines changed

.github/workflows/gem-push.yml

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,6 @@ on:
66

77
jobs:
88
build:
9-
name: Build + Publish
10-
runs-on: ubuntu-latest
11-
environment: production
12-
permissions:
13-
contents: read
14-
packages: write
15-
16-
steps:
17-
- uses: actions/checkout@v3
18-
- name: Set up Ruby 3.0
19-
uses: actions/setup-ruby@v1
20-
with:
21-
ruby-version: 3.0.x
22-
23-
- name: Publish to GPR
24-
run: |
25-
mkdir -p $HOME/.gem
26-
touch $HOME/.gem/credentials
27-
chmod 0600 $HOME/.gem/credentials
28-
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
29-
gem build *.gemspec
30-
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
31-
env:
32-
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
33-
OWNER: ${{ github.repository_owner }}
34-
35-
- name: Publish to RubyGems
36-
run: |
37-
mkdir -p $HOME/.gem
38-
touch $HOME/.gem/credentials
39-
chmod 0600 $HOME/.gem/credentials
40-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
41-
gem build *.gemspec
42-
gem push *.gem
43-
env:
44-
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
9+
uses: monade/reusable-workflows/.github/workflows/monade-ruby-rails-gems-release.yml@main
10+
secrets:
11+
RUBYGEMS_AUTH_TOKEN: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}

.github/workflows/test.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
name: Tests
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
pull_request:
5+
schedule:
6+
- cron: '0 0 1 * *'
37
jobs:
48
test:
5-
strategy:
6-
fail-fast: false
7-
matrix:
8-
os: [ubuntu-latest, macos-latest]
9-
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
10-
ruby: [2.7, '3.0', 3.1, head, truffleruby, truffleruby-head]
11-
runs-on: ${{ matrix.os }}
12-
steps:
13-
- uses: actions/checkout@v2
14-
- uses: ruby/setup-ruby@v1
15-
with:
16-
ruby-version: ${{ matrix.ruby }}
17-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
18-
- run: bundle exec rspec
9+
uses: monade/reusable-workflows/.github/workflows/monade-ruby-rails-gems-spec-with-active-record.yml@main

Gemfile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# frozen_string_literal: true
22

3-
source "https://rubygems.org"
4-
5-
# Specify your gem's dependencies in rspec_sql_matcher.gemspec
3+
source 'https://rubygems.org'
64
gemspec
75

8-
gem "rake", "~> 13.0"
9-
10-
gem "rspec", "~> 3.0"
11-
12-
gem "rubocop", "~> 1.7"
6+
rails_version = ENV['CI_RAILS_VERSION'] || '>= 0.0'
137

14-
gem "simplecov"
8+
gem "activerecord", rails_version
159

16-
gem "activerecord", "~> 7.0", ">= 7.0.3"
17-
gem "sqlite3"
10+
if ['~> 8.0.0', '>= 0', '>= 0.0'].include?(rails_version)
11+
gem 'sqlite3', '~> 2'
12+
else
13+
gem 'sqlite3', '~> 1.7.3'
14+
end
15+
gem 'typeprof'
16+
gem 'logger'
17+
gem 'mutex_m'
18+
gem 'base64'
19+
gem 'bigdecimal'
20+
gem 'benchmark'

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ The gem is available as open source under the terms of the [MIT License](https:/
6767
About Monade
6868
----------------
6969

70-
![monade](https://monade.io/wp-content/uploads/2021/06/monadelogo.png)
70+
![monade](https://monade.io/wp-content/uploads/2023/02/logo-monade.svg)
7171

72-
rspec_sql_matcher is maintained by [mònade srl](https://monade.io/en/home-en/).
72+
active_queryable is maintained by [mònade srl](https://monade.io).
7373

74-
We <3 open source software. [Contact us](https://monade.io/en/contact-us/) for your next project!
74+
We <3 open source software. [Contact us](https://monade.io) for your next project!

rspec_sql_matcher.gemspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
1212
spec.description = 'An RSpec matcher to check SQL queries'
1313
spec.homepage = 'https://github.com/monade/rspec_sql_matcher'
1414
spec.license = 'MIT'
15-
spec.required_ruby_version = '>= 2.7'
15+
spec.required_ruby_version = '>= 3.1'
1616

1717
spec.metadata['homepage_uri'] = spec.homepage
1818
spec.metadata['source_code_uri'] = spec.homepage
@@ -28,7 +28,8 @@ Gem::Specification.new do |spec|
2828
spec.require_paths = ['lib']
2929

3030
# Uncomment to register a new dependency of your gem
31-
spec.add_dependency 'activesupport'
31+
spec.add_dependency 'activesupport', '>= 6.0', '< 9.0'
32+
spec.add_development_dependency 'rspec', '~> 3.0'
3233

3334
# For more information and examples about making a new gem, checkout our
3435
# guide at: https://bundler.io/guides/creating_gem.html

spec/support/schema.rb

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,31 @@
22

33
require 'active_record'
44

5-
ActiveRecord::Base.establish_connection(
6-
adapter: 'sqlite3',
7-
database: ':memory:'
8-
)
5+
if ENV['ACTIVE_RECORD_ADAPTER'] == 'mysql'
6+
puts 'Running on MySQL...'
7+
ActiveRecord::Base.establish_connection(
8+
adapter: 'mysql2',
9+
host: ENV['DB_HOST'] || '127.0.0.1',
10+
username: ENV['DB_USERNAME'] || 'root',
11+
password: ENV['DB_PASSWORD'],
12+
database: ENV['DB_USERNAME']
13+
)
14+
elsif ENV['ACTIVE_RECORD_ADAPTER'] == 'postgresql'
15+
puts 'Running on PostgreSQL...'
16+
ActiveRecord::Base.establish_connection(
17+
adapter: 'postgresql',
18+
database: ENV['DB_NAME'],
19+
host: ENV['DB_HOST'] || '127.0.0.1',
20+
username: ENV['DB_USERNAME'] || ENV['POSTGRES_USER'] || 'postgres',
21+
password: ENV['DB_PASSWORD'] || ENV['POSTGRES_PASSWORD']
22+
)
23+
else
24+
puts 'Running on SQLite...'
25+
ActiveRecord::Base.establish_connection(
26+
adapter: 'sqlite3',
27+
database: ':memory:'
28+
)
29+
end
930

1031
class Book < ActiveRecord::Base
1132
after_initialize do

0 commit comments

Comments
 (0)