diff --git a/ci/partials/code-coverage-diff.yml b/ci/partials/code-coverage-diff.yml new file mode 100644 index 000000000..92834e345 --- /dev/null +++ b/ci/partials/code-coverage-diff.yml @@ -0,0 +1,15 @@ +platform: linux +inputs: + - name: src + - name: pipeline-tasks +outputs: [name: src] +params: + GH_EMAIL: ((pages-operations-github-user-info.email)) + GH_USERNAME: ((pages-operations-github-user-info.username)) + GH_BOT_GPG_KEY: ((pages-operations-github-user-gpg.private_key)) + GH_BOT_SSH_KEY: ((pages-gpg-operations-github-sshkey.private_key)) + GH_BOT_GPG_TRUST: ((pages-operations-github-user-gpg-trust)) + GH_TOKEN: ((pages-operations-ci-github-token)) +run: + dir: src + path: ci/tasks/code-coverage-diff.sh diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 92b86ac01..ddb6238c7 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -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: node + - get: pipeline-tasks + - task: code-coverage-diff + image: node + file: src/ci/partials/code-coverage-diff.yml + #@ if/end env == 'staging': - name: update-release-branch plan: diff --git a/ci/tasks/code-coverage-diff.sh b/ci/tasks/code-coverage-diff.sh new file mode 100755 index 000000000..7fd4fb5f2 --- /dev/null +++ b/ci/tasks/code-coverage-diff.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e + +source "$(dirname $PWD)/pipeline-tasks/scripts/github-setup.sh" + +apt-get install jq -y + +# note our branch +branch=$(git rev-parse --abbrev-ref HEAD) + +# generate test coverage +yarn install +cov_cmd() { yarn test:rtl --coverageReporters json-summary --coverageDirectory tmp; } +tot_cmd() { jq '.["total"]["lines"]["pct"]' tmp/coverage-summary.json; } +cov_cmd +newcc=$(tot_cmd) +git checkout main +cov_cmd +oldcc=$(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% +"