From a14a6fbf77cdb99beda18c8135024b61f0ac624d Mon Sep 17 00:00:00 2001 From: Erik Berlin Date: Tue, 21 May 2024 14:04:36 -0700 Subject: [PATCH] Add Maintainability and Test Coverage badges --- .github/workflows/lint.yml | 2 +- .github/workflows/mutant.yml | 2 +- .github/workflows/steep.yml | 2 +- .github/workflows/test.yml | 26 +++++++++++++++++++------- Gemfile | 1 + README.md | 2 ++ test/test_helper.rb | 3 +++ 7 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 01821ad..1c1b36a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: Linter +name: linter on: [push, pull_request] jobs: build: diff --git a/.github/workflows/mutant.yml b/.github/workflows/mutant.yml index c82f5e3..e6bd92c 100644 --- a/.github/workflows/mutant.yml +++ b/.github/workflows/mutant.yml @@ -1,4 +1,4 @@ -name: Mutant +name: mutation testing on: [push, pull_request] jobs: build: diff --git a/.github/workflows/steep.yml b/.github/workflows/steep.yml index 713cf94..f1ebed7 100644 --- a/.github/workflows/steep.yml +++ b/.github/workflows/steep.yml @@ -1,4 +1,4 @@ -name: Type Checker +name: type checker on: [push, pull_request] jobs: build: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7207133..bb415c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Tests +name: tests on: [push, pull_request] jobs: build: @@ -7,9 +7,21 @@ jobs: ruby: ["3.1", "3.2", "3.3"] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - run: bundle exec rake test + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Set up Code Climate test reporter + run: | + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter + - name: Before build + run: ./cc-test-reporter before-build + - name: Run tests + run: bundle exec rake test + - name: After build + if: always() # Ensures that this step runs even if the test step fails + run: | + EXIT_CODE=${{ job.status == 'success' && '0' || '1' }} + ./cc-test-reporter after-build --exit-code $EXIT_CODE -t simplecov -r 503b90af6f7d19fdb5efdfbebc093049baaf24fe6f15a206240ceef2a438620d diff --git a/Gemfile b/Gemfile index 976fe0f..7374d52 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,7 @@ gem "rubocop-minitest", ">= 0.31" gem "rubocop-performance", ">= 1.18" gem "rubocop-rake", ">= 0.6" gem "simplecov", ">= 0.22" +gem "simplecov_json_formatter", ">= 0.1.4" gem "standard", ">= 1.30.1" gem "steep", ">= 1.5.3" gem "webmock", ">= 3.18.1" diff --git a/README.md b/README.md index de288ad..3e3082b 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![Linter](https://github.com/sferik/x-ruby/actions/workflows/lint.yml/badge.svg)](https://github.com/sferik/x-ruby/actions/workflows/lint.yml) [![Mutant](https://github.com/sferik/x-ruby/actions/workflows/mutant.yml/badge.svg)](https://github.com/sferik/x-ruby/actions/workflows/mutant.yml) [![Typer Checker](https://github.com/sferik/x-ruby/actions/workflows/steep.yml/badge.svg)](https://github.com/sferik/x-ruby/actions/workflows/steep.yml) +[![Test Coverage](https://api.codeclimate.com/v1/badges/40bbddf2c9170742ca9e/test_coverage)](https://codeclimate.com/github/sferik/x-ruby/test_coverage) +[![Maintainability](https://api.codeclimate.com/v1/badges/40bbddf2c9170742ca9e/maintainability)](https://codeclimate.com/github/sferik/x-ruby/maintainability) [![Gem Version](https://badge.fury.io/rb/x.svg)](https://rubygems.org/gems/x) # A [Ruby](https://www.ruby-lang.org) interface to the [X API](https://developer.x.com) diff --git a/test/test_helper.rb b/test/test_helper.rb index 9254213..7eb11e3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,9 @@ unless $PROGRAM_NAME.end_with?("mutant") require "simplecov" + require "simplecov_json_formatter" + + SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::JSONFormatter] SimpleCov.start do add_filter "test"