-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate coverage reports using only GitHub Actions, without codecov.io #447
Merged
Merged
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0de9b20
Initial coverage report.
adiroiban 4dd1373
Enable for windows.
adiroiban cf12435
Try to support windows paths for coverage.
adiroiban 10d8225
Try the branch.
adiroiban 2a1ffaf
Update all-success to newer version that as no set-output warnings.
adiroiban d787a30
Add a comment.
adiroiban 04d8448
Pass comment via a file to handle newlines.
adiroiban a86b23b
Use nodejs like a pro.
adiroiban e4d2e1a
Apply suggestions from code review
adiroiban 8208990
Include diff. Wrap in markdown.
adiroiban dac2d58
Enable test report.
adiroiban 12f3c81
Fix after re-review.
adiroiban 77f12dc
Remove run_id from coverage artifact.
adiroiban 743613e
Add a name for the comment script.
adiroiban e0ca810
Remove comment about single artifact as this is what we have by defau…
adiroiban 322ce25
Add restricted permissions for token.
adiroiban 04a1c1b
Use markdown report for diff-cover.
adiroiban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
Have a single comment on a PR, identified by a comment marker. | ||
|
||
Create a new comment if no comment already exists. | ||
Update the content of the existing comment. | ||
|
||
|
||
https://octokit.github.io/rest.js/v19 | ||
*/ | ||
module.exports = async ({github, context, process}) => { | ||
var octokit_rest = github | ||
if (context.eventName != "pull_request") { | ||
// Only PR are supported. | ||
return | ||
} | ||
|
||
var sleep = function(second) { | ||
return new Promise(resolve => setTimeout(resolve, second * 1000)) | ||
} | ||
|
||
/* | ||
Perform the actual logic. | ||
|
||
This is wrapped so that we can retry on errors. | ||
*/ | ||
var doAction = async function() { | ||
|
||
console.log(context) | ||
|
||
fs = require('fs'); | ||
|
||
const body = fs.readFileSync( | ||
process.env.GITHUB_WORKSPACE + "/" + process.env.COMMENT_BODY, 'utf8'); | ||
var comment_id = null | ||
var comment_marker = '\n' + process.env.COMMENT_MARKER | ||
var comment_body = body + comment_marker | ||
|
||
var comments = await octokit_rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.number, | ||
}) | ||
|
||
console.log(comments) | ||
|
||
comments.data.forEach(comment => { | ||
if (comment.body.endsWith(comment_marker)) { | ||
comment_id = comment.id | ||
} | ||
}) | ||
|
||
if (comment_id) { | ||
// We have an existing comment. | ||
// update the content. | ||
await octokit_rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: comment_id, | ||
body: comment_body, | ||
}) | ||
return | ||
} | ||
|
||
// Create a new comment. | ||
await octokit_rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.number, | ||
body: comment_body, | ||
}) | ||
|
||
} | ||
|
||
try { | ||
await doAction() | ||
} catch (e) { | ||
await sleep(5) | ||
await doAction() | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ dist/ | |
venv/ | ||
htmlcov/ | ||
.coverage | ||
coverage.xml | ||
*~ | ||
*.lock | ||
apidocs/ | ||
|
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
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
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments in duplicated section below.
Side note... I really like cross-platform matrices to avoid this.
:]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am missing the comment.
I am happy to see less duplication, but I think is best to have it in separate PR.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copy pasted from the other similar section and contains the same typos that were present there and have been fixed. They should be fixed here as well.
But, I'm going to go ahead and trigger a run here, cancel it partially completed, rerun the cancelled jobs and see if my concern about using the
github.run_id
seems accurate.