Skip to content

Commit

Permalink
Update CI (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
tycooon authored Aug 5, 2022
1 parent a5334c9 commit 603b516
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 47 deletions.
3 changes: 1 addition & 2 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.3.1.0, ruby-head, jruby-head]
ruby: ["2.7", "3.0", "3.1"]

name: ${{ matrix.ruby }}

Expand All @@ -44,7 +44,6 @@ jobs:
- 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:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
.rspec_status

*.gem
*.lock
*.log
.coveralls.yml
.ruby-version
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inherit_gem:

AllCops:
DisplayCopNames: true
TargetRubyVersion: 2.6
TargetRubyVersion: 2.7
Include:
- lib/**/*.rb
- spec/**/*.rb
Expand Down
10 changes: 0 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,3 @@ source "https://rubygems.org"

# Specify your gem's dependencies in sequel-batches.gemspec
gemspec

# MRI/Rubinius Adapter Dependencies
platforms :ruby do
gem "pg"
end

# JRuby Adapter Dependencies
platforms :jruby do
gem "jdbc-postgres"
end
113 changes: 113 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
PATH
remote: .
specs:
sequel-batches (2.0.0)
sequel

GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
bundler-audit (0.9.1)
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
coderay (1.1.3)
concurrent-ruby (1.1.10)
diff-lcs (1.5.0)
docile (1.4.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
method_source (1.0.0)
minitest (5.16.2)
parallel (1.22.1)
parser (3.1.2.0)
ast (~> 2.4.1)
pg (1.4.2)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
rack (2.2.4)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.5.0)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rubocop (1.30.1)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.18.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.19.1)
parser (>= 3.1.1.0)
rubocop-config-umbrellio (1.30.0.65)
rubocop (~> 1.30.0)
rubocop-performance (~> 1.14.0)
rubocop-rails (~> 2.14.2)
rubocop-rake (~> 0.6.0)
rubocop-rspec (~> 2.11.1)
rubocop-sequel (~> 0.3.3)
rubocop-performance (1.14.3)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.14.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.11.1)
rubocop (~> 1.19)
rubocop-sequel (0.3.4)
rubocop (~> 1.0)
ruby-progressbar (1.11.0)
sequel (5.59.0)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
thor (1.2.1)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.2.0)

PLATFORMS
ruby

DEPENDENCIES
bundler
bundler-audit
pg
pry
rake
rspec
rubocop-config-umbrellio
sequel-batches!
simplecov
simplecov-lcov

BUNDLED WITH
2.3.19
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ Add this line to your application's Gemfile:
gem 'sequel-batches'
```

And then execute:

$ bundle

Or install it yourself as:

$ gem install sequel-batches

## Usage

In order to use the feature you should enable the extension:
Expand Down Expand Up @@ -57,21 +49,26 @@ end
You can set the following options:

### pk

Overrides primary key of your dataset. This option is required in case your table doesn't have a real PK, otherwise you will get `Sequel::Extensions::Batches::MissingPKError`.

Note that you have to provide columns that don't contain NULL values, otherwise this may not work as intended. You will receive `Sequel::Extensions::Batches::NullPKError` in case batch processing detects a NULL value on it's way, but it's not guaranteed since it doesn't check all the rows for performance reasons.

### of

Sets chunk size (1000 by default).

### start

A hash `{ [column]: <start_value> }` that represents frame start for batch processing. Note that you will get `Sequel::Extensions::Batches::InvalidPKError` in case you provide a hash with wrong keys (ordering matters as well).

### finish

Same as `start` but represents the frame end.

### order
Specifies the primary key order (can be :asc or :desc). Defaults to :asc.

Specifies the primary key order (can be `:asc` or `:desc`). Defaults to `:asc`.

## Contributing

Expand Down
10 changes: 4 additions & 6 deletions sequel-batches.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |spec|
spec.name = "sequel-batches"
spec.version = "1.1.0"
spec.version = "2.0.0"
spec.authors = %w[fiscal-cliff umbrellio]
spec.email = ["[email protected]"]
spec.required_ruby_version = ">= 2.6"
spec.required_ruby_version = ">= 2.7"

spec.summary = "The extension mimics AR5 batches api"
spec.description = "Allows you to split your dataset in batches"
Expand All @@ -22,13 +22,11 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "bundler"
spec.add_development_dependency "bundler-audit"

spec.add_development_dependency "pg"
spec.add_development_dependency "pry"
spec.add_development_dependency "rake"

spec.add_development_dependency "rubocop-config-umbrellio"

spec.add_development_dependency "rspec"
spec.add_development_dependency "rubocop-config-umbrellio"
spec.add_development_dependency "simplecov"
spec.add_development_dependency "simplecov-lcov"
end
25 changes: 7 additions & 18 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# frozen_string_literal: true

def is_jruby?
RUBY_ENGINE == "jruby"
end

require "simplecov"
require "simplecov-lcov"

Expand All @@ -16,31 +12,24 @@ def is_jruby?
SimpleCov::Formatter::LcovFormatter,
])

SimpleCov.minimum_coverage(100) unless is_jruby?
SimpleCov.minimum_coverage(100)
SimpleCov.start

require "bundler/setup"
require "sequel"
require "logger"
require "yaml"

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

def connect
if is_jruby?
schema = "jdbc:postgresql"
user_string = "?user=#{DB_USER}"
else
schema = "postgres"
end

Sequel.connect("#{schema}:///#{DB_NAME}#{user_string}").tap(&:tables)
conn_string = "postgres:///#{DB_NAME}"
Sequel.connect(conn_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}#{user_string}")
system("createdb #{DB_NAME}")
Sequel.connect(conn_string)
end

DB = connect
Expand Down

0 comments on commit 603b516

Please sign in to comment.