Skip to content

Commit

Permalink
debug: add comment_coverage
Browse files Browse the repository at this point in the history
Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
  • Loading branch information
gouravkrosx committed May 1, 2024
1 parent 1903b9a commit e953ab4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 23 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/comment_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Comment Coverage on PR

on:
workflow_call:
inputs:
issue-number:
required: true
type: number


jobs:
comment-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Download the coverage report
id: coverage-artifact
uses: actions/download-artifact@v4
with:
name: coverage-report-html
path: /tmp

- name: Comment HTML report on PR
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ inputs.issue-number }}
body: |
Coverage report is available [here](${{ steps.upload-artifacts.outputs.artifact-url }}). Navigate to 'Artifacts' to download the HTML report.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 15 additions & 23 deletions .github/workflows/coverage_stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,20 @@ jobs:
- name: Display the coverage data
run: |
go tool cover -func total-coverage.txt
tail -n 1 total-coverage.txt > coverage-comment.txt
- name: Comment on the PR with the coverage data
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const coverageComment = fs.readFileSync('coverage-comment.txt', 'utf8');
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Total coverage: " + coverageComment,
});
# - name: Generate the HTML coverage report
# run: |
# go tool cover -html=total-coverage.txt -o=coverage.html
- name: Generate the HTML coverage report
run: |
go tool cover -html=total-coverage.txt -o=coverage.html
# - name: Upload the HTML coverage report
# id: artifact-upload-step
# uses: actions/upload-artifact@v4
# with:
# name: coverage-report-html
# path: coverage.html
- name: Upload the HTML coverage report
id: artifact-upload-step
uses: actions/upload-artifact@v4
with:
name: coverage-report-html
path: coverage.html

comment-coverage:
needs: coverage
uses: ./.github/workflows/comment_coverage.yml
with:
issue-number: ${{ github.event.pull_request.number }}

0 comments on commit e953ab4

Please sign in to comment.