Skip to content

Commit

Permalink
Merge pull request #4 from patrick204nqh/ci-workflow
Browse files Browse the repository at this point in the history
[CI-CD] Add/update Ruby Test and Coverage workflow
  • Loading branch information
patrick204nqh authored Dec 27, 2024
2 parents 9cf3f82 + 4f981bc commit c4b5fa4
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 54 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI with Code Climate Coverage

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: [3.0, 3.1, 3.2]

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Install dependencies
run: bundle install

- name: Run tests and generate coverage
run: bundle exec rspec

- name: Prepare Code Climate test reporter
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
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: Upload coverage to Code Climate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
./cc-test-reporter after-build --coverage-input-type=lcov --exit-code $?
27 changes: 0 additions & 27 deletions .github/workflows/main.yml

This file was deleted.

13 changes: 8 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ source "https://rubygems.org"
# Specify your gem's dependencies in trace_viz.gemspec
gemspec

gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"
gem "rubocop", "~> 1.65"
gem "rubocop-shopify", "~> 2.15.1"
gem "pry"
group :development, :test do
gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"
gem "rubocop", "~> 1.65"
gem "rubocop-shopify", "~> 2.15.1"
gem "simplecov", "~> 0.22", require: false
gem "simplecov-lcov", "~> 0.8.0", require: false
end
36 changes: 20 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
coderay (1.1.3)
diff-lcs (1.5.1)
json (2.8.2)
docile (1.4.1)
json (2.9.1)
language_server-protocol (3.17.0.3)
method_source (1.1.0)
parallel (1.26.3)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
pry (0.15.0)
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.9.3)
regexp_parser (2.10.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand All @@ -35,37 +31,45 @@ GEM
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rubocop (1.69.0)
rspec-support (3.13.2)
rubocop (1.69.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.36.1, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.36.2)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
rubocop-shopify (2.15.1)
rubocop (~> 1.51)
ruby-progressbar (1.13.0)
unicode-display_width (3.1.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
unicode-display_width (3.1.3)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)

PLATFORMS
arm64-darwin-23
ruby
x86_64-linux

DEPENDENCIES
pry
rake (~> 13.0)
rspec (~> 3.0)
rubocop (~> 1.65)
rubocop-shopify (~> 2.15.1)
simplecov (~> 0.22)
simplecov-lcov (~> 0.8.0)
trace_viz!

BUNDLED WITH
2.5.17
2.6.1
10 changes: 4 additions & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# frozen_string_literal: true

require_relative "support/coverage"

require "trace_viz"

Dir[File.expand_path("support/**/*.rb", __dir__)].each { |file| require file }

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"

# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with(:rspec) { |c| c.syntax = :expect }

config.expect_with(:rspec) do |c|
c.syntax = :expect
end
# Add any additional RSpec configuration here
end
26 changes: 26 additions & 0 deletions spec/support/coverage.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

if ENV["CI"]
require "simplecov"
require "simplecov-lcov"

SimpleCov::Formatter::LcovFormatter.config do |c|
c.output_directory = "coverage"
c.report_with_single_file = true
c.lcov_file_name = "lcov.info"
end
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter

SimpleCov.start do
add_filter "/spec/"
track_files "{lib}/**/*.rb"

minimum_coverage(90)
end

at_exit do
SimpleCov.result.format!
end

puts "SimpleCov coverage started..."
end

0 comments on commit c4b5fa4

Please sign in to comment.