Skip to content

Commit

Permalink
ci: 👷 improve test result and coverage reporting (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafasoares authored May 27, 2024
1 parent 400c625 commit 7c24afa
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish gem
name: publish

on:
push:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/reports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: reports

on:
workflow_run:
workflows: ["tests"]
types:
- completed

permissions:
contents: read
actions: read
checks: write

jobs:
report:
name: Report test results

runs-on: ubuntu-latest

steps:
- uses: dorny/test-reporter@v1
with:
name: rspec
path: spec/reports
artifact: test-results
reporter: rspec-json

coverage:
name: Report code coverage
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@v4
with:
name: code-coverage
path: coverage

- uses: paambaati/codeclimate-action@v6
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
33 changes: 20 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
name: tests

on:
push:
branches: [main, develop]
branches: [main]
pull_request:
branches: [main, develop]
branches: [main]
workflow_call:

permissions:
contents: read

jobs:
test:
name: Run specs
test-matrix:
name: Test against Ruby ${{ matrix.ruby }} and Rails ${{ matrix.rails }}

runs-on: ubuntu-latest

strategy:
Expand All @@ -33,11 +36,12 @@ jobs:
- name: Run specs
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: bin/rspec
run: bin/rspec --no-profile

test-current:
name: Run specs against current Ruby and Rails
needs: test-matrix

coverage:
name: Report code coverage
needs: test
runs-on: ubuntu-latest

steps:
Expand All @@ -48,13 +52,16 @@ jobs:
rubygems: latest
bundler-cache: true

- uses: paambaati/codeclimate-action@v6
- run: bin/rspec --format json --out spec/reports/rspec.json

- name: Upload test reports
uses: actions/upload-artifact@v4
with:
coverageCommand: bin/rspec
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
name: test-results
path: spec/reports

- uses: actions/upload-artifact@v4
- name: Upload code coverage
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: coverage

0 comments on commit 7c24afa

Please sign in to comment.