romeovs / lcov-reporter-action

Comments a pull request with the code coverage generated by your tests.
MIT License
161 stars 99 forks source link

Allow post the report to job summary #68

Open 06393993 opened 1 year ago

06393993 commented 1 year ago

For PR from a foreign repo, the action won't have enough permission to comment on a PR, and for security reason the action shouldn't have the permission. See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/, https://github.com/orgs/community/discussions/26644.

This PR implements the feature requested in https://github.com/romeovs/lcov-reporter-action/issues/65.

~I haven't tested this PR yet. I may need to upgrade the version of @actions/core to call the new summary API.~

EDIT: I have tested this PR, and people can check the output here. The job summary also won't generate new email, so may also solve #57.

06393993 commented 4 months ago

Hi @romeovs , can you please take a look at this PR? Thanks a lot!

daxpedda commented 2 months ago

I've tried using the latest commit from your fork but it errors out with:

file:///home/runner/work/_actions/06393993/lcov-reporter-action/c2dc6744871841e7cc2fa528f983253ecee694ab/dist/main.js:3
var require$$0$1 = require('node:fs');
                   ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/runner/work/_actions/06393993/lcov-reporter-action/c2dc6744871841e7cc2fa528f983253ecee694ab/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///home/runner/work/_actions/06393993/lcov-reporter-action/c2dc6744871841e7cc2fa528f983253ecee694ab/dist/main.js:3:20
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Node.js v20.13.1

Using an older commit I took from vk-layer-for-rust works.

06393993 commented 2 months ago

Re https://github.com/romeovs/lcov-reporter-action/pull/68#issuecomment-2284453232, I had a simple fix to change dist/main.js to dist/main.cjs. But it seems that https://github.com/romeovs/lcov-reporter-action/commit/423a24f58067e0c0500f35c7eba92d8f38a1630a breaks the script completely, so I need to adjust more code to fix that issue.

06393993 commented 2 months ago

I've tried using the latest commit from your fork but it errors out with:

file:///home/runner/work/_actions/06393993/lcov-reporter-action/c2dc6744871841e7cc2fa528f983253ecee694ab/dist/main.js:3
var require$$0$1 = require('node:fs');
                   ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/runner/work/_actions/06393993/lcov-reporter-action/c2dc6744871841e7cc2fa528f983253ecee694ab/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///home/runner/work/_actions/06393993/lcov-reporter-action/c2dc6744871841e7cc2fa528f983253ecee694ab/dist/main.js:3:20
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Node.js v20.13.1

Using an older commit I took from vk-layer-for-rust works.

I have updated this PR and verified that it works.