diff --git a/.github/workflows/gem-workflow.yaml b/.github/workflows/gem-workflow.yaml new file mode 100644 index 0000000..9786b6f --- /dev/null +++ b/.github/workflows/gem-workflow.yaml @@ -0,0 +1,71 @@ +name: Test and Deploy +on: + push: + pull_request: + release: + types: [created] +jobs: + rubocop: + strategy: + matrix: + ruby-version: [2.6.3, 2.6.6, 2.7.1] + runs-on: [ubuntu-latest] + steps: + - uses: actions/checkout@v2 + with: + persist-credentials: false + fetch-depth: 0 + - name: Ruby Setup and Bundle + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - run: bundle exec rubocop + rspec: + strategy: + matrix: + ruby-version: [2.6.3, 2.6.6, 2.7.1] + runs-on: [ubuntu-latest] + steps: + - uses: actions/checkout@v2 + with: + persist-credentials: false + fetch-depth: 0 + - name: Ruby Setup and Bundle + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - name: rspec and report to coveralls + run: bundle exec rspec --order rand + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel: true + flag-name: run-${{ matrix.ruby-version }} + publish: + runs-on: ubuntu-latest + needs: ['rubocop', 'rspec'] + if: github.event_name == 'release' && github.event.action == 'created' + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + fetch-depth: 0 + - name: Ruby Setup and Bundle + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7.1 + bundler-cache: true + - name: Publish to RubyGems + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials + gem build *.gemspec + gem push *.gem + env: + GEM_HOST_API_KEY: "${{ secrets.RUBY_GEM_KEY }}" \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index b59b074..562f956 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,12 @@ PATH remote: . specs: - ledger_sync-stripe (0.1.0) + ledger_sync-stripe (0.1.1) dotenv ledger_sync nokogiri oauth2 + stripe GEM remote: https://rubygems.org/ @@ -20,12 +21,8 @@ GEM zeitwerk (~> 2.2, >= 2.2.2) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - akami (1.3.1) - gyoku (>= 0.4.0) - nokogiri ast (2.4.1) awesome_print (1.8.0) - builder (3.2.4) bump (0.9.0) byebug (11.1.3) childprocess (4.0.0) @@ -40,24 +37,22 @@ GEM tins (~> 1.6) crack (0.4.4) diff-lcs (1.4.4) - docile (1.3.2) + docile (1.3.5) dotenv (2.7.6) - dry-configurable (0.11.6) + dry-configurable (0.12.1) concurrent-ruby (~> 1.0) - dry-core (~> 0.4, >= 0.4.7) - dry-equalizer (~> 0.2) + dry-core (~> 0.5, >= 0.5.0) dry-container (0.7.2) concurrent-ruby (~> 1.0) dry-configurable (~> 0.1, >= 0.1.3) - dry-core (0.4.9) + dry-core (0.5.0) concurrent-ruby (~> 1.0) dry-equalizer (0.3.0) dry-inflector (0.2.0) dry-initializer (3.0.4) - dry-logic (1.0.8) + dry-logic (1.2.0) concurrent-ruby (~> 1.0) - dry-core (~> 0.2) - dry-equalizer (~> 0.2) + dry-core (~> 0.5, >= 0.5) dry-schema (1.5.6) concurrent-ruby (~> 1.0) dry-configurable (~> 0.8, >= 0.8.3) @@ -66,11 +61,10 @@ GEM dry-initializer (~> 3.0) dry-logic (~> 1.0) dry-types (~> 1.4) - dry-types (1.4.0) + dry-types (1.5.1) concurrent-ruby (~> 1.0) dry-container (~> 0.3) - dry-core (~> 0.4, >= 0.4.4) - dry-equalizer (~> 0.3) + dry-core (~> 0.5, >= 0.5) dry-inflector (~> 0.1, >= 0.1.2) dry-logic (~> 1.0, >= 1.0.2) dry-validation (1.5.6) @@ -82,27 +76,28 @@ GEM dry-schema (~> 1.5, >= 1.5.2) factory_bot (6.1.0) activesupport (>= 5.0.0) - faraday (1.1.0) + faraday (1.4.1) + faraday-excon (~> 1.1) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.1) multipart-post (>= 1.2, < 3) - ruby2_keywords + ruby2_keywords (>= 0.0.4) faraday-detailed_logger (2.3.0) faraday (>= 0.8, < 2) + faraday-excon (1.1.0) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.1.0) faraday_middleware (1.0.0) faraday (~> 1.0) fingerprintable (1.2.1) colorize - gyoku (1.3.1) - builder (>= 2.1.2) hashdiff (1.0.1) - httpi (2.4.5) - rack - socksify i18n (1.8.5) concurrent-ruby (~> 1.0) iniparse (1.5.0) - json (2.3.1) - jwt (2.2.2) - ledger_sync (1.6.0) + json (2.5.1) + jwt (2.2.3) + ledger_sync (2.0.0) activemodel colorize dry-schema (~> 1.5.4) @@ -111,29 +106,27 @@ GEM faraday-detailed_logger faraday_middleware fingerprintable (>= 1.2.1) - netsuite (~> 0.8.6) nokogiri - oauth2 + openssl (~> 2.2.0) pd_ruby + rack (~> 2.2.3) resonad simply_serializable (>= 1.5.1) - stripe (~> 5.26.0) - mini_portile2 (2.4.0) + mini_portile2 (2.5.1) minitest (5.14.2) multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.1.1) - netsuite (0.8.6) - savon (>= 2.3.0, <= 2.11.1) - nokogiri (1.10.10) - mini_portile2 (~> 2.4.0) - nori (2.6.0) - oauth2 (1.4.4) + nokogiri (1.11.3) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) + oauth2 (1.4.7) faraday (>= 0.8, < 2.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) + openssl (2.2.0) overcommit (0.57.0) childprocess (>= 0.6.3, < 5) iniparse (~> 1.4) @@ -143,11 +136,12 @@ GEM pd_ruby (0.2.3) colorize public_suffix (4.0.6) + racc (1.5.2) rack (2.2.3) rainbow (3.0.0) rake (13.0.1) regexp_parser (1.8.2) - resonad (1.3.0) + resonad (1.4.0) rexml (3.2.4) rspec (3.10.0) rspec-core (~> 3.10.0) @@ -174,15 +168,7 @@ GEM rubocop-ast (1.1.1) parser (>= 2.7.1.5) ruby-progressbar (1.10.1) - ruby2_keywords (0.0.2) - savon (2.11.1) - akami (~> 1.2) - builder (>= 2.1.2) - gyoku (~> 1.2) - httpi (~> 2.3) - nokogiri (>= 1.4.0) - nori (~> 2.4) - wasabi (~> 3.4) + ruby2_keywords (0.0.4) simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) @@ -190,22 +176,17 @@ GEM simplecov-html (0.10.2) simply_serializable (1.5.1) fingerprintable (>= 1.2.1) - socksify (1.7.1) - stripe (5.26.0) + stripe (5.32.1) sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) - thor (1.0.1) + thor (1.1.0) thread_safe (0.3.6) - tins (1.26.0) + tins (1.28.0) sync tzinfo (1.2.7) thread_safe (~> 0.1) unicode-display_width (1.7.0) - wasabi (3.6.1) - addressable - httpi (~> 2.0) - nokogiri (>= 1.4.2) webmock (3.9.4) addressable (>= 2.3.6) crack (>= 0.3.2) diff --git a/ledger_sync-stripe.gemspec b/ledger_sync-stripe.gemspec index e92fe2e..0472010 100644 --- a/ledger_sync-stripe.gemspec +++ b/ledger_sync-stripe.gemspec @@ -42,4 +42,5 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency('ledger_sync') spec.add_runtime_dependency('nokogiri', '>= 0') spec.add_runtime_dependency('oauth2', '>= 0') + spec.add_runtime_dependency('stripe', '>= 0') end diff --git a/lib/ledger_sync/stripe.rb b/lib/ledger_sync/stripe.rb index 4704f9b..623f2d9 100644 --- a/lib/ledger_sync/stripe.rb +++ b/lib/ledger_sync/stripe.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'ledger_sync' +require 'stripe' module LedgerSync module Stripe diff --git a/lib/ledger_sync/stripe/version.rb b/lib/ledger_sync/stripe/version.rb index 8330274..861a140 100644 --- a/lib/ledger_sync/stripe/version.rb +++ b/lib/ledger_sync/stripe/version.rb @@ -3,15 +3,13 @@ # :nocov: module LedgerSync module Stripe - VERSION = '0.1.0' + VERSION = '0.1.1' - def self.version(args = {}) - pre = args.fetch(:pre, false) - - if !pre && (!ENV['TRAVIS'] || ENV.fetch('TRAVIS_TAG', '') != '') - VERSION + def self.version + if ENV['PRE_RELEASE'] + "#{VERSION}.pre.#{ENV['GITHUB_RUN_NUMBER']}" else - "#{VERSION}.pre.#{ENV['TRAVIS_BUILD_NUMBER']}" + VERSION end end end diff --git a/spec/customer/create_spec.rb b/spec/customer/create_spec.rb index db92532..2f1775a 100644 --- a/spec/customer/create_spec.rb +++ b/spec/customer/create_spec.rb @@ -4,6 +4,14 @@ support :stripe_shared_examples -RSpec.describe LedgerSync::Stripe::Customer::Operations::Create, operation: true do - it_behaves_like 'a stripe operation' +module LedgerSync + module Stripe + class Customer + module Operations + RSpec.describe Create, operation: true do + it_behaves_like 'a stripe operation' + end + end + end + end end diff --git a/spec/qa/customers_spec.rb b/spec/qa/customers_spec.rb index 0fb309e..3707611 100644 --- a/spec/qa/customers_spec.rb +++ b/spec/qa/customers_spec.rb @@ -10,7 +10,7 @@ } end let(:resource) do - FactoryBot.create(:customer) + FactoryBot.create(:stripe_customer) end it_behaves_like 'a full stripe resource' diff --git a/spec/version_spec.rb b/spec/version_spec.rb index 3e3a074..56c7ea1 100644 --- a/spec/version_spec.rb +++ b/spec/version_spec.rb @@ -2,7 +2,16 @@ require 'spec_helper' -RSpec.describe LedgerSync::Stripe do - it { expect(described_class).to respond_to(:version) } - it { expect(described_class.version(pre: true)).to include('.pre.') } +module LedgerSync + RSpec.describe Stripe do + it 'has a version number' do + expect(described_class).to respond_to(:version) + end + + it 'has a version number in pre release' do + ClimateControl.modify PRE_RELEASE: 'true' do + expect(described_class.version).to include('pre') + end + end + end end