Skip to content

Commit

Permalink
Fix github actions (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
frvade authored Nov 6, 2021
1 parent 8c84792 commit a5334c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [2.6, 2.7, "3.0", jruby-9.2.8.0, ruby-head, jruby-head]
ruby: [2.6, 2.7, "3.0", jruby-9.3.1.0, ruby-head, jruby-head]

name: ${{ matrix.ruby }}

Expand All @@ -39,12 +39,13 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- run: psql -c 'CREATE DATABASE batches_test'
- run: bundle exec rake bundle:audit
- run: bundle exec rake lint
- run: bundle exec rspec
continue-on-error: ${{ matrix.ruby == 'jruby-head' || matrix.ruby == 'ruby-head' }}

- uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
17 changes: 14 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def is_jruby?
require "simplecov"
require "simplecov-lcov"

SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
c.single_report_path = "coverage/lcov.info"
end
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::LcovFormatter,
Expand All @@ -20,16 +24,23 @@ def is_jruby?
require "logger"
require "yaml"

DB_USER = (ENV["PGUSER"] || "").freeze
DB_NAME = (ENV["DB_NAME"] || "batches_test").freeze

def connect
schema = is_jruby? ? "jdbc:postgresql" : "postgres"
Sequel.connect("#{schema}:///#{DB_NAME}").tap(&:tables)
if is_jruby?
schema = "jdbc:postgresql"
user_string = "?user=#{DB_USER}"
else
schema = "postgres"
end

Sequel.connect("#{schema}:///#{DB_NAME}#{user_string}").tap(&:tables)
rescue Sequel::DatabaseConnectionError => error
raise unless error.message.include? "database \"#{DB_NAME}\" does not exist"

`createdb #{DB_NAME}`
Sequel.connect("#{schema}:///#{DB_NAME}")
Sequel.connect("#{schema}:///#{DB_NAME}#{user_string}")
end

DB = connect
Expand Down

0 comments on commit a5334c9

Please sign in to comment.