Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: coverage #94

Open
wants to merge 18 commits into
base: beta
Choose a base branch
from
7 changes: 5 additions & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
plugins:
rubocop:
version: "2"
checks:
argument-count:
enabled: true
test_reporter:
formatter: simplecov
173 changes: 92 additions & 81 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["3.0", "3.1", "3.2"]
# ruby-version: ["3.0", "3.1", "3.2"]
ruby-version: [ "3.2" ]
packages:
- forest_admin_agent
# - forest_admin_agent
- forest_admin_datasource_active_record
- forest_admin_datasource_customizer
- forest_admin_datasource_toolkit
- forest_admin_test_toolkit
- forest_admin_rails
# - forest_admin_datasource_customizer
# - forest_admin_datasource_toolkit
# - forest_admin_test_toolkit
# - forest_admin_rails

steps:
- name: Checkout
Expand All @@ -39,22 +40,23 @@ jobs:
- name: Install dependencies on packages
run: cd packages/${{ matrix.packages }} && bundle install && cd -

- name: Run RuboCop
run: bundle exec rubocop
# - name: Run RuboCop
# run: bundle exec rubocop

test:
name: Test
runs-on: ubuntu-latest
needs: [lint]
strategy:
matrix:
ruby-version: ["3.0", "3.1", "3.2"]
# ruby-version: ["3.0", "3.1", "3.2"]
ruby-version: [ "3.2" ]
packages:
- forest_admin_agent
# - forest_admin_agent
- forest_admin_datasource_active_record
- forest_admin_datasource_customizer
- forest_admin_datasource_toolkit
- forest_admin_rails
# - forest_admin_datasource_customizer
# - forest_admin_datasource_toolkit
# - forest_admin_rails
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -72,78 +74,87 @@ jobs:
- name: Test
run: cd packages/${{ matrix.packages }} && BUNDLE_GEMFILE=Gemfile-test bundle install && BUNDLE_GEMFILE=Gemfile-test bundle exec rspec --color --format doc && cd -

- name: Debug coverage directory
run: |
echo "Inspecting coverage directory:"
cd packages/forest_admin_datasource_active_record
ls -R coverage || echo "Coverage directory not found"

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.ruby-version }}-${{ matrix.packages }}
path: packages/${{ matrix.packages }}/coverage/*
retention-days: 1

coverage:
name: Coverage
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download coverage reports
uses: actions/download-artifact@v4
with:
path: reports

- name: Send coverage
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: |
${{github.workspace}}/reports/3.2-forest_admin_agent/coverage.json:simplecov
${{github.workspace}}/reports/3.2-forest_admin_datasource_active_record/coverage.json:simplecov
${{github.workspace}}/reports/3.2-forest_admin_datasource_toolkit/coverage.json:simplecov
# ${{github.workspace}}/reports/3.2-forest_admin_rails/coverage.json:simplecov
debug: true

deploy:
name: Release package
runs-on: ubuntu-latest
needs: [coverage]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false # GITHUB_TOKEN must not be set for the semantic release

- uses: actions/setup-node@v4
with:
node-version: 18.14.0

- uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install semantic release dependencies
run: yarn

- name: Setup credentials
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${{secrets.GEM_HOST_API_KEY}}\n" > $HOME/.gem/credentials

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
semantic_version: 17.3.0
env:
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# coverage:
# name: Coverage
# runs-on: ubuntu-latest
# needs: [test]
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Download coverage reports
# uses: actions/download-artifact@v4
# with:
# path: reports
#
# - name: Debug coverage file
# run: |
# echo "Contents of coverage.json:"
# ls -R ${{ github.workspace }}/reports || echo "Reports directory not found"
# cat ${{ github.workspace }}/reports/3.2-forest_admin_datasource_active_record/coverage.json || echo "coverage.json not found"
#
# - name: Send coverage
# uses: paambaati/[email protected]
# env:
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
# with:
# coverageLocations: |
# ${{github.workspace}}/reports/3.2-forest_admin_datasource_active_record/coverage.json:simplecov
# debug: true

# deploy:
# name: Release package
# runs-on: ubuntu-latest
# needs: [coverage]
# if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta')
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# persist-credentials: false # GITHUB_TOKEN must not be set for the semantic release
#
# - uses: actions/setup-node@v4
# with:
# node-version: 18.14.0
#
# - uses: actions/cache@v4
# with:
# path: "**/node_modules"
# key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
#
# - name: Install semantic release dependencies
# run: yarn
#
# - name: Setup credentials
# run: |
# mkdir -p $HOME/.gem
# touch $HOME/.gem/credentials
# chmod 0600 $HOME/.gem/credentials
# printf -- "---\n:rubygems_api_key: ${{secrets.GEM_HOST_API_KEY}}\n" > $HOME/.gem/credentials
#
# - name: Semantic Release
# uses: cycjimmy/semantic-release-action@v2
# id: semantic
# with:
# semantic_version: 17.3.0
# env:
# GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
# GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
# GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
# GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
add_filter 'spec'
end

SimpleCov.at_exit do
result = SimpleCov.result
coverage_percent = result.covered_percent
puts "Coverage Report Generated"
puts "Covered Percent: #{coverage_percent}%"
end

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('dummy/config/environment', __dir__)
Rails.application.eager_load!
Expand Down
Loading