Skip to content

Commit b6d460d

Browse files
committed
🔧 カバレッジレポートの結果をCI結果に表示させる
1 parent 136476a commit b6d460d

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Upload test coverage file"
2+
description: "Upload test coverage file to the desired location"
3+
outputs:
4+
coverage-value:
5+
description: "coverage value"
6+
value: ${{ steps.coverage-value-getter.outputs.coverage-value }}
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: "Archive code coverage results"
11+
uses: actions/upload-artifact@v3
12+
with:
13+
name: code-coverage-report
14+
path: coverage
15+
16+
- name: "Get coverage value"
17+
id: coverage-value-getter
18+
run: |
19+
coverage_value=`cat ./coverage/.last_run.json | jq -r .result.line`
20+
echo "coverage-value=$coverage_value" >> "$GITHUB_OUTPUT"
21+
shell: bash

.github/workflows/ci.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ jobs:
3030
run: bundle exec rubocop
3131
- name: Run RSpec
3232
run: bundle exec rspec
33-
# https://docs.github.com/ja/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts
34-
- name: Archive code coverage results
35-
uses: actions/upload-artifact@v2
36-
with:
37-
name: code-coverage-report
38-
path: coverage
33+
- name: Upload test coverage
34+
id: upload-test-coverage
35+
uses: ./.github/actions/upload-test-coverage
36+
- name: Display test coverage in summary
37+
run: |
38+
coverage_value=${{ steps.upload-test-coverage.outputs.coverage-value }}
39+
echo "# Coverage report: $coverage_value%" >> $GITHUB_STEP_SUMMARY
3940
# https://github.com/marketplace/actions/action-slack
4041
- name: Github Actions notify to Slack
4142
uses: 8398a7/action-slack@v3

0 commit comments

Comments
 (0)