From 06a1bb1542f5a21343fa2214cbff39312ac2f74f Mon Sep 17 00:00:00 2001 From: Stoica Alex Date: Tue, 21 Nov 2023 10:54:20 +0000 Subject: [PATCH 1/4] Support files --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++ .gitignore | 9 +++++++ Gemfile | 5 ++++ Gemfile.lock | 12 +++++++++- LICENSE.txt | 21 +++++++++++++++++ Rakefile | 3 +++ lib/rb_snowflake_client/version.rb | 3 +++ rb_snowflake_client.gemspec | 21 +++++++++++++++++ 8 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 LICENSE.txt create mode 100644 Rakefile create mode 100644 lib/rb_snowflake_client/version.rb create mode 100644 rb_snowflake_client.gemspec diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b11470f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: CI + +on: + push: + branches: "*" + pull_request: + branches: "*" + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@904f3fef85a9c80a3750cbe7d5159268fd5caa9f + with: + ruby-version: '3.0.6' + - name: Install dependencies + run: bundle install + - name: Build gem + run: rake build + # Enable this section to allow debugging via SSH + #- name: Setup upterm session + #uses: lhotari/action-upterm@v1 + #with: + ### limits ssh access and adds the ssh public key for the user which triggered the workflow + #limit-access-to-actor: true + - name: Install gem + run: cd pkg && gem install --local *.gem + - name: Run tests + run: ruby -rrb_snowflake_client spec/test.rb + env: # Or as an environment variable + SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} + SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} + SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} + SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6f77e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/.project +/.rakeTasks +.idea/* + +# ruby gems +*.gem +/.DS_Store +.env + diff --git a/Gemfile b/Gemfile index 63049d2..6ef3355 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,11 @@ source "https://rubygems.org" +# Specify your gem's dependencies in ruby_snowflake_client.gemspec +gemspec + +gem "bundler" +gem "rake" gem "concurrent-ruby" gem "connection_pool" gem "jwt" diff --git a/Gemfile.lock b/Gemfile.lock index 4f10dd8..8c88e01 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,8 @@ +PATH + remote: . + specs: + rb_snowflake_client (0.0.1) + GEM remote: https://rubygems.org/ specs: @@ -5,15 +10,20 @@ GEM connection_pool (2.4.1) jwt (2.7.1) oj (3.16.1) + rake (13.1.0) PLATFORMS + arm64-darwin-21 arm64-darwin-22 DEPENDENCIES + bundler concurrent-ruby connection_pool jwt oj + rake + rb_snowflake_client! BUNDLED WITH - 2.4.14 + 2.4.19 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..e3c3ff6 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Dotan Nahum + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..7398a90 --- /dev/null +++ b/Rakefile @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require 'bundler/gem_tasks' diff --git a/lib/rb_snowflake_client/version.rb b/lib/rb_snowflake_client/version.rb new file mode 100644 index 0000000..c2dbe80 --- /dev/null +++ b/lib/rb_snowflake_client/version.rb @@ -0,0 +1,3 @@ +module RbSnowflakeClient + VERSION = '0.0.1' +end diff --git a/rb_snowflake_client.gemspec b/rb_snowflake_client.gemspec new file mode 100644 index 0000000..752ae8a --- /dev/null +++ b/rb_snowflake_client.gemspec @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require_relative "lib/rb_snowflake_client/version" + +Gem::Specification.new do |s| + s.name = "rb_snowflake_client" + s.version = RbSnowflakeClient::VERSION + s.summary = "Snowflake connector for Ruby" + s.author = "Rinsed" + s.email = ["reid@rinsed.co", "alex@rinsed.co"] + s.description = <<~DESC + Using the HTTP V2 Api for Snowflake runs queries & creates native Ruby objects. + DESC + s.license = "MIT" # TODO: double check + + s.files = Dir.chdir(File.expand_path(__dir__)) do + `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|vendor)/}) } + end + + s.require_paths = ["lib"] +end From 90a6def967092feab3661505f04343c774d3b0a1 Mon Sep 17 00:00:00 2001 From: Stoica Alex Date: Tue, 21 Nov 2023 10:54:34 +0000 Subject: [PATCH 2/4] Moved files to directories --- lib/rb_snowflake_client.rb | 6 ++++++ .../indifferent_case_insensitive_hash.rb | 0 result_set.rb => lib/rb_snowflake_client/result_set.rb | 0 row_facade.rb => lib/rb_snowflake_client/row_facade.rb | 0 .../rb_snowflake_client/snowflake_client.rb | 0 test.rb => spec/test.rb | 2 +- 6 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 lib/rb_snowflake_client.rb rename indifferent_case_insensitive_hash.rb => lib/rb_snowflake_client/indifferent_case_insensitive_hash.rb (100%) rename result_set.rb => lib/rb_snowflake_client/result_set.rb (100%) rename row_facade.rb => lib/rb_snowflake_client/row_facade.rb (100%) rename snowflake_client.rb => lib/rb_snowflake_client/snowflake_client.rb (100%) rename test.rb => spec/test.rb (96%) diff --git a/lib/rb_snowflake_client.rb b/lib/rb_snowflake_client.rb new file mode 100644 index 0000000..389b045 --- /dev/null +++ b/lib/rb_snowflake_client.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require "rb_snowflake_client/snowflake_client" + +module RbSnowflakeClient +end diff --git a/indifferent_case_insensitive_hash.rb b/lib/rb_snowflake_client/indifferent_case_insensitive_hash.rb similarity index 100% rename from indifferent_case_insensitive_hash.rb rename to lib/rb_snowflake_client/indifferent_case_insensitive_hash.rb diff --git a/result_set.rb b/lib/rb_snowflake_client/result_set.rb similarity index 100% rename from result_set.rb rename to lib/rb_snowflake_client/result_set.rb diff --git a/row_facade.rb b/lib/rb_snowflake_client/row_facade.rb similarity index 100% rename from row_facade.rb rename to lib/rb_snowflake_client/row_facade.rb diff --git a/snowflake_client.rb b/lib/rb_snowflake_client/snowflake_client.rb similarity index 100% rename from snowflake_client.rb rename to lib/rb_snowflake_client/snowflake_client.rb diff --git a/test.rb b/spec/test.rb similarity index 96% rename from test.rb rename to spec/test.rb index 7d31f41..8b61277 100644 --- a/test.rb +++ b/spec/test.rb @@ -1,5 +1,5 @@ require "benchmark" -require_relative "snowflake_client" +require "rb_snowflake_client" def new_client From f07e098044bac0129e1df357f26ad0bf5c64289e Mon Sep 17 00:00:00 2001 From: Stoica Alex Date: Tue, 21 Nov 2023 12:48:45 +0000 Subject: [PATCH 3/4] ci --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b11470f..2a97038 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,8 +8,10 @@ on: jobs: test: - runs-on: ubuntu-latest + permissions: + packages: write + contents: read steps: - uses: actions/checkout@v3 @@ -36,3 +38,8 @@ jobs: SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }} + - name: Build and publish to GitHub Package + uses: actionshub/publish-gem-to-github@v1.0.6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + owner: rinsed-org From f3e41e16c185bae77a18ec6a6adf44a163e09b8f Mon Sep 17 00:00:00 2001 From: Stoica Alex Date: Tue, 21 Nov 2023 15:31:13 +0000 Subject: [PATCH 4/4] release is now individual step --- .github/workflows/ci.yml | 5 ----- .github/workflows/release.yml | 23 +++++++++++++++++++++++ lib/rb_snowflake_client/version.rb | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a97038..db418b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,3 @@ jobs: SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }} - - name: Build and publish to GitHub Package - uses: actionshub/publish-gem-to-github@v1.0.6 - with: - token: ${{ secrets.GITHUB_TOKEN }} - owner: rinsed-org diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f83ba86 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,23 @@ +name: Release +on: + push: + branches: + - "master" +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@904f3fef85a9c80a3750cbe7d5159268fd5caa9f + with: + ruby-version: '3.0.6' + - name: Install dependencies + run: bundle install + - name: Build gem + run: rake build + - name: Build and publish to GitHub Package + uses: actionshub/publish-gem-to-github@v1.0.6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + owner: rinsed-org diff --git a/lib/rb_snowflake_client/version.rb b/lib/rb_snowflake_client/version.rb index c2dbe80..1de2d6c 100644 --- a/lib/rb_snowflake_client/version.rb +++ b/lib/rb_snowflake_client/version.rb @@ -1,3 +1,3 @@ module RbSnowflakeClient - VERSION = '0.0.1' + VERSION = '0.0.2' end