Skip to content

Commit

Permalink
ci: comment coverage on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinKruglov committed Mar 1, 2024
1 parent 47c0af9 commit 1951cb8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 34 additions & 1 deletion .github/workflows/ci-full-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,51 @@ jobs:
docker exec $CONTAINER_ID bash -c "ruby lib/code_coverage_collate.rb"
docker cp $CONTAINER_ID:/srv/app/coverage/index.html coverage
docker cp $CONTAINER_ID:/srv/app/coverage/assets coverage
docker cp $CONTAINER_ID:/srv/app/coverage/.last_run.json coverage
docker stop $CONTAINER_ID
docker rm $CONTAINER_ID
- name: Store collated test coverage
uses: actions/[email protected]
with:
name: full-coverage-report
path: coverage/*
path: |
coverage/*
!coverage/.last_run.json
- name: Store last run
uses: actions/[email protected]
with:
name: last-run
path: coverage/.last_run.json
- name: Delete intermediate artifacts
uses: geekyeggo/[email protected]
with:
name: coverage-report-*

comment_coverage:
name: Comment coverage on PR
needs: collate_test_coverage
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Download coverage from current run
uses: actions/[email protected]
with:
path: coverage/current
pattern: last-run
- run: echo current_coverage=$(cat coverage/current/last-run/.last_run.json) >> $GITHUB_ENV
- name: Store coverage from current run
id: current-run-coverage
run: |
echo branch=${{ fromJson(env.current_coverage).result.branch }} >> $GITHUB_OUTPUT
echo line=${{ fromJson(env.current_coverage).result.line }} >> $GITHUB_OUTPUT
- name: Post comment
uses: thollander/[email protected]
with:
message: |
# Test coverage
**Line:** ${{ steps.current-run-coverage.outputs.line }}%
**Branch:** ${{ steps.current-run-coverage.outputs.branch }}%
release_dev:
name: Deploy release (Dev)
runs-on: ubuntu-20.04
Expand Down
2 changes: 2 additions & 0 deletions lib/code_coverage_collate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
primary_coverage :branch

formatter SimpleCov::Formatter::HTMLFormatter
refuse_coverage_drop :line, :branch
maximum_coverage_drop line: 1, branch: 1
end

0 comments on commit 1951cb8

Please sign in to comment.