Skip to content

Commit

Permalink
Merge pull request #249 from dentarg/actions
Browse files Browse the repository at this point in the history
Add Ruby 3.0 support and replace Travis CI with GitHub Actions
  • Loading branch information
hennevogel authored Feb 6, 2021
2 parents b708621 + 7698c7b commit b8217c4
Show file tree
Hide file tree
Showing 18 changed files with 165 additions and 103 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Tests

# workflow_dispatch enables running workflow manually
on: [push, pull_request, workflow_dispatch]

jobs:
rubocop:
name: RuboCop
runs-on: ${{ matrix.os }}
if: |
!( contains(github.event.pull_request.title, '[ci skip]')
|| contains(github.event.pull_request.title, '[skip ci]')
|| contains(github.event.head_commit.message, '[ci skip]')
|| contains(github.event.head_commit.message, '[skip ci]'))
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
ruby: [2.7]
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ${{ matrix.ruby }}
- run: bundle exec rake rubocop

specs:
name: ${{ matrix.os }} ${{ matrix.ruby }}
runs-on: ${{ matrix.os }}
if: |
!( contains(github.event.pull_request.title, '[ci skip]')
|| contains(github.event.pull_request.title, '[skip ci]')
|| contains(github.event.head_commit.message, '[ci skip]')
|| contains(github.event.head_commit.message, '[skip ci]'))
strategy:
fail-fast: false
matrix:
os:
- ubuntu-16.04
- ubuntu-18.04
- ubuntu-20.04
ruby:
- 2.3
- 2.4
- 2.5
- 2.6
- 2.7
# YAML gotcha: https://github.com/actions/runner/issues/849
- '3.0'
- head
include:
- os: ubuntu-20.04
ruby: jruby-9.1
jruby_opts: '--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -J-Xmx256M'
allow-failure: true
- os: ubuntu-20.04
ruby: jruby-9.2
jruby_opts: '--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -J-Xmx256M'
allow-failure: true
- os: ubuntu-20.04
ruby: jruby-head
jruby_opts: '--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -J-Xmx256M'
allow-failure: true
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ${{ matrix.ruby }}
- run: bundle exec rake
continue-on-error: ${{ matrix.allow-failure || false }}

smoketests:
name: smoketest with influx ${{ matrix.influx_version }}
runs-on: ubuntu-20.04
if: |
!( contains(github.event.pull_request.title, '[ci skip]')
|| contains(github.event.pull_request.title, '[skip ci]')
|| contains(github.event.head_commit.message, '[ci skip]')
|| contains(github.event.head_commit.message, '[skip ci]'))
strategy:
fail-fast: false
matrix:
include:
- { ruby: 2.7, influx_version: 1.0.2, pkghash: 88f6c30fec2c6e612e802e23b9161fdfc7c5c29f6be036f0376326445aff0037 }
- { ruby: 2.7, influx_version: 1.1.5, pkghash: 0ecb9385cc008f6e5094e6e8f8ea70522023a16d4397e401898f3973176d3b21 }
- { ruby: 2.7, influx_version: 1.2.4, pkghash: 2fac8391e04aa1bec9151e8f0d8f18df030c866af2b4963ab7d86c6ddc172182 }
- { ruby: 2.7, influx_version: 1.3.8, pkghash: 35c9cb2943bbde04aa5e94ad6d8caf5fc9b1480bdbcde7c34078de135cc4f788 }
- { ruby: 2.7, influx_version: 1.4.3, pkghash: 0477080f1d1cf8e1242dc7318280b9010c4c45cf6a415a2a5de607ae17fa0359 }
- { ruby: 2.7, influx_version: 1.5.4, pkghash: fa6f8d3196d13ffc376d533581b534692c738181ce3427c53484c138d9e6b902 }
- { ruby: 2.7, influx_version: 1.6.4, pkghash: dbfa13a0f9e38a8e7b19294c30144903bb681ac0aba0a3a8f4f349c37d5de5f9 }
- { ruby: 2.7, influx_version: 1.7.9, pkghash: 02759d70cef670d336768fd38a9cf2f046a1bf40618be78ba215e7ce75b5075f }
- { ruby: 2.7, influx_version: nightly, channel: nightlies, allow-failure: true }
env:
influx_version: ${{ matrix.influx_version }}
pkghash: ${{ matrix.pkghash }}
channel: ${{ matrix.channel }}
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ${{ matrix.ruby }}
- run: bin/provision.sh
- run: bundle exec rake spec
continue-on-error: ${{ matrix.allow-failure || false }}
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
inherit_mode:
merge:
- Exclude

AllCops:
Include:
- 'Rakefile'
Expand Down
59 changes: 0 additions & 59 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# influxdb-ruby

[![Gem Version](https://badge.fury.io/rb/influxdb.svg)](https://badge.fury.io/rb/influxdb)
[![Build Status](https://travis-ci.org/influxdata/influxdb-ruby.svg?branch=master)](https://travis-ci.org/influxdata/influxdb-ruby)
[![Build Status](https://github.com/influxdata/influxdb-ruby/workflows/Tests/badge.svg)](https://github.com/influxdata/influxdb-ruby/actions)

The official Ruby client library for [InfluxDB](https://influxdata.com/time-series-platform/influxdb/).
Maintained by [@toddboom](https://github.com/toddboom) and [@dmke](https://github.com/dmke).
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = FileList[file_pattern]
end

if ENV.key?("TRAVIS")
if ENV.key?("CI")
task default: %i[spec]
else
task default: %i[spec rubocop]
Expand Down
2 changes: 1 addition & 1 deletion bin/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ echo "-- grant access"

echo "== Download and import NOAA sample data"

curl https://s3-us-west-1.amazonaws.com/noaa.water.database.0.9/NOAA_data.txt > noaa.txt
curl https://s3.amazonaws.com/noaa.water-database/NOAA_data.txt > noaa.txt
/usr/bin/influx -import -path noaa.txt -precision s

echo "-- grant access"
Expand Down
12 changes: 9 additions & 3 deletions lib/influxdb/query/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def execute(
)
return [] if statements.empty?

url = full_url "/query".freeze, query_params(statements.join(";"), opts)
url = full_url "/query".freeze, **query_params(statements.join(";"), **opts)
series = fetch_series get(url, parse: true, json_streaming: !chunk_size.nil?)

if denormalize
Expand Down Expand Up @@ -82,8 +82,14 @@ def fetch_series(response)
denormalize_series
denormalized_series_list
].each do |method_name|
define_method(method_name) do |*args|
client.send method_name, *args
if RUBY_VERSION < "2.7"
define_method(method_name) do |*args|
client.send method_name, *args
end
else
define_method(method_name) do |*args, **kwargs|
client.send method_name, *args, **kwargs
end
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/influxdb/query/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def query( # rubocop:disable Metrics/MethodLength
)
query = builder.build(query, params)

url = full_url("/query".freeze, query_params(query, **opts))
url = full_url("/query".freeze, **query_params(query, **opts))
series = fetch_series(get(url, parse: true, json_streaming: !chunk_size.nil?))

if block_given?
Expand Down Expand Up @@ -79,7 +79,7 @@ def write(data, precision, retention_policy = nil, database = nil)
}

params[:rp] = retention_policy if retention_policy
url = full_url("/write", params)
url = full_url("/write", **params)
post(url, data)
end

Expand Down Expand Up @@ -133,7 +133,7 @@ def generate_point(point)
def execute(query, db: nil, **options)
params = { q: query }
params[:db] = db if db
url = full_url("/query".freeze, params)
url = full_url("/query".freeze, **params)
get(url, options)
end

Expand All @@ -147,7 +147,7 @@ def raw_values(series)
series.select { |k, _| %w[columns values].include?(k) }
end

def full_url(path, params = {})
def full_url(path, **params)
if config.auth_method == "params".freeze
params[:u] = config.username
params[:p] = config.password
Expand Down
2 changes: 1 addition & 1 deletion spec/influxdb/cases/query_cluster_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe InfluxDB::Client do
let(:subject) do
described_class.new "database", {
described_class.new "database", **{
host: "influxdb.test",
port: 9999,
username: "username",
Expand Down
2 changes: 1 addition & 1 deletion spec/influxdb/cases/query_series_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let(:subject) do
described_class.new(
"database",
{
**{
host: "influxdb.test",
port: 9999,
username: "username",
Expand Down
2 changes: 1 addition & 1 deletion spec/influxdb/cases/querying_issue_7000_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

describe InfluxDB::Client do
let(:subject) do
described_class.new "database", {
described_class.new "database", **{
host: "influxdb.test",
port: 9999,
username: "username",
Expand Down
2 changes: 1 addition & 1 deletion spec/influxdb/cases/querying_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe InfluxDB::Client do
let(:subject) do
described_class.new "database", {
described_class.new "database", **{
host: "influxdb.test",
port: 9999,
username: "username",
Expand Down
2 changes: 1 addition & 1 deletion spec/influxdb/cases/retry_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let(:client) do
described_class.new(
"database",
{
**{
host: "influxdb.test",
port: 9999,
username: "username",
Expand Down
2 changes: 1 addition & 1 deletion spec/influxdb/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let(:subject) do
described_class.new(
"database",
{
**{
host: "influxdb.test",
port: 9999,
username: "username",
Expand Down
Loading

0 comments on commit b8217c4

Please sign in to comment.