Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update faraday #2

Open
wants to merge 45 commits into
base: add/new_endpoints
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0c1e470
Update faraday and remove faraday_middleware
elalemanyo May 12, 2023
2f3aba2
Add more ruby versions and remove old 2.5
elalemanyo May 12, 2023
43e2f24
Run bundle install
elalemanyo May 12, 2023
8a07762
Update min ruby version needed
elalemanyo May 12, 2023
5772a39
Update CI settings
elalemanyo May 12, 2023
d2cdcfe
run rubocop autofix
elalemanyo May 12, 2023
02a9dad
Update
elalemanyo May 12, 2023
a5e8515
Make rubocop happy
elalemanyo May 12, 2023
45e2e77
remove faraday_middleware dependency
elalemanyo May 12, 2023
99bb41b
Update pry
elalemanyo May 12, 2023
70000de
Update context names
elalemanyo May 12, 2023
9e1d33b
Fix specs
elalemanyo May 13, 2023
b40d32b
Update metabase version
elalemanyo May 13, 2023
25bb869
Try first step of new ci settings
elalemanyo May 13, 2023
032a9f2
Run rubocop again with ci
elalemanyo May 13, 2023
fa89224
Try adding metabase service
elalemanyo May 13, 2023
921b1fd
Test that test still not running because metabase service is not there
elalemanyo May 13, 2023
d2ca5e7
Try new host
elalemanyo May 13, 2023
2cb121d
Change port
elalemanyo May 13, 2023
1307bc9
check docker
elalemanyo May 13, 2023
b32190a
Try localhost again
elalemanyo May 13, 2023
9ce069c
Use 3030 port again
elalemanyo May 13, 2023
8e66596
Try using service containers
elalemanyo May 14, 2023
f38628e
Move metabase to a service
elalemanyo May 14, 2023
c446076
Test new service name
elalemanyo May 14, 2023
b4ece3a
Try 127.0.0.1 as host to access metabase service
elalemanyo May 14, 2023
bddb143
Use netcat to check service
elalemanyo May 14, 2023
6adfdd3
List containers
elalemanyo May 14, 2023
5e97f6e
Test container service
elalemanyo May 14, 2023
7a631a5
remove service container port test 😔
elalemanyo May 14, 2023
40c2edc
try localhost nc
elalemanyo May 14, 2023
2980504
use localhost
elalemanyo May 14, 2023
ef68f26
Remove debug run commands
elalemanyo May 14, 2023
ec13a86
Test container service again
elalemanyo May 14, 2023
ac53d97
Update metabase data
elalemanyo May 14, 2023
bb79165
Test curl for container service
elalemanyo May 14, 2023
8c7953f
check containers
elalemanyo May 14, 2023
4c31e32
Check docker network created from github actions
elalemanyo May 14, 2023
2bcf9c9
Add another docker container to run tests
elalemanyo May 14, 2023
a3824a3
Try ubuntu-latest container
elalemanyo May 14, 2023
4b9d32a
Test network fix
elalemanyo May 14, 2023
1080d40
fix indentation
elalemanyo May 14, 2023
0a58bce
show docker network
elalemanyo May 14, 2023
47d9b8f
try curl localhost
elalemanyo May 14, 2023
a3a0899
Remove metabase service
elalemanyo May 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,22 @@ jobs:
strategy:
matrix:
ruby:
- '3.2'
- '3.1'
- '3.0'
- '2.7'
- '2.6'
- '2.5'
container:
image: ruby:${{ matrix.ruby }}
env:
BUNDLE_CLEAN: 'true'
BUNDLE_DEPLOYMENT: 'true'
BUNDLE_JOBS: 4

steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v3

- uses: ruby/setup-ruby@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-ruby${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: ${{ runner.os }}-ruby${{ matrix.ruby }}-
- name: Install gems
run: gem install bundler && bundle install
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- run: ruby -v

- name: Rubocop
run: bundle exec rubocop

- name: RSpec
run: bundle exec rake spec
Binary file modified .metabase.db/metabase.db.mv.db
Binary file not shown.
6 changes: 5 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require:
- rubocop-rake
- rubocop-rspec

AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 3.0
NewCops: enable

Style/Documentation:
Expand Down
94 changes: 49 additions & 45 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
PATH
remote: .
specs:
metabase (0.5.0)
faraday (>= 1.2.0)
faraday_middleware
metabase (0.6.0)
faraday (>= 2.0.1)

GEM
remote: https://rubygems.org/
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
amazing_print (1.2.2)
ast (2.4.1)
ast (2.4.2)
bump (0.10.0)
coderay (1.1.3)
crack (0.4.5)
rexml
diff-lcs (1.4.4)
docile (1.3.5)
faraday (1.3.0)
faraday-net_http (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords
faraday-net_http (1.0.1)
faraday_middleware (1.0.0)
faraday (~> 1.0)
faraday (2.7.4)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
hashdiff (1.0.1)
json (2.6.3)
method_source (1.0.0)
multipart-post (2.1.1)
parallel (1.20.1)
parser (3.0.0.0)
parallel (1.23.0)
parser (3.2.2.1)
ast (~> 2.4.1)
pry (0.13.1)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.6)
rainbow (3.0.0)
public_suffix (5.0.1)
rainbow (3.1.1)
rake (13.0.3)
regexp_parser (2.0.3)
rexml (3.2.4)
regexp_parser (2.8.0)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
Expand All @@ -52,29 +48,35 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.1)
rubocop (1.8.1)
rubocop (1.50.2)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.2.0, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.4.0)
parser (>= 2.7.1.5)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.2)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.28.1)
parser (>= 3.2.1.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.4.0)
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.2)
unicode-display_width (2.0.0)
unicode-display_width (2.4.2)
vcr (6.0.0)
webmock (3.11.1)
addressable (>= 2.3.6)
webmock (3.18.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
yard (0.9.26)
Expand All @@ -83,18 +85,20 @@ PLATFORMS
ruby

DEPENDENCIES
amazing_print
bump
bundler
amazing_print (>= 1.2.2)
bump (>= 0.10.0)
bundler (>= 2.4.13)
metabase!
pry
rake
rspec
rubocop
simplecov
vcr
webmock
yard
pry (>= 0.14)
rake (>= 13.0.3)
rspec (>= 3.10.0)
rubocop (>= 1.19.0)
rubocop-rake (>= 0.4.0)
rubocop-rspec (>= 2.0.0)
simplecov (>= 0.21.2)
vcr (>= 6.0.0)
webmock (>= 3.12.2)
yard (>= 0.9.25)

BUNDLED WITH
2.2.5
2.4.13
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
metabase:
image: metabase/metabase:v0.38.4
image: metabase/metabase:latest
ports:
- 3030:3000
volumes:
Expand Down
1 change: 0 additions & 1 deletion lib/metabase/connection.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'faraday'
require 'faraday_middleware'
require 'metabase/error'

module Metabase
Expand Down
4 changes: 2 additions & 2 deletions lib/metabase/endpoint/card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def query_card(card_id, format: :json, **params)
# @param params [Hash] Query string
# @return [Hash] Parsed response JSON
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#post-apicard
def new_card(**params)
def new_card(**params)
post('/api/card', **params)
end
end
end
end
end
4 changes: 2 additions & 2 deletions lib/metabase/endpoint/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def collection(collection_id, **params)
# Fetch a collection's items.
#
# @param params [Hash] Query string
# @return [Array<Hash>] Parsed response JSON
# @return [Hash] Parsed response JSON
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#get-apicollectioniditems
def collection_items(collection_id, **params)
get("/api/collection/#{collection_id}/items", **params)
Expand All @@ -35,7 +35,7 @@ def collection_items(collection_id, **params)
# @param params [Hash] Query string
# @return [Hash] Parsed response JSON
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#post-apicollection
def new_collection(**params)
def new_collection(**params)
post('/api/collection', **params)
end
end
Expand Down
14 changes: 7 additions & 7 deletions lib/metabase/endpoint/dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ def dashboards(**params)
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#get-apidashboardid
def dashboard(dashboard_id, **params)
get("/api/dashboard/#{dashboard_id}", **params)
end
end

# Create a new dashboard.
#
# @param params [Hash] Query string
# @return [Hash] Parsed response JSON
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#post-apidashboard
def new_dashboard(**params)
def new_dashboard(**params)
post('/api/dashboard', **params)
end

Expand All @@ -37,7 +37,7 @@ def new_dashboard(**params)
# @param params [Hash] Query string
# @return [Hash] Parsed response JSON
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#post-apidashboardfrom-dashboard-idcopy
def copy_dashboard(from_dashboard_id, **params)
def copy_dashboard(from_dashboard_id, **params)
post("/api/dashboard/#{from_dashboard_id}/copy", **params)
end

Expand All @@ -47,17 +47,17 @@ def copy_dashboard(from_dashboard_id, **params)
# @param params [Hash] Query string
# @return [Hash] Parsed response JSON
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#post-apidashboardidcards
def add_dashboard_card(dashboard_id, **params)
def add_dashboard_card(dashboard_id, **params)
post("/api/dashboard/#{dashboard_id}/cards", **params)
end
end

# Update Cards on a Dashboard.
#
# @param dashboard_id [Integer, String] Dashboard ID
# @param params [Hash] Query string
# @return [Hash] Parsed response JSON
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#put-apidashboardidcards
def update_dashboard_cards(dashboard_id, **params)
def update_dashboard_cards(dashboard_id, **params)
put("/api/dashboard/#{dashboard_id}/cards", **params)
end

Expand All @@ -67,7 +67,7 @@ def update_dashboard_cards(dashboard_id, **params)
# @param params [Hash] Query string
# @return [Hash] Parsed response JSON
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#delete-apidashboardidcards
def delete_dashboard_card(dashboard_id, **params)
def delete_dashboard_card(dashboard_id, **params)
delete("/api/dashboard/#{dashboard_id}/cards", **params)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/metabase/endpoint/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Database
# Fetch all databases.
#
# @param params [Hash] Query string
# @return [Array<Hash>] Parsed response JSON
# @return [Hash] Parsed response JSON
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#get-apidatabase
def databases(**params)
get('/api/database', **params)
Expand Down
2 changes: 1 addition & 1 deletion lib/metabase/endpoint/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module User
# Fetch all users.
#
# @param params [Hash] Query string
# @return [Array<Hash>] Parsed response JSON
# @return [Hash] Parsed response JSON
# @see https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#get-apiuser
def users(**params)
get('/api/user', **params)
Expand Down
2 changes: 1 addition & 1 deletion lib/metabase/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def build_error_message
return nil if @response.nil?

"#{@response.env.method.upcase} #{@response.env.url}: " \
"#{@response.status} - #{@response.body}"
"#{@response.status} - #{@response.body}"
end
end

Expand Down
30 changes: 16 additions & 14 deletions metabase.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,22 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.required_ruby_version = '>= 2.5'
spec.required_ruby_version = '>= 3.0'

spec.add_runtime_dependency 'faraday', '>= 1.2.0'
spec.add_runtime_dependency 'faraday_middleware'
spec.add_runtime_dependency 'faraday', '>= 2.0.1'

spec.add_development_dependency 'amazing_print'
spec.add_development_dependency 'bump'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'vcr'
spec.add_development_dependency 'webmock'
spec.add_development_dependency 'yard'
spec.add_development_dependency 'amazing_print', '>= 1.2.2'
spec.add_development_dependency 'bump', '>= 0.10.0'
spec.add_development_dependency 'bundler', '>= 2.4.13'
spec.add_development_dependency 'pry', '>= 0.14'
spec.add_development_dependency 'rake', '>= 13.0.3'
spec.add_development_dependency 'rspec', '>= 3.10.0'
spec.add_development_dependency 'rubocop', '>= 1.19.0'
spec.add_development_dependency 'rubocop-rake', '>= 0.4.0'
spec.add_development_dependency 'rubocop-rspec', '>= 2.0.0'
spec.add_development_dependency 'simplecov', '>= 0.21.2'
spec.add_development_dependency 'vcr', '>= 6.0.0'
spec.add_development_dependency 'webmock', '>= 3.12.2'
spec.add_development_dependency 'yard', '>= 0.9.25'
spec.metadata['rubygems_mfa_required'] = 'true'
end
2 changes: 1 addition & 1 deletion spec/metabase/connection_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe Metabase::Connection do
include_context 'client'
include_context 'with client'

describe 'get' do
include_examples 'response handling' do
Expand Down
4 changes: 2 additions & 2 deletions spec/metabase/endpoint/activity_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

RSpec.describe Metabase::Endpoint::Activity do
include_context 'login'
include_context 'with login'

describe 'activities', vcr: true do
context 'success' do
context 'when success' do
it 'returns recent activities' do
activities = client.activities
expect(activities).to be_kind_of(Array)
Expand Down
4 changes: 2 additions & 2 deletions spec/metabase/endpoint/alert_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

RSpec.describe Metabase::Endpoint::Alert do
include_context 'login'
include_context 'with login'

describe 'alerts', vcr: true do
context 'success' do
context 'when success' do
it 'returns all alerts' do
alerts = client.alerts
expect(alerts).to be_kind_of(Array)
Expand Down
Loading