From 09b709cf6a16e30b0808ba050c7a6e8a5ef13f8d Mon Sep 17 00:00:00 2001 From: Valentin Kiselev Date: Mon, 24 Apr 2023 11:44:39 +0300 Subject: [PATCH] feat: add debug option (#168) --- README.md | 1 + action.yml | 4 ++++ dist/index.js | 5 ++++- src/run.ts | 8 +++++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 81e57f26..985f4738 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ The action's step needs to run after your test suite has outputted an LCOV file. | `base-path` | _optional_ | Path to the root folder of the project the coverage was collected in. Should be used in monorepos so that coveralls can process the LCOV correctly (e.g. packages/my-project) | | `git-branch` | _optional_ | Default: GITHUB_REF environment variable. Override the branch name. | | `git-commit` | _optional_ | Default: GITHUB_SHA environment variable. Override the commit SHA. | +| `debug` | _optional_ | Default: `false`. Set to `true` to enable debug logging. | ### Outputs: diff --git a/action.yml b/action.yml index b29befd2..9b0eeca6 100644 --- a/action.yml +++ b/action.yml @@ -36,6 +36,10 @@ inputs: git-commit: description: 'Override the commit sha' required: false + debug: + description: 'Enable debug logging' + required: false + default: false outputs: coveralls-api-result: description: 'Result status of Coveralls API post.' diff --git a/dist/index.js b/dist/index.js index 3f651098..0ae08193 100644 --- a/dist/index.js +++ b/dist/index.js @@ -40761,6 +40761,9 @@ const core = __importStar(__nccwpck_require__(6024)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const request_1 = __importDefault(__nccwpck_require__(2956)); const lcov_processor_1 = __nccwpck_require__(6334); +process.env.NODE_COVERALLS_DEBUG = (process.env.COVERALLS_DEBUG == 'true' || + process.env.COVERALLS_DEBUG == '1' || + core.getInput('debug') == 'true') ? '1' : ''; const coveralls = __nccwpck_require__(7532); function run() { return __awaiter(this, void 0, void 0, function* () { @@ -40775,7 +40778,7 @@ function run() { process.env.COVERALLS_GIT_BRANCH = process.env.GITHUB_REF.toString(); process.env.COVERALLS_FLAG_NAME = process.env.COVERALLS_FLAG_NAME || core.getInput('flag-name'); const event = fs_1.default.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'); - if (process.env.COVERALLS_DEBUG) { + if (process.env.NODE_COVERALLS_DEBUG) { console.log("Event Name: " + process.env.GITHUB_EVENT_NAME); console.log(event); } diff --git a/src/run.ts b/src/run.ts index 6bb03f8d..7585f1ab 100644 --- a/src/run.ts +++ b/src/run.ts @@ -5,6 +5,12 @@ import path from 'path'; import request, { Response } from 'request'; import { adjustLcovBasePath } from './lcov-processor'; +process.env.NODE_COVERALLS_DEBUG = ( + process.env.COVERALLS_DEBUG == 'true' || + process.env.COVERALLS_DEBUG == '1' || + core.getInput('debug') == 'true' +) ? '1' : ''; + const coveralls = require('coveralls'); interface WebhookResult { @@ -30,7 +36,7 @@ export async function run() { const event = fs.readFileSync(process.env.GITHUB_EVENT_PATH!, 'utf8'); - if (process.env.COVERALLS_DEBUG) { + if (process.env.NODE_COVERALLS_DEBUG) { console.log("Event Name: " + process.env.GITHUB_EVENT_NAME); console.log(event); }