Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ jobs:
path: main.breakdown
if-no-files-found: error

# Post coverage report as comment
- name: find pull request ID
run: |
PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
Expand All @@ -92,25 +91,16 @@ jobs:
else
echo "No open pull request found for this branch."
fi
- name: find if coverage report is already present
if: env.pull_request_id
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ env.pull_request_id }}
comment-author: 'github-actions[bot]'
body-includes: 'go-test-coverage report:'
- name: post coverage report
if: env.pull_request_id
uses: peter-evans/create-or-update-comment@v4
uses: thollander/actions-comment-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ env.pull_request_id }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-tag: coverage-report
pr-number: ${{ env.pull_request_id }}
message: |
go-test-coverage report:
```
```
${{ fromJSON(steps.coverage.outputs.report) }}```

- name: "finally check coverage"
Expand Down
31 changes: 11 additions & 20 deletions docs/github_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,39 +108,30 @@ Example of report is in [this PR](https://github.com/vladopajic/go-test-coverage
continue-on-error: true # Should fail after coverage comment is posted
with:
config: ./.github/.testcoverage.yml
# Post coverage report as comment (in 3 steps)

# Post coverage report as comment (in 2 steps)
- name: find pull request ID
run: |
PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref_name }}&state=open")
"https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref_name }}&state=open")
PR_ID=$(echo "$PR_DATA" | jq -r '.[0].number')

if [ "$PR_ID" != "null" ]; then
echo "pull_request_id=$PR_ID" >> $GITHUB_ENV
echo "pull_request_id=$PR_ID" >> $GITHUB_ENV
else
echo "No open pull request found for this branch."
echo "No open pull request found for this branch."
fi
- name: find if coverage report is already present
if: env.pull_request_id
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ env.pull_request_id }}
comment-author: 'github-actions[bot]'
body-includes: 'go-test-coverage report:'
- name: post coverage report
if: env.pull_request_id
uses: peter-evans/create-or-update-comment@v4
uses: thollander/actions-comment-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ env.pull_request_id }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-tag: coverage-report
pr-number: ${{ env.pull_request_id }}
message: |
go-test-coverage report:
```
${{ fromJSON(steps.coverage.outputs.report) }} ```
${{ fromJSON(steps.coverage.outputs.report) }}```

- name: "finally check coverage"
if: steps.coverage.outcome == 'failure'
Expand Down
Loading