Skip to content

Commit

Permalink
Add CodeClimate (#2)
Browse files Browse the repository at this point in the history
Configure CodeClimate analysis and code coverage report.
  • Loading branch information
avmnu-sng committed Jan 18, 2022
1 parent f1ea796 commit faeca42
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}

- name: Setup Code Climate test-reporter
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: Install Dependencies
run: |
gem update --system 3.2.3
Expand All @@ -54,3 +61,56 @@ jobs:
- name: Run Tests
run: bundle exec rake

- name: Format Coverage Report
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
GIT_BRANCH: ${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}
GIT_COMMIT_SHA: ${{ github.sha }}
run: |
mkdir -p coverage-artifacts
./cc-test-reporter format-coverage coverage/coverage.json --input-type simplecov --output coverage-artifacts/ruby-${{ matrix.ruby }}-coverage.json
- name: Save Coverage Report
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v2
with:
name: ruby-${{ matrix.ruby }}-coverage.json
path: coverage-artifacts/ruby-${{ matrix.ruby }}-coverage.json
retention-days: 1

coverage:
needs: [ 'main' ]
name: coverage
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup 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
./cc-test-reporter before-build
- name: Download Coverage Reports
uses: actions/download-artifact@v2
with:
path: coverage-artifacts-temp

- name: Finalize Artifacts
run: |
mkdir -p coverage-artifacts
find coverage-artifacts-temp -mindepth 2 -type f -exec mv -i '{}' coverage-artifacts ';'
- name: Upload Coverage
env:
GIT_BRANCH: ${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}
GIT_COMMIT_SHA: ${{ github.sha }}
CC_TEST_REPORTER_ID: "23d80ff322cb6f334d19fd049df07430140bc2c9eb9567711a17387a5378f9c1"
run: |
./cc-test-reporter sum-coverage coverage-artifacts/ruby-*-coverage.json --parts 11 --output coverage-artifacts/coverage.json
./cc-test-reporter upload-coverage --input coverage-artifacts/coverage.json
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![Maintainability](https://api.codeclimate.com/v1/badges/906b5c8d15a66897d350/maintainability)](https://codeclimate.com/github/avmnu-sng/clepsydra/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/906b5c8d15a66897d350/test_coverage)](https://codeclimate.com/github/avmnu-sng/clepsydra/test_coverage)

# Clepsydra

**Clepsydra** is an instrumentation tool allowing instrumenting events. You can
Expand Down
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

require 'pry'
require 'simplecov'
require 'simplecov_json_formatter'
require 'timecop'

require 'clepsydra'

SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::JSONFormatter
].freeze

RSpec.configure do |config|
config.example_status_persistence_file_path = 'spec/examples.txt'
config.disable_monkey_patching!
Expand Down

0 comments on commit faeca42

Please sign in to comment.