Coverage #210
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Coverage | |
on: | |
schedule: | |
# 04:00 daily | |
- cron: '0 4 * * *' | |
jobs: | |
check-coverage: | |
runs-on: ubuntu-latest | |
outputs: | |
msg: ${{ steps.make_msg.outputs.msg }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install llvm | |
uses: KyleMayes/install-llvm-action@v1 | |
with: | |
version: "16.0" # should match version used by rustc | |
- 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} | |
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: | | |
change="`cat coverage-summary-prev.txt`% --> `cat coverage-summary.txt`%" | |
if (( $(echo "`cat coverage-summary-prev.txt` < `cat coverage-summary.txt` + 0.04" | bc -l) )) | |
then | |
echo "msg=Coverage check for hugr shows no regression (${change}). ✅ ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_OUTPUT" | |
else | |
echo "msg=Coverage check for hugr shows regression (${change}). ❌ ${{ 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/[email protected] | |
with: | |
channel-id: 'C04SHCL4FKP' | |
slack-message: ${{ needs.check-coverage.outputs.msg }} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |