fix: workflow for coverage upload to codeclimate #614
Workflow file for this run
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
name: Lint, Test, Coverage and Deploy | |
on: | |
push: | |
branches: | |
- main | |
- beta | |
pull_request: | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
ruby-version: ["3.0", "3.1", "3.2"] | |
packages: | |
- forest_admin_agent | |
- forest_admin_datasource_active_record | |
- forest_admin_datasource_customizer | |
- forest_admin_datasource_toolkit | |
- forest_admin_test_toolkit | |
- forest_admin_rails | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Ruby ${{ matrix.ruby-version }} | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ matrix.ruby-version }} | |
- name: Install dependencies on main repo | |
run: | | |
gem install bundler | |
bundle install | |
- name: Install dependencies on packages | |
run: cd packages/${{ matrix.packages }} && bundle install && cd - | |
- 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"] | |
packages: | |
- forest_admin_agent | |
- forest_admin_datasource_active_record | |
- forest_admin_datasource_customizer | |
- forest_admin_datasource_toolkit | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Ruby ${{ matrix.ruby-version }} | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ matrix.ruby-version }} | |
- name: Install dependencies on main repo | |
run: | | |
gem install bundler | |
bundle install | |
- 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: Upload coverage | |
if: ${{ matrix.ruby-version == '3.2' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.ruby-version }}-${{ matrix.packages }} | |
path: packages/${{ matrix.packages }}/coverage/* | |
retention-days: 1 | |
coverage: | |
name: Send Coverage | |
runs-on: ubuntu-latest | |
needs: [test] | |
strategy: | |
matrix: | |
ruby-version: ["3.2"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download coverage reports | |
uses: actions/download-artifact@v4 | |
with: | |
path: reports | |
- name: Debug coverage directory | |
run: | | |
echo "Debugging reports directory:" | |
tree -a reports || ls -la reports | |
- name: Send coverage | |
uses: paambaati/[email protected] | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
with: | |
coverageLocations: | | |
${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_agent/coverage.json:simplecov | |
${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_active_record/coverage.json:simplecov | |
${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_customizer/coverage.json:simplecov | |
${{ github.workspace }}/reports/${{ matrix.ruby-version }}-forest_admin_datasource_toolkit/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 }} |