Skip to content

Commit

Permalink
chore: add pr code coverage to ci (#4643)
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbo committed Nov 8, 2024
1 parent 92aeba1 commit 462ab7b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ci/partials/code-coverage-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
platform: linux
inputs:
- name: src
- name: pages-pipeline-tasks
outputs: [name: src]
run:
dir: src
path: ci/tasks/code-coverage-diff.sh
11 changes: 11 additions & 0 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ jobs:
instance_vars:
deploy-env: ((deploy-env))

#@ if/end env == 'dev':
- name: code-coverage-diff
plan:
- get: src
trigger: true
- get: general-task
- get: pipeline-tasks
- task: code-coverage-diff
image: general-task
file: src/ci/partials/code-coverage-diff.yml

#@ if/end env == 'staging':
- name: update-release-branch
plan:
Expand Down
25 changes: 25 additions & 0 deletions ci/tasks/code-coverage-diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e

source "${BASH_SOURCE%/*/*}/pages-pipeline-tasks/github-setup.sh"

# note our branch
branch=$(git rev-parse --abbrev-ref HEAD)

# generate test coverage
cov_cmd="yarn test:rtl --coverageReporters json-summary --coverageDirectory tmp"
tot_cmd="jq '.["total"]["lines"]["pct"]' tmp/coverage-summary.json"
bash -c $cov_cmd
newcc=$(bash -c $tot_cmd)
git checkout main
bash -c $cov_cmd
oldcc=$(bash -c $tot_cmd)

difcc=$(($newcc-$oldcc))

gh pr comment $branch -b " \
## :robot: This is an automated code coverage report
Total coverage (lines): $newcc%
Coverage diff: $diffcc%
"

0 comments on commit 462ab7b

Please sign in to comment.