sidx1024 / report-nyc-coverage-github-action

GitHub Action that posts the report in a comment on a GitHub Pull Request from coverage data generated by nyc (istanbul)
MIT License
21 stars 10 forks source link

Unable to find default comment_template.md #28

Closed TaighHawkins closed 1 year ago

TaighHawkins commented 2 years ago

The comment file isn't being found - this is because the source path for the search defaults to the application directory you're building, not the action runner directory:
Error: Error: ENOENT: no such file or directory, open '/home/runner/work/JsFunctionAppTest/JsFunctionAppTest/comment-template.md'
Providing the full comment template path to the action results in it working:

    - name: Report NYC coverage
      uses: sidx1024/report-nyc-coverage-github-action@v1.2.6
      with:
        coverage_file: "coverage/coverage-summary.json"
        comment_template_file: "/home/runner/work/_actions/sidx1024/report-nyc-coverage-github-action/v1.2.6/comment-template.md"

The rest of the error:

Run sidx10[2](https://github.com/####/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:2)4/report-nyc-coverage-github-action@v1.2.6
  with:
    coverage_file: coverage/coverage-summary.json
    comment_mode: new
    base_coverage_file: .base_nyc_output/coverage-summary.json
    comment_template_file: comment-template.md
    github_token: ***
    sources_base_path: /home/runner/work/JsFunctionAppTest/JsFunctionAppTest/
    files_coverage_table_output_type_order: SBFL
Base coverage json was not readable.
/usr/bin/git diff --name-only --diff-filter=ACMRT origin/master...4758df2bbd[3](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:3)0bc16c5a67a298d6caed260af9725
fatal: ambiguous argument 'origin/master...[4](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:4)7[5](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:5)8df2bbd30bc1[6](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:6)c5a6[7](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:7)a29[8](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:8)d6caed260af[9](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:9)725': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
A non-fatal error occurred while performing git diff:  {
  exitCode: 128,
  stdout: '',
  stderr: "fatal: ambiguous argument 'origin/master...4758df2bbd30bc16c5a67a298d6caed260af9725': unknown revision or path not in the working tree.\n" +
    "Use '--' to separate paths from revisions, like this:\n" +
    "'git <command> [<revision>...] -- [<file>...]'\n"
}
Error: Error: ENOENT: no such file or directory, open '/home/runner/work/JsFunctionAppTest/JsFunctionAppTest/comment-template.md'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at run (/home/runner/work/_actions/sidx[10](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:10)24/report-nyc-coverage-github-action/v1.2.6/dist/index.js:10[23](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:23)1:32)
domnantas commented 2 years ago

Getting the same error

yassinebebba commented 2 years ago

this is the template https://github.com/sidx1024/report-nyc-coverage-github-action/blob/main/comment-template.md

domnantas commented 2 years ago

Figured that out a bit later 😅 There are no instructions on README to copy the issue template to your project. Ideally, it would automatically default to https://github.com/sidx1024/report-nyc-coverage-github-action/blob/main/comment-template.md (or the .svelte one) if template does not exist in your project

TaighHawkins commented 2 years ago

Yeah, while I can understand that providing your own template is useful, there's no need to provide a template if you just want the default template (given that it exists within the action at hand). I'm happy to have this issue closed if either:

But as it stands, there's no indication that you should use your own template, and it is entirely possible to use the one in the action.

yassinebebba commented 2 years ago

if you don't use your own template the action will fail, and even if you provide one you endup with an error that says missing fields

Error: Error: Invalid or missing tokens: base_ref,base_short_commit_sha,base_commit_link,base_total_statements_coverage_percent,total_statements_coverage_percent_diff,base_total_branches_coverage_percent,total_branches_coverage_percent_diff,base_total_functions_coverage_percent,total_functions_coverage_percent_diff,base_total_lines_coverage_percent,total_lines_coverage_percent_diff
sidx1024 commented 1 year ago

It was a bug. Please use one of the newer releases which has this issue fixed.