-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from patrick204nqh/ci-workflow
[CI-CD] Add/update Ruby Test and Coverage workflow
- Loading branch information
Showing
6 changed files
with
102 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 $? |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |