From ec0f88728a77aba7d2b26a9505632acc8ef734ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Bol=C3=ADvar?= Date: Wed, 10 Jul 2024 09:57:41 +0200 Subject: [PATCH] Add coverage to CI --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 19 +++++++++++++++++-- .simplecov | 2 ++ Gemfile | 4 ++++ Gemfile.lock | 33 ++++++++++++++++++++++----------- spec/spec_helper.rb | 6 ++++++ 6 files changed, 52 insertions(+), 14 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d486011..182d596 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,7 +20,7 @@ concurrency: jobs: main: - name: Tests + name: Lint runs-on: ubuntu-latest timeout-minutes: 30 services: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a69ae39..3b0abc9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,9 +20,20 @@ concurrency: jobs: main: - name: Lint + name: Tests runs-on: ubuntu-latest timeout-minutes: 30 + services: + postgres: + image: postgres:11 + ports: ["5432:5432"] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + POSTGRES_PASSWORD: postgres env: DATABASE_USERNAME: postgres DATABASE_PASSWORD: postgres @@ -56,7 +67,7 @@ jobs: - run: RAILS_ENV=test bundle exec rails assets:precompile name: Precompile assets working-directory: ./spec/decidim_dummy_app/ - - run: bundle exec rspec + - run: CI=1 bundle exec rspec name: RSpec - uses: codecov/codecov-action@v3 - uses: actions/upload-artifact@v3 @@ -65,3 +76,7 @@ jobs: name: screenshots path: ./spec/decidim_dummy_app/tmp/screenshots if-no-files-found: ignore + - uses: coverallsapp/github-action@master + name: Coveralls + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.simplecov b/.simplecov index 9de065b..2f0aec0 100644 --- a/.simplecov +++ b/.simplecov @@ -3,6 +3,8 @@ SimpleCov.start do root ENV.fetch("ENGINE_ROOT", nil) + track_files "{app,lib}/**/*.rb" + add_filter "lib/generators" add_filter "/spec" end diff --git a/Gemfile b/Gemfile index d10e83c..60f0390 100644 --- a/Gemfile +++ b/Gemfile @@ -29,3 +29,7 @@ group :development do gem "spring-watcher-listen", "~> 2.0" gem "web-console", "~> 4.2" end + +group :test do + gem "coveralls_reborn", require: false +end diff --git a/Gemfile.lock b/Gemfile.lock index 04031cd..ce1cce5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -129,6 +129,11 @@ GEM childprocess (5.0.0) commonmarker (0.23.10) concurrent-ruby (1.3.3) + coveralls_reborn (0.28.0) + simplecov (~> 0.22.0) + term-ansicolor (~> 1.7) + thor (~> 1.2) + tins (~> 1.32) crack (1.0.0) bigdecimal rexml @@ -356,17 +361,7 @@ GEM faraday-net_http (>= 2.0, < 3.2) faraday-net_http (3.1.0) net-http - ffi (1.17.0) - ffi (1.17.0-aarch64-linux-gnu) - ffi (1.17.0-aarch64-linux-musl) - ffi (1.17.0-arm-linux-gnu) - ffi (1.17.0-arm-linux-musl) - ffi (1.17.0-arm64-darwin) - ffi (1.17.0-x86-linux-gnu) - ffi (1.17.0-x86-linux-musl) - ffi (1.17.0-x86_64-darwin) - ffi (1.17.0-x86_64-linux-gnu) - ffi (1.17.0-x86_64-linux-musl) + ffi (1.16.3) file_validators (3.0.0) activemodel (>= 3.2) mime-types (>= 1.0) @@ -488,6 +483,8 @@ GEM tomlrb mixlib-shellout (3.2.8) chef-utils + mize (0.4.1) + protocol (~> 2.0) msgpack (1.7.2) multi_xml (0.6.0) net-http (0.4.1) @@ -576,6 +573,8 @@ GEM actionmailer (>= 3) net-smtp premailer (~> 1.7, >= 1.7.9) + protocol (2.0.0) + ruby_parser (~> 3.0) psych (4.0.6) stringio public_suffix (6.0.0) @@ -718,6 +717,9 @@ GEM rubyXL (3.4.27) nokogiri (>= 1.10.8) rubyzip (>= 1.3.0) + ruby_parser (3.21.1) + racc (~> 1.5) + sexp_processor (~> 4.16) rubyzip (2.3.2) sass (3.7.4) sass-listen (~> 4.0.0) @@ -732,6 +734,7 @@ GEM websocket (~> 1.0) semantic_range (3.0.0) seven_zip_ruby (1.3.0) + sexp_processor (4.17.2) shakapacker (7.1.0) activesupport (>= 5.2) rack-proxy (>= 0.6.1) @@ -764,12 +767,19 @@ GEM ssrf_filter (1.1.2) stringio (3.1.1) strscan (3.1.0) + sync (0.5.0) temple (0.10.3) + term-ansicolor (1.10.2) + mize + tins (~> 1.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) thor (1.3.1) tilt (2.3.0) timeout (0.4.1) + tins (1.33.0) + bigdecimal + sync tomlrb (2.0.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) @@ -836,6 +846,7 @@ PLATFORMS DEPENDENCIES bootsnap (~> 1.4) byebug (~> 11.0) + coveralls_reborn decidim (~> 0.28.0) decidim-dev (~> 0.28.0) decidim-ub! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a30b234..e67ff19 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,12 @@ # frozen_string_literal: true require "decidim/dev" +require "simplecov" + +if ENV["CI"] + require "coveralls" + SimpleCov.formatter = Coveralls::SimpleCov::Formatter +end ENV["ENGINE_ROOT"] = File.dirname(__dir__)