From 7edd01b12b56068d3e17cb4957e36e0e6917ab69 Mon Sep 17 00:00:00 2001 From: Drowze Date: Wed, 8 Jul 2020 22:56:59 +0100 Subject: [PATCH 1/6] Add github actions --- .github/workflows/workflow.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..bdb944b --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,33 @@ +env: + RUBY_VERSION: 2.7.1 + +name: build-test +on: [ push, pull_request ] +jobs: + rubocop-test: + name: Rubocop + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ env.RUBY_VERSION }} + - name: Install rubocop + run: gem install rubocop + - name: Check code + run: rubocop + rspec-test: + name: RSpec + needs: rubocop-test + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ env.RUBY_VERSION }} + - name: Install dependencies + run: | + gem install bundler + bundler install + - name: Run tests + run: bundler exec rake From e445351dd02f997f9692ae6932300a2a130f6e86 Mon Sep 17 00:00:00 2001 From: Drowze Date: Wed, 8 Jul 2020 23:07:58 +0100 Subject: [PATCH 2/6] Fix rubocop --- Gemfile.lock | 10 ++++------ lib/configuration.rb | 3 +-- lib/models/transaction.rb | 2 ++ lib/utils.rb | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 420f4bd..28559ad 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -54,7 +54,6 @@ GEM method_source (~> 1.0) public_suffix (4.0.5) rainbow (3.0.0) - rake (12.3.3) regexp_parser (1.7.1) representable (3.0.4) declarative (< 0.1.0) @@ -75,16 +74,16 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) rspec-support (3.9.3) - rubocop (0.86.0) + rubocop (0.87.1) parallel (~> 1.10) - parser (>= 2.7.0.1) + parser (>= 2.7.1.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.7) rexml - rubocop-ast (>= 0.0.3, < 1.0) + rubocop-ast (>= 0.1.0, < 1.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (0.0.3) + rubocop-ast (0.1.0) parser (>= 2.7.0.1) ruby-progressbar (1.10.1) signet (0.14.0) @@ -101,7 +100,6 @@ PLATFORMS DEPENDENCIES aspire_budget! pry - rake (~> 12.0) rspec (~> 3.0) rubocop diff --git a/lib/configuration.rb b/lib/configuration.rb index 5e5fa5b..19120bf 100644 --- a/lib/configuration.rb +++ b/lib/configuration.rb @@ -10,8 +10,7 @@ def self.configuration end class Configuration - attr_writer :session - attr_writer :spreadsheet_key + attr_writer :session, :spreadsheet_key def session @session || raise('Please set session') diff --git a/lib/models/transaction.rb b/lib/models/transaction.rb index e58890e..29a7dca 100644 --- a/lib/models/transaction.rb +++ b/lib/models/transaction.rb @@ -20,6 +20,7 @@ def self.from_row(header, row) new(**params) end + # rubocop:disable Metrics/ParameterLists def initialize(date:, outflow:, inflow:, category:, account:, memo:, status:) @date = Utils.parse_date(date) || Date.today @outflow = outflow || 0.0 @@ -29,6 +30,7 @@ def initialize(date:, outflow:, inflow:, category:, account:, memo:, status:) @memo = memo @status = status end + # rubocop:enable Metrics/ParameterLists def to_row(header) header.map do |h| diff --git a/lib/utils.rb b/lib/utils.rb index 2ea18a2..3d64b18 100644 --- a/lib/utils.rb +++ b/lib/utils.rb @@ -30,7 +30,7 @@ def parse_currency(value) end def serialize_currency(value) - format('%.2f', value) + format('%.2f', value: value) end def parse_status(value) From 57c5f5f817e36ee7cfd35ccb34c1567dfeddc038 Mon Sep 17 00:00:00 2001 From: Drowze Date: Wed, 8 Jul 2020 23:12:07 +0100 Subject: [PATCH 3/6] Fix wrong test command --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index bdb944b..29bcabd 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -30,4 +30,4 @@ jobs: gem install bundler bundler install - name: Run tests - run: bundler exec rake + run: bundler exec rspec From 418535082bd9df4a5fad1eabba0a59d678b3549e Mon Sep 17 00:00:00 2001 From: Drowze Date: Wed, 8 Jul 2020 23:50:23 +0100 Subject: [PATCH 4/6] Add simplecov --- .github/workflows/workflow.yml | 9 ++++++++- Gemfile | 1 + Gemfile.lock | 6 ++++++ spec/spec_helper.rb | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 29bcabd..50f2369 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -1,8 +1,9 @@ env: RUBY_VERSION: 2.7.1 + RAILS_ENABLE_CODE_COVERAGE: 1 name: build-test -on: [ push, pull_request ] +on: push jobs: rubocop-test: name: Rubocop @@ -31,3 +32,9 @@ jobs: bundler install - name: Run tests run: bundler exec rspec + - name: Upload coverage results + uses: actions/upload-artifact@master + if: always() + with: + name: coverage-report + path: coverage \ No newline at end of file diff --git a/Gemfile b/Gemfile index e13cd1a..d1a6a50 100644 --- a/Gemfile +++ b/Gemfile @@ -9,4 +9,5 @@ group :test, :development do gem 'pry' gem 'rspec', '~> 3.0' gem 'rubocop' + gem 'simplecov' end diff --git a/Gemfile.lock b/Gemfile.lock index 28559ad..1880491 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,6 +14,7 @@ GEM declarative (0.0.10) declarative-option (0.1.0) diff-lcs (1.4.1) + docile (1.3.2) faraday (1.0.1) multipart-post (>= 1.2, < 3) google-api-client (0.41.0) @@ -91,6 +92,10 @@ GEM faraday (>= 0.17.3, < 2.0) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) + simplecov (0.18.5) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov-html (0.12.2) uber (0.1.0) unicode-display_width (1.7.0) @@ -102,6 +107,7 @@ DEPENDENCIES pry rspec (~> 3.0) rubocop + simplecov BUNDLED WITH 2.1.4 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4f12a67..35adfde 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,8 @@ require 'bundler/setup' Bundler.require(:test) +SimpleCov.start if ENV['RAILS_ENABLE_CODE_COVERAGE'] + require 'support/google_drive_mock' RSpec.configure do |config| From e49a26f93c36dbc699cc8ef431e997e6c550226b Mon Sep 17 00:00:00 2001 From: Drowze Date: Thu, 9 Jul 2020 10:08:32 +0100 Subject: [PATCH 5/6] Move deps to gemspec ; add codecov --- .github/workflows/workflow.yml | 20 +++++++++++++++++--- Gemfile | 7 ------- Gemfile.lock | 9 ++++++++- README.md | 2 +- aspire_budget.gemspec | 5 +++++ spec/spec_helper.rb | 5 ++++- 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 50f2369..5a5721a 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -1,6 +1,6 @@ env: RUBY_VERSION: 2.7.1 - RAILS_ENABLE_CODE_COVERAGE: 1 + ENABLE_CODE_COVERAGE: 1 name: build-test on: push @@ -32,9 +32,23 @@ jobs: bundler install - name: Run tests run: bundler exec rspec - - name: Upload coverage results + - name: Upload resultset artifact uses: actions/upload-artifact@master if: always() with: name: coverage-report - path: coverage \ No newline at end of file + path: coverage + upload-codecov: + name: Codecov + needs: rspec-test + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v1 + - name: Download resultset artifact + uses: actions/download-artifact@v1 + with: + name: coverage-report + - uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: coverage-report/.resultset.json diff --git a/Gemfile b/Gemfile index d1a6a50..f036d42 100644 --- a/Gemfile +++ b/Gemfile @@ -4,10 +4,3 @@ source 'https://rubygems.org' # Specify your gem's dependencies in aspire_budget.gemspec gemspec - -group :test, :development do - gem 'pry' - gem 'rspec', '~> 3.0' - gem 'rubocop' - gem 'simplecov' -end diff --git a/Gemfile.lock b/Gemfile.lock index 1880491..a7b944b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,7 +10,12 @@ GEM addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) ast (2.4.1) + codecov (0.1.19) + colorize + json + simplecov coderay (1.1.3) + colorize (0.8.1) declarative (0.0.10) declarative-option (0.1.0) diff-lcs (1.4.1) @@ -37,6 +42,7 @@ GEM os (>= 0.9, < 2.0) signet (~> 0.14) httpclient (2.8.3) + json (2.3.1) jwt (2.2.1) memoist (0.16.2) method_source (1.0.0) @@ -104,9 +110,10 @@ PLATFORMS DEPENDENCIES aspire_budget! + codecov pry rspec (~> 3.0) - rubocop + rubocop (~> 0.87.1) simplecov BUNDLED WITH diff --git a/README.md b/README.md index 22ce3f4..039d16e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -2# Aspire Budget - Ruby +# Aspire Budget - Ruby This is an independent project implementing a Ruby for Aspire Budgeting spreadsheets, leveraging from the use of another great gem: `google_drive`. The idea of this gem is to enable a good API to be easily implemented, allowing more powerful and complex tools to emerge. diff --git a/aspire_budget.gemspec b/aspire_budget.gemspec index a1a1d19..f8339cf 100644 --- a/aspire_budget.gemspec +++ b/aspire_budget.gemspec @@ -27,4 +27,9 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_runtime_dependency 'google_drive', '~> 3.0' + + spec.add_development_dependency 'pry' + spec.add_development_dependency 'rspec', '~> 3.0' + spec.add_development_dependency 'rubocop', '~> 0.87.1' + spec.add_development_dependency 'simplecov' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 35adfde..615f19a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,7 +3,10 @@ require 'bundler/setup' Bundler.require(:test) -SimpleCov.start if ENV['RAILS_ENABLE_CODE_COVERAGE'] +if ENV['ENABLE_CODE_COVERAGE'] + require 'simplecov' + SimpleCov.start +end require 'support/google_drive_mock' From ee483b984effe2e08dbacc58131532b84bf19e56 Mon Sep 17 00:00:00 2001 From: Drowze Date: Thu, 30 Jul 2020 09:19:18 +0100 Subject: [PATCH 6/6] Reporting codecov error, see codecov/codecov-action#62 --- report-codecov-error | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 report-codecov-error diff --git a/report-codecov-error b/report-codecov-error new file mode 100644 index 0000000..e69de29