Skip to content

Commit

Permalink
Notify slack with overall result of coverage check. (#327)
Browse files Browse the repository at this point in the history
* Notify slack with overall result of coverage check.

* Use unicode tick and cross for easier comprehension.
  • Loading branch information
cqc-alec committed Aug 1, 2023
1 parent e8718cf commit b5178b1
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
jobs:
check-coverage:
runs-on: ubuntu-latest
outputs:
msg: ${{ steps.make_msg.outputs.msg }}
steps:
- uses: actions/checkout@v3
- name: Install stable toolchain
Expand All @@ -16,15 +18,50 @@ jobs:
uses: KyleMayes/install-llvm-action@v1
with:
version: "16.0" # should match version used by rustc
- name: Generate coverage report
- name: Download previous summary
uses: dawidd6/action-download-artifact@v2
with:
# Downloads the artifact from the most recent successful run
workflow: 'coverage.yml'
name: coverage-summary
- name: Rename file
run: mv coverage-summary.txt coverage-summary-prev.txt
- name: Generate coverage report and summary
env:
RUSTFLAGS: "-C instrument-coverage"
run: |
TGT=`cargo test --tests 2>&1 | grep Running | awk -F'[()]' '{print $2}'`
llvm-profdata merge -sparse default_*.profraw -o hugr.profdata
llvm-cov show --format=html --ignore-filename-regex='/.cargo/registry' --instr-profile=hugr.profdata --output-dir coverage --object ${TGT}
- name: Upload artifact
llvm-cov report --ignore-filename-regex='/.cargo/registry' --instr-profile=hugr.profdata --object ${TGT} | grep TOTAL | awk '{print $10}' | tr -dc '[:digit:].' > coverage-summary.txt
- name: Upload full report
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage/
- name: Upload summary
uses: actions/upload-artifact@v3
with:
name: coverage-summary
path: coverage-summary.txt
- name: Compare with previous summary and make message
id: make_msg
run: |
if (( $(echo "`cat coverage-summary-prev.txt` < `cat coverage-summary.txt` + 0.03" | bc -l) ))
then
echo "msg=Coverage check for hugr shows no regression. ✅ ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_OUTPUT"
else
echo "msg=Coverage check for hugr shows regression. ❌ ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_OUTPUT"
fi
notify-slack:
needs: check-coverage
runs-on: ubuntu-latest
steps:
- name: Send notification
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: 'C04SHCL4FKP'
slack-message: ${{ needs.check-coverage.outputs.msg }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

0 comments on commit b5178b1

Please sign in to comment.