Skip to content

Commit

Permalink
[Workflow] Unify Code Coverage Workflow (open-algebra#75)
Browse files Browse the repository at this point in the history
* Simplified code coverage commenting

* Moved commenting to single file

* Removed unused variable and use correct llvm-cov tool

* Remove save PR number step
  • Loading branch information
matthew-mccall authored Mar 23, 2024
1 parent 7928337 commit 834ea90
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 102 deletions.
81 changes: 0 additions & 81 deletions .github/workflows/code-coverage-comment.yml

This file was deleted.

37 changes: 16 additions & 21 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
pull_request:
branches: [ "master" ]

permissions:
pull-requests: write

jobs:
collect-coverage:
runs-on: ubuntu-latest
Expand All @@ -26,13 +29,6 @@ jobs:
run: |
echo "build-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
echo "coverage-dir=${{ github.workspace }}/coverage" >> "$GITHUB_OUTPUT"
echo "pr-dir=${{ github.workspace }}/pr" >> "$GITHUB_OUTPUT"
# Saves the PR number to use in writing a comment on the PR.
- name: Save PR number
run: |
mkdir -p ${{ steps.strings.outputs.pr-dir }}
echo "${{ github.event.number }}" > ${{ steps.strings.outputs.pr-dir }}/issue_number
# Installs LLVM 17 on the runner.
- name: Install LLVM 17
Expand Down Expand Up @@ -81,20 +77,19 @@ jobs:
shell: bash
run: |
llvm-profdata-17 merge -sparse oasis.profraw -o oasis.profdata
llvm-cov-17 show -output-dir reports -instr-profile oasis.profdata ${{ steps.strings.outputs.build-dir }}/tests/OasisTests -sources ${{ github.workspace }}/src ${{ github.workspace }}/include
llvm-cov-17 report -instr-profile oasis.profdata ${{ steps.strings.outputs.build-dir }}/tests/OasisTests -sources ${{ github.workspace }}/src ${{ github.workspace }}/include > coverage.txt
# Uploads the build, test, and code coverage artifacts.
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: build-test-cover
path: |
${{ steps.strings.outputs.build-dir }}
!${{ steps.strings.outputs.build-dir }}/_deps
${{ steps.strings.outputs.coverage-dir }}
- name: Upload PR number
uses: actions/upload-artifact@v3
- name: Comment on PR
uses: actions/github-script@v6
with:
name: pr-number
path: ${{ steps.strings.outputs.pr-dir }}
script: |
const fs = require('fs');
const coverage_file = fs.readFileSync('${{ steps.strings.outputs.coverage-dir }}/coverage.txt');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: '```\n' + coverage_file + '\n```'
});

0 comments on commit 834ea90

Please sign in to comment.