Skip to content

Commit 462ab7b

Browse files
committed
chore: add pr code coverage to ci (#4643)
1 parent 92aeba1 commit 462ab7b

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

ci/partials/code-coverage-diff.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
platform: linux
2+
inputs:
3+
- name: src
4+
- name: pages-pipeline-tasks
5+
outputs: [name: src]
6+
run:
7+
dir: src
8+
path: ci/tasks/code-coverage-diff.sh

ci/pipeline.yml

+11
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ jobs:
7575
instance_vars:
7676
deploy-env: ((deploy-env))
7777

78+
#@ if/end env == 'dev':
79+
- name: code-coverage-diff
80+
plan:
81+
- get: src
82+
trigger: true
83+
- get: general-task
84+
- get: pipeline-tasks
85+
- task: code-coverage-diff
86+
image: general-task
87+
file: src/ci/partials/code-coverage-diff.yml
88+
7889
#@ if/end env == 'staging':
7990
- name: update-release-branch
8091
plan:

ci/tasks/code-coverage-diff.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source "${BASH_SOURCE%/*/*}/pages-pipeline-tasks/github-setup.sh"
6+
7+
# note our branch
8+
branch=$(git rev-parse --abbrev-ref HEAD)
9+
10+
# generate test coverage
11+
cov_cmd="yarn test:rtl --coverageReporters json-summary --coverageDirectory tmp"
12+
tot_cmd="jq '.["total"]["lines"]["pct"]' tmp/coverage-summary.json"
13+
bash -c $cov_cmd
14+
newcc=$(bash -c $tot_cmd)
15+
git checkout main
16+
bash -c $cov_cmd
17+
oldcc=$(bash -c $tot_cmd)
18+
19+
difcc=$(($newcc-$oldcc))
20+
21+
gh pr comment $branch -b " \
22+
## :robot: This is an automated code coverage report
23+
Total coverage (lines): $newcc%
24+
Coverage diff: $diffcc%
25+
"

0 commit comments

Comments
 (0)