Skip to content

Commit c9436c0

Browse files
authored
Use Github Actions for CI (#9)
1 parent 65fecd3 commit c9436c0

File tree

13 files changed

+71
-73
lines changed

13 files changed

+71
-73
lines changed

.github/workflows/CI.yml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,61 @@ on:
44
push:
55
branches:
66
- master
7-
- github_actions
87
pull_request:
98

109
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
ruby:
16+
- "3.3"
17+
- "3.4"
18+
activerecord:
19+
- "6.1"
20+
continue-on-error: ${{ matrix.ruby == 'head' || matrix.activerecord == 'head' }}
21+
name: Ruby ${{ matrix.ruby }} / ActiveRecord ${{ matrix.activerecord }}
22+
services:
23+
postgres:
24+
image: postgres
25+
ports:
26+
- 5432:5432
27+
env:
28+
POSTGRES_HOST_AUTH_METHOD: trust
29+
POSTGRES_DB: odbc_test
30+
options: >-
31+
--health-cmd pg_isready
32+
--health-interval 10s
33+
--health-timeout 5s
34+
--health-retries 5
35+
env:
36+
RAILS_VERSION: ${{ matrix.activerecord }}
37+
CONN_STR: 'DRIVER={PostgreSQL ANSI};SERVER=localhost;PORT=5432;DATABASE=odbc_test;UID=postgres;'
38+
PGHOST: localhost
39+
PGUSER: postgres
40+
RAILS_ENV: test
41+
steps:
42+
- uses: actions/checkout@v4
43+
- name: Install Apt Packages
44+
run: >
45+
sudo apt-get install
46+
unixodbc
47+
unixodbc-dev
48+
odbc-postgresql
49+
odbcinst
50+
51+
- uses: ruby/setup-ruby@v1
52+
with:
53+
ruby-version: ${{ matrix.ruby }}
54+
bundler-cache: true
55+
- name: Setup PostgreSQL
56+
run: |
57+
sudo odbcinst -j
58+
sudo cat /usr/share/psqlodbc/odbcinst.ini.template
59+
sudo odbcinst -i -d -f /usr/share/psqlodbc/odbcinst.ini.template
60+
- run: |
61+
bundle exec rake test
1162
RuboCop:
1263
runs-on: ubuntu-latest
1364
steps:

.travis.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

Gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
source "https://rubygems.org"
22

3+
gem "activerecord", "~> #{ENV.fetch('RAILS_VERSION', '6.1')}.0"
4+
5+
gem "base64"
6+
gem "bigdecimal"
7+
gem "mutex_m"
8+
9+
gem "rake"
310
gem "rubocop", "~> 1.75.0"
411

512
gemspec

gemfiles/active_record_5_0.gemfile

Lines changed: 0 additions & 5 deletions
This file was deleted.

gemfiles/active_record_5_1.gemfile

Lines changed: 0 additions & 5 deletions
This file was deleted.

gemfiles/active_record_5_2.gemfile

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/active_record/connection_adapters/odbc_adapter.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,9 @@ def disconnect!
149149

150150
# Build a new column object from the given options. Effectively the same
151151
# as super except that it also passes in the native type.
152-
# rubocop:disable Metrics/ParameterLists
153-
def new_column(name, default, sql_type_metadata, null, table_name, default_function = nil, collation = nil, native_type = nil)
154-
::ODBCAdapter::Column.new(name, default, sql_type_metadata, null, table_name, default_function, collation, native_type)
152+
def new_column(...)
153+
::ODBCAdapter::Column.new(...)
155154
end
156-
# rubocop:enable Metrics/ParameterLists
157155

158156
protected
159157

lib/odbc_adapter/adapters/postgresql_odbc_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def default_sequence_name(table_name, pri_key = nil)
4242
"#{table_name}_#{pri_key || 'id'}_seq"
4343
end
4444

45-
def sql_for_insert(sql, pri_key, _id_value, _sequence_name, binds)
45+
def sql_for_insert(sql, pri_key, binds)
4646
unless pri_key
4747
table_ref = extract_table_ref_from_insert_sql(sql)
4848
pri_key = primary_key(table_ref) if table_ref

lib/odbc_adapter/column.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ class Column < ActiveRecord::ConnectionAdapters::Column
44

55
# Add the native_type accessor to allow the native DBMS to report back what
66
# it uses to represent the column internally.
7-
# rubocop:disable Metrics/ParameterLists
8-
def initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, native_type = nil, default_function = nil, collation = nil)
9-
super(name, default, sql_type_metadata, null, table_name, default_function, collation)
7+
def initialize(*, native_type: nil, **)
8+
super(*, **)
109
@native_type = native_type
1110
end
12-
# rubocop:enable Metrics/ParameterLists
1311
end
1412
end

lib/odbc_adapter/quoting.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def quote_column_name(name)
2828
# sequence, but not all ODBC drivers support them.
2929
def quoted_date(value)
3030
if value.acts_like?(:time)
31-
zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal
31+
default_tz = ActiveRecord.try(:default_timezone) || ActiveRecord::Base.default_timezone
32+
zone_conversion_method = default_tz == :utc ? :getutc : :getlocal
3233

3334
if value.respond_to?(zone_conversion_method)
3435
value = value.send(zone_conversion_method)

lib/odbc_adapter/schema_statements.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def columns(table_name, _name = nil)
8383
end
8484
sql_type_metadata = ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(**args)
8585

86-
cols << new_column(format_case(col_name), col_default, sql_type_metadata, col_nullable, table_name, col_native_type)
86+
cols << new_column(format_case(col_name), col_default, sql_type_metadata, col_nullable, native_type: col_native_type)
8787
end
8888
end
8989

odbc_adapter.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ Gem::Specification.new do |spec|
1919
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2020
spec.require_paths = ["lib"]
2121

22-
spec.add_dependency "activerecord", ">= 6.0", "< 8"
22+
spec.required_ruby_version = ">= 3.3.0"
23+
24+
spec.add_dependency "activerecord", ">= 6.1", "< 8"
2325
spec.add_dependency "ruby-odbc", ">= 0.9", "< 2"
2426

25-
spec.add_development_dependency "bundler", ">= 1.14"
2627
spec.add_development_dependency "minitest", "~> 5.10"
2728
spec.add_development_dependency "pry", "~> 0.11"
28-
spec.add_development_dependency "rake", "~> 12.0"
2929
spec.add_development_dependency "simplecov", "~> 0.14"
3030
end

test/test_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require "logger"
12
require "simplecov"
23
SimpleCov.start
34

0 commit comments

Comments
 (0)