diff --git a/CHANGELOG.md b/CHANGELOG.md index db60f772..3a9f1b9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [2.5.4] - 2020-03-04 +### Fixed +- Fixes [#119](https://github.com/paambaati/codeclimate-action/issues/119) - via [`#127`](https://github.com/paambaati/codeclimate-action/pull/127). + # [2.5.3] - 2020-02-26 ### Fixed - Fixes [#109](https://github.com/paambaati/codeclimate-action/issues/109) and #117(https://github.com/paambaati/codeclimate-action/issues/117) - via [`#118`](https://github.com/paambaati/codeclimate-action/pull/118). diff --git a/lib/main.js b/lib/main.js index 9bfc3008..9f68b814 100644 --- a/lib/main.js +++ b/lib/main.js @@ -86,7 +86,7 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman core_1.debug('โœ… Coverage run completed...'); } catch (err) { - core_1.error(err); + core_1.error(err.message); core_1.setFailed('๐Ÿšจ Coverage run failed!'); return reject(err); } diff --git a/node_modules/@actions/core/README.md b/node_modules/@actions/core/README.md index 457f73cc..5ad27eed 100644 --- a/node_modules/@actions/core/README.md +++ b/node_modules/@actions/core/README.md @@ -82,6 +82,12 @@ try { core.warning('myInput was not set'); } + if (core.isDebug()) { + // curl -v https://github.com + } else { + // curl https://github.com + } + // Do stuff } catch (err) { diff --git a/node_modules/@actions/core/lib/core.d.ts b/node_modules/@actions/core/lib/core.d.ts index 6483c3ca..8fcc31ba 100644 --- a/node_modules/@actions/core/lib/core.d.ts +++ b/node_modules/@actions/core/lib/core.d.ts @@ -55,6 +55,10 @@ export declare function setOutput(name: string, value: string): void; * @param message add error issue message */ export declare function setFailed(message: string): void; +/** + * Gets whether Actions Step Debug is on or not + */ +export declare function isDebug(): boolean; /** * Writes debug message to user log * @param message debug message diff --git a/node_modules/@actions/core/lib/core.js b/node_modules/@actions/core/lib/core.js index b99e1dee..b7ec8ab4 100644 --- a/node_modules/@actions/core/lib/core.js +++ b/node_modules/@actions/core/lib/core.js @@ -104,6 +104,13 @@ exports.setFailed = setFailed; //----------------------------------------------------------------------- // Logging Commands //----------------------------------------------------------------------- +/** + * Gets whether Actions Step Debug is on or not + */ +function isDebug() { + return process.env['RUNNER_DEBUG'] === '1'; +} +exports.isDebug = isDebug; /** * Writes debug message to user log * @param message debug message diff --git a/node_modules/@actions/core/lib/core.js.map b/node_modules/@actions/core/lib/core.js.map index 33c62688..fb93bd38 100644 --- a/node_modules/@actions/core/lib/core.js.map +++ b/node_modules/@actions/core/lib/core.js.map @@ -1 +1 @@ -{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAA6C;AAE7C,uCAAwB;AACxB,2CAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,MAAc;IACtC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;AACtC,CAAC;AAFD,8BAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG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AA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC;AAED,yEAAyE;AACzE,uBAAuB;AACvB,yEAAyE;AAEzE;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,IAAI,EAAE,CAAA;AAC3C,CAAC;AAFD,4BAEC"} \ No newline at end of file diff --git a/node_modules/@actions/core/package.json b/node_modules/@actions/core/package.json index e521ba80..6aa90bd8 100644 --- a/node_modules/@actions/core/package.json +++ b/node_modules/@actions/core/package.json @@ -1,32 +1,32 @@ { "_args": [ [ - "@actions/core@1.2.2", + "@actions/core@1.2.3", "/home/runner/work/codeclimate-action/codeclimate-action/.work/build" ] ], - "_from": "@actions/core@1.2.2", - "_id": "@actions/core@1.2.2", + "_from": "@actions/core@1.2.3", + "_id": "@actions/core@1.2.3", "_inBundle": false, - "_integrity": "sha512-IbCx7oefq+Gi6FWbSs2Fnw8VkEI6Y4gvjrYprY3RV//ksq/KPMlClOerJ4jRosyal6zkUIc8R9fS/cpRMlGClg==", + "_integrity": "sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w==", "_location": "/@actions/core", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "@actions/core@1.2.2", + "raw": "@actions/core@1.2.3", "name": "@actions/core", "escapedName": "@actions%2fcore", "scope": "@actions", - "rawSpec": "1.2.2", + "rawSpec": "1.2.3", "saveSpec": null, - "fetchSpec": "1.2.2" + "fetchSpec": "1.2.3" }, "_requiredBy": [ "/" ], - "_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.2.tgz", - "_spec": "1.2.2", + "_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.3.tgz", + "_spec": "1.2.3", "_where": "/home/runner/work/codeclimate-action/codeclimate-action/.work/build", "bugs": { "url": "https://github.com/actions/toolkit/issues" @@ -65,5 +65,5 @@ "tsc": "tsc" }, "types": "lib/core.d.ts", - "version": "1.2.2" + "version": "1.2.3" } diff --git a/test/main.test.ts b/test/main.test.ts index 07fa1b1c..975ecac6 100644 --- a/test/main.test.ts +++ b/test/main.test.ts @@ -24,8 +24,8 @@ test('๐Ÿงช downloadToFile() should download the give URL and write to given file .get('/dummy-cc-reporter') .reply(200, () => { return toReadableStream(`#!/bin/bash - echo "hello" - `); +echo "hello" +`); }); await downloadToFile( 'http://localhost.test/dummy-cc-reporter', @@ -52,8 +52,8 @@ test('๐Ÿงช run() should run the CC reporter (happy path).', async t => { .get('/dummy-cc-reporter') .reply(200, () => { return toReadableStream(`#!/bin/bash - echo "$*" - `); // Dummy shell script that just echoes back all arguments. +echo "$*" +`); // Dummy shell script that just echoes back all arguments. }); let capturedOutput = ''; @@ -70,8 +70,9 @@ test('๐Ÿงช run() should run the CC reporter (happy path).', async t => { unhookIntercept(); } catch (err) { unhookIntercept(); - nock.cleanAll(); t.fail(err); + } finally { + nock.cleanAll(); } t.equal( @@ -94,6 +95,53 @@ after-build --exit-code 0 t.end(); }); +// TODO: @paambaati โ€” Figure out why this test itself passes but why tape fails with exit code 1. +test.skip('๐Ÿงช run() should exit cleanly when the coverage command fails.', async t => { + t.plan(1); + const COVERAGE_COMMAND = 'wololololo'; // Random command that doesn't exist (and so should fail). + const filePath = './test.sh'; + const mock = await nock('http://localhost.test') + .get('/dummy-cc-reporter') + .reply(200, () => { + return toReadableStream(`#!/bin/bash +echo "$*" +`); // Dummy shell script that just echoes back all arguments. + }); + + let capturedOutput = ''; + const unhookIntercept = intercept.default((text: string) => { + capturedOutput += text; + }); + + try { + await run( + 'http://localhost.test/dummy-cc-reporter', + filePath, + COVERAGE_COMMAND + ); + unhookIntercept(); + t.fail('Should throw an error.'); + } catch (err) { + unhookIntercept(); + t.equal( + capturedOutput, + `::debug::โ„น๏ธ Downloading CC Reporter from http://localhost.test/dummy-cc-reporter ... +::debug::โœ… CC Reporter downloaded... +[command]${DEFAULT_WORKDIR}/test.sh before-build +before-build +::debug::โœ… CC Reporter before-build checkin completed... +::error::Unable to locate executable file: ${COVERAGE_COMMAND}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable. +::error::๐Ÿšจ Coverage run failed! +`, + 'should fail correctly on wrong/invalid coverage command.' + ); + } finally { + unlinkSync(filePath); + nock.cleanAll(); + t.end(); + } +}); + test('๐Ÿ’ฃ teardown', t => { nock.restore(); nock.cleanAll();