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..0257e53c3 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: 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: diff --git a/ci/tasks/code-coverage-diff.sh b/ci/tasks/code-coverage-diff.sh new file mode 100755 index 000000000..dc3580597 --- /dev/null +++ b/ci/tasks/code-coverage-diff.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +source "$(dirname $PWD)/pipeline-tasks/scripts/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% +"