From baef3850ca1973cd488c8c1ef005b40eb20d8f21 Mon Sep 17 00:00:00 2001 From: GP Date: Wed, 29 Sep 2021 14:48:20 +0000 Subject: [PATCH] feat: build for release --- CHANGELOG.md | 125 --- ...D9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc | 54 -- .../dummy-cc-reporter-after-build-error.sh | 7 - ...dummy-cc-reporter-after-build-error.sha256 | 1 - .../dummy-cc-reporter-before-build-error.sh | 3 - ...ummy-cc-reporter-before-build-error.sha256 | 1 - test/fixtures/dummy-cc-reporter.sh | 3 - test/fixtures/dummy-cc-reporter.sha256 | 1 - test/fixtures/dummy-cc-reporter.sha256.sig | Bin 566 -> 0 bytes test/main.test.ts | 903 ------------------ test/utils.test.ts | 63 -- 11 files changed, 1161 deletions(-) delete mode 100644 CHANGELOG.md delete mode 100644 test/fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc delete mode 100644 test/fixtures/dummy-cc-reporter-after-build-error.sh delete mode 100644 test/fixtures/dummy-cc-reporter-after-build-error.sha256 delete mode 100644 test/fixtures/dummy-cc-reporter-before-build-error.sh delete mode 100644 test/fixtures/dummy-cc-reporter-before-build-error.sha256 delete mode 100755 test/fixtures/dummy-cc-reporter.sh delete mode 100644 test/fixtures/dummy-cc-reporter.sha256 delete mode 100644 test/fixtures/dummy-cc-reporter.sha256.sig delete mode 100644 test/main.test.ts delete mode 100644 test/utils.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 994882ac..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,125 +0,0 @@ -# Changelog -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.7.5] - 2020-12-10 -### Added -- ✨ Coverage prefix will now work for `after-build` commands as well - via [`#266`](https://github.com/paambaati/codeclimate-action/pull/266). This closes [`#265`](https://github.com/paambaati/codeclimate-action/issues/265). Thanks @matthewshirley! - -# [2.7.4] - 2020-10-03 -### Added -- đŸ’Ģ Coverage locations can now be Glob patterns - via [`#240`](https://github.com/paambaati/codeclimate-action/pull/240). This closes [`#234`](https://github.com/paambaati/codeclimate-action/issues/234). Thanks @Sumolari! - -# [2.7.3] - 2020-10-01 -### Fixed -- 🐛 Default coverage command now correctly defaults to `''` - via [`#238`](https://github.com/paambaati/codeclimate-action/pull/238). This closes [`#235`](https://github.com/paambaati/codeclimate-action/issues/235). Thanks @bennypowers! - -# [2.7.2] - 2020-10-01 -### Fixed -- 🐛 The entrypoint logic was fixed so the script will _actually_ run now - via [`#236`](https://github.com/paambaati/codeclimate-action/pull/236). This closes [`#235`](https://github.com/paambaati/codeclimate-action/issues/235). - -# [2.7.1] - 2020-09-22 -### Added -- `coverageCommand` argument is now optional - via [`#220`](https://github.com/paambaati/codeclimate-action/pull/220). This closes [`#182`](https://github.com/paambaati/codeclimate-action/issues/182). - -# [2.7.0] - 2020-09-22 -### Added -- Customizable working directory with the new `workingDirectory` option - via [`#220`](https://github.com/paambaati/codeclimate-action/pull/220). Thanks @arareko! - -### Fixed -- Errors in the `before-build` and `after-build` steps, if any, are now surfaced correctly - via [`#214`](https://github.com/paambaati/codeclimate-action/pull/214). Thanks @olly! - -### Changed -- Dependencies upgraded to latest, including tape v5. - -# [2.6.0] - 2020-04-24 -### Fixed -- Fixed regressions introduced in [`#154`](https://github.com/paambaati/codeclimate-action/pull/154). Thanks @MartinNuc! - -# [2.5.7] - 2020-04-17 -### Fixed -- Finally fixed the long-standing [`#119`](https://github.com/paambaati/codeclimate-action/issues/119) with proper exit code handling - via [`#154`](https://github.com/paambaati/codeclimate-action/pull/154). - -# [2.5.6] - 2020-03-28 -### Fixed -- Correctly report `HEAD` SHA for PRs (and some nice refactors) - via [`#141`](https://github.com/paambaati/codeclimate-action/pull/141). Thanks @vladjerca! - -# [2.5.5] - 2020-03-18 -### Fixed -- `--prefix` fixes - via [`#131`](https://github.com/paambaati/codeclimate-action/pull/131). Thanks @rwjblue! - -# [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). - -# [2.5.2] - 2020-02-26 -### Changed -- [Better error message on failure of downloading CC Reporter](https://github.com/paambaati/codeclimate-action/issues/98) - via [`#116`](https://github.com/paambaati/codeclimate-action/pull/116). - -# [2.5.1] - 2020-02-26 -### Fixed -- Fix reporting the [wrong branch name for PRs](https://github.com/paambaati/codeclimate-action/issues/86) - via [`#115`](https://github.com/paambaati/codeclimate-action/pull/115). - -# [2.5.0] - 2020-02-25 -### Added -- Custom `--prefix` support - via [`#111`](https://github.com/paambaati/codeclimate-action/pull/111). - -# [2.4.0] - 2020-01-07 -### Added -- Multiple coverage locations support - via [`#77`](https://github.com/paambaati/codeclimate-action/pull/77). Thanks @mattvv! - -# [2.3.0] - 2019-10-31 -### Added -- Debug support - via [`#45`](https://github.com/paambaati/codeclimate-action/pull/45). - -# [2.2.6] - 2019-10-31 -### Fixed -- `env` issues introduced after the Husky-related fixes. - -# [2.2.5] - 2019-10-29 -### Fixed -- Remove `husky` as a dependency. - -### Changed -- Automated releases thanks to [`technote-space/release-github-actions`](https://github.com/technote-space/release-github-actions). - -# [2.2.4] - 2019-10-27 -### Fixed -- Fix [missing files](https://github.com/paambaati/codeclimate-action/issues/42#issuecomment-546676537). - -# [2.2.3] - 2019-10-27 -### Fixed -- Fix [runtime failures](https://github.com/paambaati/codeclimate-action/issues/42#issuecomment-546659123) - via [`0a0ba88`](https://github.com/paambaati/codeclimate-action/commit/0a0ba88ef1092c69d5be6235dc6d493a699ffb1a) and [`c2422ad`](https://github.com/paambaati/codeclimate-action/commit/c2422ad00a34ed3524226d5d1e2124e05a970874). - -# [2.2.2] - 2019-10-27 -### Fixed -- Code coverage will also be available in 'Overview' tab - via [#43](https://github.com/paambaati/codeclimate-action/pull/43). - -## [2.2.1] - 2019-09-19 -### Changed -- Upgrade to `@actions/core` v1.1.1 - via [#20](https://github.com/paambaati/codeclimate-action/pull/20). - -## [2.2.0] - 2019-08-28 -### Fixed -- Inject `GITHUB_` environment vars as CC-specific ones - via [#3](https://github.com/paambaati/codeclimate-action/pull/3). Thanks @b4nst! - -## [2.1.0] - 2019-08-16 -### Added -- Release script. - -### Changed -- ⚡ī¸ Replaced `got` with `node-fetch`. Now the action should run faster! - -## [2.0.0] - 2019-08-14 -### Changed -- ⚡ī¸ Change from Docker to JavaScript. - -## [1.0.0] - 2019-08-09 -### Added -- Initial release. diff --git a/test/fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc b/test/fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc deleted file mode 100644 index 33bb8a63..00000000 --- a/test/fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc +++ /dev/null @@ -1,54 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Comment: 9BD9 E2DD 46DA 965A 537E 5B0A 5CBF 3202 43B6 FD85 -Comment: Federico Moya - -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 -hQDdDhnylWEY62XJQA== -=AI17 ------END PGP PUBLIC KEY BLOCK----- diff --git a/test/fixtures/dummy-cc-reporter-after-build-error.sh b/test/fixtures/dummy-cc-reporter-after-build-error.sh deleted file mode 100644 index 68c8a6db..00000000 --- a/test/fixtures/dummy-cc-reporter-after-build-error.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# Dummy shell script that with a non-zero code when the argument 'after-build' is given. -if [[ "$*" == "after-build --exit-code 0" ]] - then exit 69 -else - : -fi diff --git a/test/fixtures/dummy-cc-reporter-after-build-error.sha256 b/test/fixtures/dummy-cc-reporter-after-build-error.sha256 deleted file mode 100644 index d0d21e13..00000000 --- a/test/fixtures/dummy-cc-reporter-after-build-error.sha256 +++ /dev/null @@ -1 +0,0 @@ -5f6b335c3d081dc45d93fa61f0e763d7317086c91bf464e994a023594295163f test/fixtures/dummy-cc-reporter-after-build-error.sh diff --git a/test/fixtures/dummy-cc-reporter-before-build-error.sh b/test/fixtures/dummy-cc-reporter-before-build-error.sh deleted file mode 100644 index 11e199d8..00000000 --- a/test/fixtures/dummy-cc-reporter-before-build-error.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# Dummy shell script exits with a non-zero code. -exit 69 diff --git a/test/fixtures/dummy-cc-reporter-before-build-error.sha256 b/test/fixtures/dummy-cc-reporter-before-build-error.sha256 deleted file mode 100644 index 9fd1ea5a..00000000 --- a/test/fixtures/dummy-cc-reporter-before-build-error.sha256 +++ /dev/null @@ -1 +0,0 @@ -7bbab1e443418dc4d00671c369725a3c46da409f57303825bf1a554bfc4db2a9 test/fixtures/dummy-cc-reporter-before-build-error.sh diff --git a/test/fixtures/dummy-cc-reporter.sh b/test/fixtures/dummy-cc-reporter.sh deleted file mode 100755 index c9469548..00000000 --- a/test/fixtures/dummy-cc-reporter.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# Dummy shell script that just echoes back all arguments. -echo "$*" diff --git a/test/fixtures/dummy-cc-reporter.sha256 b/test/fixtures/dummy-cc-reporter.sha256 deleted file mode 100644 index 9d061fab..00000000 --- a/test/fixtures/dummy-cc-reporter.sha256 +++ /dev/null @@ -1 +0,0 @@ -f6ee1f4ce8ed9da602f03b6193950938cccdc8f72fb73212223bf56b90465046 dummy-cc-reporter diff --git a/test/fixtures/dummy-cc-reporter.sha256.sig b/test/fixtures/dummy-cc-reporter.sha256.sig deleted file mode 100644 index 0dc935cb3b5afe19c4dce9e052b0ca1bd85112cf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 566 zcmV-60?GY}0y6{v0SEvc79j+i+2Y+s+Ll^Vep?D$zcK={pzx78keDsXqzqL$HA@@=JJ2Aky0|)+!u^G^nnQ`J zxu^=&Yd1d=3-Fn4Wg)Gs@GwFJK36NY6P>AIi|ReW{NY!1Qr-;P=Nxx4?6FEHRybwt zz$LUhgXyp6)*EI$0eyS?(3iy&&@I7kw~+sCt93d2G5gZ8`PKgxkW^Rbga!F&$kbej zK!#@SF@5x@%|tvz82*wu4ur5pQUMxB;$ID`<}3JJLYo+s%b)Zg^@DEzl^-}%C`8a4 zBoiyZsHeaUdc#>sEkY(d-btp8iZnY`!U$CIc& z29RGKTO>gH&mm$CA_Ykg?YNw?6?TH;!1Ab3Qdi)z0#TL(a`*>vlEh0JSTlonvA4Do zxN~(F0e|^ { - nock.disableNetConnect(); - if (!nock.isActive()) nock.activate(); - pExec('which echo', (err, stdout, stderr) => { - if (err || stderr) t.fail(err?.message || stderr); - DEFAULT_ECHO = stdout.trim(); // Finds system default `echo`. - t.end(); - }); -}); - -test('đŸ§Ē run() should run the CC reporter (happy path).', async (t) => { - t.plan(1); - t.teardown(() => sandbox.restore()); - const filePath = './test.sh'; - nock('http://localhost.test') - .get('/dummy-cc-reporter') - .reply(200, async () => { - const dummyReporterFile = './test/fixtures/dummy-cc-reporter.sh'; - const dummyReporter = await readFileAsync(dummyReporterFile); - return toReadableStream(dummyReporter); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256') - .reply(200, async () => { - const checksumFile = `./test/fixtures/dummy-cc-reporter.sha256`; - const checksum = await readFileAsync(checksumFile); - return toReadableStream(checksum); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256.sig') - .reply(200, async () => { - const signatureFile = `./test/fixtures/dummy-cc-reporter.sha256.sig`; - const signature = await readFileAsync(signatureFile); - return toReadableStream(signature); - }); - - nock('https://keys.openpgp.org') - .get(`/vks/v1/by-fingerprint/${CODECLIMATE_GPG_PUBLIC_KEY_ID}`) - .reply(200, async () => { - const publicKeyFile = `./test/fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc`; - const publicKey = await readFileAsync(publicKeyFile); - return toReadableStream(publicKey); - }); - - sandbox.stub(utils, 'verifySignature').resolves(true); - - let capturedOutput = ''; - const stdHook = hookStd((text: string) => { - capturedOutput += text; - }); - - try { - await run( - 'http://localhost.test/dummy-cc-reporter', - filePath, - `echo 'coverage ok'` - ); - stdHook.unhook(); - } catch (err) { - stdHook.unhook(); - t.fail(err); - } finally { - nock.cleanAll(); - } - - t.equal( - capturedOutput, - // prettier-ignore - `::debug::ℹī¸ Downloading CC Reporter from http://localhost.test/dummy-cc-reporter ... -::debug::✅ CC Reporter downloaded... -::debug::ℹī¸ Verifying CC Reporter checksum... -::debug::✅ CC Reported checksum verification completed... -::debug::ℹī¸ Verifying CC Reporter GPG signature... -::debug::✅ CC Reported GPG signature verification completed... -[command]${DEFAULT_WORKDIR}/test.sh before-build\nbefore-build -::debug::✅ CC Reporter before-build checkin completed... -[command]${DEFAULT_ECHO} \'coverage ok\' -\'coverage ok\' -::debug::✅ Coverage run completed... -[command]${DEFAULT_WORKDIR}/test.sh after-build --exit-code 0 -after-build --exit-code 0 -::debug::✅ CC Reporter after-build checkin completed! -`, - 'should execute all steps.' - ); - unlinkSync(filePath); - unlinkSync(`${filePath}.sha256`); - unlinkSync(`${filePath}.sha256.sig`); - unlinkSync('public-key.asc'); - nock.cleanAll(); - t.end(); -}); - -test('đŸ§Ē run() should run the CC reporter without verification if configured.', async (t) => { - t.plan(1); - t.teardown(() => sandbox.restore()); - const filePath = './test.sh'; - nock('http://localhost.test') - .get('/dummy-cc-reporter') - .reply(200, async () => { - const dummyReporterFile = './test/fixtures/dummy-cc-reporter.sh'; - const dummyReporter = await readFileAsync(dummyReporterFile); - return toReadableStream(dummyReporter); - }); - - let capturedOutput = ''; - const stdHook = hookStd((text: string) => { - capturedOutput += text; - }); - - try { - await run( - 'http://localhost.test/dummy-cc-reporter', - filePath, - `echo 'coverage ok'`, - undefined, - undefined, - undefined, - undefined, - 'false' - ); - stdHook.unhook(); - } catch (err) { - stdHook.unhook(); - t.fail(err); - } finally { - nock.cleanAll(); - } - - t.equal( - capturedOutput, - // prettier-ignore - `::debug::ℹī¸ Downloading CC Reporter from http://localhost.test/dummy-cc-reporter ... -::debug::✅ CC Reporter downloaded... -[command]${DEFAULT_WORKDIR}/test.sh before-build\nbefore-build -::debug::✅ CC Reporter before-build checkin completed... -[command]${DEFAULT_ECHO} \'coverage ok\' -\'coverage ok\' -::debug::✅ Coverage run completed... -[command]${DEFAULT_WORKDIR}/test.sh after-build --exit-code 0 -after-build --exit-code 0 -::debug::✅ CC Reporter after-build checkin completed! -`, - 'should execute all steps (except verification).' - ); - unlinkSync(filePath); - nock.cleanAll(); - t.end(); -}); - -test('đŸ§Ē run() should run the CC reporter without a coverage command.', async (t) => { - t.plan(1); - t.teardown(() => sandbox.restore()); - const filePath = './test.sh'; - nock('http://localhost.test') - .get('/dummy-cc-reporter') - .reply(200, async () => { - const dummyReporterFile = './test/fixtures/dummy-cc-reporter.sh'; - const dummyReporter = await readFileAsync(dummyReporterFile); - return toReadableStream(dummyReporter); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256') - .reply(200, async () => { - const checksumFile = `./test/fixtures/dummy-cc-reporter.sha256`; - const checksum = await readFileAsync(checksumFile); - return toReadableStream(checksum); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256.sig') - .reply(200, async () => { - const signatureFile = `./test/fixtures/dummy-cc-reporter.sha256.sig`; - const signature = await readFileAsync(signatureFile); - return toReadableStream(signature); - }); - - nock('https://keys.openpgp.org') - .get(`/vks/v1/by-fingerprint/${CODECLIMATE_GPG_PUBLIC_KEY_ID}`) - .reply(200, async () => { - const publicKeyFile = `./test/fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc`; - const publicKey = await readFileAsync(publicKeyFile); - return toReadableStream(publicKey); - }); - - sandbox.stub(utils, 'verifySignature').resolves(true); - - let capturedOutput = ''; - const stdHook = hookStd((text: string) => { - capturedOutput += text; - }); - - try { - await run('http://localhost.test/dummy-cc-reporter', filePath, ''); - stdHook.unhook(); - } catch (err) { - stdHook.unhook(); - t.fail(err); - } finally { - nock.cleanAll(); - } - - t.equal( - capturedOutput, - // prettier-ignore - `::debug::ℹī¸ Downloading CC Reporter from http://localhost.test/dummy-cc-reporter ... -::debug::✅ CC Reporter downloaded... -::debug::ℹī¸ Verifying CC Reporter checksum... -::debug::✅ CC Reported checksum verification completed... -::debug::ℹī¸ Verifying CC Reporter GPG signature... -::debug::✅ CC Reported GPG signature verification completed... -[command]${DEFAULT_WORKDIR}/test.sh before-build\nbefore-build -::debug::✅ CC Reporter before-build checkin completed... -ℹī¸ 'coverageCommand' not set, so skipping building coverage report! -[command]${DEFAULT_WORKDIR}/test.sh after-build --exit-code 0 -after-build --exit-code 0 -::debug::✅ CC Reporter after-build checkin completed! -`, - 'should execute all steps (except running the coverage command).' - ); - unlinkSync(filePath); - unlinkSync(`${filePath}.sha256`); - unlinkSync(`${filePath}.sha256.sig`); - unlinkSync('public-key.asc'); - nock.cleanAll(); - t.end(); -}); - -test('đŸ§Ē run() should convert patterns to locations.', async (t) => { - t.plan(3); - t.teardown(() => sandbox.restore()); - const globSpy = sandbox - .stub() - .resolves([ - joinPath(DEFAULT_WORKDIR, './file-a.lcov'), - joinPath(DEFAULT_WORKDIR, './file-b.lcov'), - ]); - sandbox.stub(glob, 'create').resolves({ - glob: globSpy, - getSearchPaths: sandbox.spy(), - globGenerator: sandbox.spy(), - }); - const filePath = './test.sh'; - nock('http://localhost.test') - .get('/dummy-cc-reporter') - .reply(200, async () => { - const dummyReporterFile = './test/fixtures/dummy-cc-reporter.sh'; - const dummyReporter = await readFileAsync(dummyReporterFile); - return toReadableStream(dummyReporter); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256') - .reply(200, async () => { - const checksumFile = `./test/fixtures/dummy-cc-reporter.sha256`; - const checksum = await readFileAsync(checksumFile); - return toReadableStream(checksum); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256.sig') - .reply(200, async () => { - const signatureFile = `./test/fixtures/dummy-cc-reporter.sha256.sig`; - const signature = await readFileAsync(signatureFile); - return toReadableStream(signature); - }); - - nock('https://keys.openpgp.org') - .get(`/vks/v1/by-fingerprint/${CODECLIMATE_GPG_PUBLIC_KEY_ID}`) - .reply(200, async () => { - const publicKeyFile = `./test/fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc`; - const publicKey = await readFileAsync(publicKeyFile); - return toReadableStream(publicKey); - }); - - sandbox.stub(utils, 'verifySignature').resolves(true); - - const filePattern = `${DEFAULT_WORKDIR}/*.lcov:lcov`; - const fileA = 'file-a.lcov'; - const fileB = 'file-b.lcov'; - - writeFileSync(fileA, 'file a content'); - writeFileSync(fileB, 'file b content'); - - let capturedOutput = ''; - const stdHook = hookStd((text: string) => { - capturedOutput += text; - }); - - try { - await run( - 'http://localhost.test/dummy-cc-reporter', - filePath, - '', - '', - 'false', - filePattern - ); - stdHook.unhook(); - } catch (err) { - stdHook.unhook(); - t.fail(err); - } finally { - nock.cleanAll(); - } - - t.deepEquals( - (glob.create as unknown as sinon.SinonSpy).firstCall.firstArg, - `${DEFAULT_WORKDIR}/*.lcov`, - 'should create a globber with given pattern.' - ); - t.true( - globSpy.calledOnceWithExactly(), - 'should get the paths of the files from the newly created globber instance.' - ); - t.equal( - capturedOutput, - // prettier-ignore - `::debug::ℹī¸ Downloading CC Reporter from http://localhost.test/dummy-cc-reporter ... -::debug::✅ CC Reporter downloaded... -::debug::ℹī¸ Verifying CC Reporter checksum... -::debug::✅ CC Reported checksum verification completed... -::debug::ℹī¸ Verifying CC Reporter GPG signature... -::debug::✅ CC Reported GPG signature verification completed... -[command]${DEFAULT_WORKDIR}/test.sh before-build -before-build -::debug::✅ CC Reporter before-build checkin completed... -ℹī¸ 'coverageCommand' not set, so skipping building coverage report! -::debug::Parsing 2 coverage location(s) — ${DEFAULT_WORKDIR}/file-a.lcov:lcov,${DEFAULT_WORKDIR}/file-b.lcov:lcov (object) -[command]${DEFAULT_WORKDIR}/test.sh format-coverage ${DEFAULT_WORKDIR}/file-a.lcov -t lcov -o codeclimate.0.json -format-coverage ${DEFAULT_WORKDIR}/file-a.lcov -t lcov -o codeclimate.0.json -[command]${DEFAULT_WORKDIR}/test.sh format-coverage ${DEFAULT_WORKDIR}/file-b.lcov -t lcov -o codeclimate.1.json -format-coverage ${DEFAULT_WORKDIR}/file-b.lcov -t lcov -o codeclimate.1.json -[command]${DEFAULT_WORKDIR}/test.sh sum-coverage codeclimate.0.json codeclimate.1.json -p 2 -o coverage.total.json -sum-coverage codeclimate.0.json codeclimate.1.json -p 2 -o coverage.total.json -[command]${DEFAULT_WORKDIR}/test.sh upload-coverage -i coverage.total.json -upload-coverage -i coverage.total.json -::debug::✅ CC Reporter upload coverage completed! -`, - 'should execute all steps (except running the coverage command).' - ); - unlinkSync(filePath); - unlinkSync(`${filePath}.sha256`); - unlinkSync(`${filePath}.sha256.sig`); - unlinkSync('public-key.asc'); - unlinkSync(fileA); - unlinkSync(fileB); - nock.cleanAll(); - t.end(); -}); - -test('đŸ§Ē run() should correctly switch the working directory if given.', async (t) => { - t.plan(1); - t.teardown(() => sandbox.restore()); - const filePath = './test.sh'; - nock('http://localhost.test') - .get('/dummy-cc-reporter') - .reply(200, async () => { - const dummyReporterFile = joinPath( - __dirname, - './fixtures/dummy-cc-reporter.sh' - ); - const dummyReporter = await readFileAsync(dummyReporterFile); - return toReadableStream(dummyReporter); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256') - .reply(200, async () => { - const checksumFile = joinPath( - __dirname, - './fixtures/dummy-cc-reporter.sha256' - ); - const checksum = await readFileAsync(checksumFile); - return toReadableStream(checksum); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256.sig') - .reply(200, async () => { - const signatureFile = joinPath( - __dirname, - './fixtures/dummy-cc-reporter.sha256.sig' - ); - const signature = await readFileAsync(signatureFile); - return toReadableStream(signature); - }); - - nock('https://keys.openpgp.org') - .get(`/vks/v1/by-fingerprint/${CODECLIMATE_GPG_PUBLIC_KEY_ID}`) - .reply(200, async () => { - const publicKeyFile = joinPath( - __dirname, - `./fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc` - ); - const publicKey = await readFileAsync(publicKeyFile); - return toReadableStream(publicKey); - }); - - sandbox.stub(utils, 'verifySignature').resolves(true); - - let capturedOutput = ''; - const stdHook = hookStd((text: string) => { - capturedOutput += text; - }); - - const CUSTOM_WORKDIR = await realpath(tmpdir()); - try { - await run( - 'http://localhost.test/dummy-cc-reporter', - filePath, - `echo 'coverage ok'`, - CUSTOM_WORKDIR - ); - stdHook.unhook(); - } catch (err) { - stdHook.unhook(); - t.fail(err); - } finally { - nock.cleanAll(); - } - - t.equal( - capturedOutput, - // prettier-ignore - `::debug::Changing working directory to ${CUSTOM_WORKDIR} -::debug::✅ Changing working directory completed... -::debug::ℹī¸ Downloading CC Reporter from http://localhost.test/dummy-cc-reporter ... -::debug::✅ CC Reporter downloaded... -::debug::ℹī¸ Verifying CC Reporter checksum... -::debug::✅ CC Reported checksum verification completed... -::debug::ℹī¸ Verifying CC Reporter GPG signature... -::debug::✅ CC Reported GPG signature verification completed... -[command]${CUSTOM_WORKDIR}/test.sh before-build -before-build -::debug::✅ CC Reporter before-build checkin completed... -[command]${DEFAULT_ECHO} 'coverage ok' -'coverage ok' -::debug::✅ Coverage run completed... -[command]${CUSTOM_WORKDIR}/test.sh after-build --exit-code 0 -after-build --exit-code 0 -::debug::✅ CC Reporter after-build checkin completed! -`, - 'should execute all steps.' - ); - unlinkSync(filePath); - nock.cleanAll(); - process.chdir(DEFAULT_WORKDIR); - t.end(); -}); - -test('đŸ§Ē run() should throw an error if run on Windows.', async (t) => { - t.plan(1); - t.teardown(() => sandbox.restore()); - - sandbox.stub(os, 'platform').returns('win32'); - - try { - await run('http://localhost.test/dummy-cc-reporter', undefined); - t.fail('should actually throw an error and not succeed'); - } catch (err) { - t.equal( - (err as Error).message, - 'CC Reporter is not supported on Windows!', - 'should return the correct error message.' - ); - } - - t.end(); -}); - -test('đŸ§Ē run() should throw an error if the checksum verification fails.', async (t) => { - t.plan(1); - t.teardown(() => sandbox.restore()); - const filePath = './test.sh'; - nock('http://localhost.test') - .get('/dummy-cc-reporter') - .reply(200, async () => { - const dummyReporterFile = - './test/fixtures/dummy-cc-reporter-before-build-error.sh'; - const dummyReporter = await readFileAsync(dummyReporterFile); - return toReadableStream(dummyReporter); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256') - .reply(200, () => { - const dummyChecksum = 'lolno'; - return toReadableStream(dummyChecksum); - }); - - let capturedOutput = ''; - const stdHook = hookStd((text: string) => { - capturedOutput += text; - }); - - try { - await run( - 'http://localhost.test/dummy-cc-reporter', - filePath, - `echo 'coverage ok'` - ); - stdHook.unhook(); - } catch (err) { - stdHook.unhook(); - // do nothing else, we expect this run command to fail. - } finally { - nock.cleanAll(); - } - - t.equal( - capturedOutput, - // prettier-ignore - `::debug::ℹī¸ Downloading CC Reporter from http://localhost.test/dummy-cc-reporter ... -::debug::✅ CC Reporter downloaded... -::debug::ℹī¸ Verifying CC Reporter checksum... -::error::CC Reporter checksum does not match! -::error::🚨 CC Reporter checksum verfication failed! -`, - 'should correctly throw the error.' - ); - unlinkSync(filePath); - unlinkSync(`${filePath}.sha256`); - nock.cleanAll(); - t.end(); -}); - -test('đŸ§Ē run() should throw an error if the GPG signature verification fails.', async (t) => { - t.plan(1); - t.teardown(() => sandbox.restore()); - const filePath = './test.sh'; - nock('http://localhost.test') - .get('/dummy-cc-reporter') - .reply(200, async () => { - const dummyReporterFile = - './test/fixtures/dummy-cc-reporter-before-build-error.sh'; - const dummyReporter = await readFileAsync(dummyReporterFile); - return toReadableStream(dummyReporter); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256') - .reply(200, async () => { - const checksumFile = `./test/fixtures/dummy-cc-reporter-before-build-error.sha256`; - const checksum = await readFileAsync(checksumFile); - return toReadableStream(checksum); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256.sig') - .reply(200, async () => { - const signatureFile = `./test/fixtures/dummy-cc-reporter.sha256.sig`; - const signature = await readFileAsync(signatureFile); - return toReadableStream(signature); - }); - - nock('https://keys.openpgp.org') - .get(`/vks/v1/by-fingerprint/${CODECLIMATE_GPG_PUBLIC_KEY_ID}`) - .reply(200, async () => { - const publicKeyFile = `./test/fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc`; - const publicKey = await readFileAsync(publicKeyFile); - return toReadableStream(publicKey); - }); - - sandbox.stub(utils, 'verifySignature').resolves(false); - - let capturedOutput = ''; - const stdHook = hookStd((text: string) => { - capturedOutput += text; - }); - - try { - await run( - 'http://localhost.test/dummy-cc-reporter', - filePath, - `echo 'coverage ok'` - ); - stdHook.unhook(); - } catch (err) { - stdHook.unhook(); - // do nothing else, we expect this run command to fail. - } finally { - nock.cleanAll(); - } - - t.equal( - capturedOutput, - // prettier-ignore - `::debug::ℹī¸ Downloading CC Reporter from http://localhost.test/dummy-cc-reporter ... -::debug::✅ CC Reporter downloaded... -::debug::ℹī¸ Verifying CC Reporter checksum... -::debug::✅ CC Reported checksum verification completed... -::debug::ℹī¸ Verifying CC Reporter GPG signature... -::error::CC Reporter GPG signature is invalid! -::error::🚨 CC Reporter GPG signature verfication failed! -`, - 'should correctly throw the error.' - ); - unlinkSync(filePath); - unlinkSync(`${filePath}.sha256`); - unlinkSync(`${filePath}.sha256.sig`); - unlinkSync('public-key.asc'); - nock.cleanAll(); - t.end(); -}); - -test('đŸ§Ē run() should throw an error if the before-build step throws an error.', async (t) => { - t.plan(1); - t.teardown(() => sandbox.restore()); - const filePath = './test.sh'; - nock('http://localhost.test') - .get('/dummy-cc-reporter') - .reply(200, async () => { - const dummyReporterFile = - './test/fixtures/dummy-cc-reporter-before-build-error.sh'; - const dummyReporter = await readFileAsync(dummyReporterFile); - return toReadableStream(dummyReporter); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256') - .reply(200, async () => { - const checksumFile = `./test/fixtures/dummy-cc-reporter-before-build-error.sha256`; - const checksum = await readFileAsync(checksumFile); - return toReadableStream(checksum); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256.sig') - .reply(200, async () => { - const signatureFile = `./test/fixtures/dummy-cc-reporter.sha256.sig`; - const signature = await readFileAsync(signatureFile); - return toReadableStream(signature); - }); - - nock('https://keys.openpgp.org') - .get(`/vks/v1/by-fingerprint/${CODECLIMATE_GPG_PUBLIC_KEY_ID}`) - .reply(200, async () => { - const publicKeyFile = `./test/fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc`; - const publicKey = await readFileAsync(publicKeyFile); - return toReadableStream(publicKey); - }); - - sandbox.stub(utils, 'verifySignature').resolves(true); - - let capturedOutput = ''; - const stdHook = hookStd((text: string) => { - capturedOutput += text; - }); - - try { - await run( - 'http://localhost.test/dummy-cc-reporter', - filePath, - `echo 'coverage ok'` - ); - stdHook.unhook(); - } catch (err) { - stdHook.unhook(); - // do nothing else, we expect this run command to fail. - } finally { - nock.cleanAll(); - } - - t.equal( - capturedOutput, - // prettier-ignore - `::debug::ℹī¸ Downloading CC Reporter from http://localhost.test/dummy-cc-reporter ... -::debug::✅ CC Reporter downloaded... -::debug::ℹī¸ Verifying CC Reporter checksum... -::debug::✅ CC Reported checksum verification completed... -::debug::ℹī¸ Verifying CC Reporter GPG signature... -::debug::✅ CC Reported GPG signature verification completed... -[command]${DEFAULT_WORKDIR}/test.sh before-build -::error::The process '${DEFAULT_WORKDIR}/test.sh' failed with exit code 69 -::error::🚨 CC Reporter before-build checkin failed! -`, - 'should correctly throw the error.' - ); - unlinkSync(filePath); - unlinkSync(`${filePath}.sha256`); - unlinkSync(`${filePath}.sha256.sig`); - unlinkSync('public-key.asc'); - nock.cleanAll(); - t.end(); -}); - -test('đŸ§Ē run() should throw an error if the after-build step throws an error.', async (t) => { - t.plan(1); - t.teardown(() => sandbox.restore()); - const filePath = './test.sh'; - nock('http://localhost.test') - .get('/dummy-cc-reporter') - .reply(200, async () => { - const dummyReporterFile = - './test/fixtures/dummy-cc-reporter-after-build-error.sh'; - const dummyReporter = await readFileAsync(dummyReporterFile); - return toReadableStream(dummyReporter); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256') - .reply(200, async () => { - const checksumFile = `./test/fixtures/dummy-cc-reporter-after-build-error.sha256`; - const checksum = await readFileAsync(checksumFile); - return toReadableStream(checksum); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256.sig') - .reply(200, async () => { - const signatureFile = `./test/fixtures/dummy-cc-reporter.sha256.sig`; - const signature = await readFileAsync(signatureFile); - return toReadableStream(signature); - }); - - nock('https://keys.openpgp.org') - .get(`/vks/v1/by-fingerprint/${CODECLIMATE_GPG_PUBLIC_KEY_ID}`) - .reply(200, async () => { - const publicKeyFile = `./test/fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc`; - const publicKey = await readFileAsync(publicKeyFile); - return toReadableStream(publicKey); - }); - - sandbox.stub(utils, 'verifySignature').resolves(true); - - let capturedOutput = ''; - const stdHook = hookStd((text: string) => { - capturedOutput += text; - }); - - try { - await run( - 'http://localhost.test/dummy-cc-reporter', - filePath, - `echo 'coverage ok'` - ); - stdHook.unhook(); - } catch (err) { - stdHook.unhook(); - // do nothing else, we expect this run command to fail. - } finally { - nock.cleanAll(); - } - - t.equal( - capturedOutput, - // prettier-ignore - `::debug::ℹī¸ Downloading CC Reporter from http://localhost.test/dummy-cc-reporter ... -::debug::✅ CC Reporter downloaded... -::debug::ℹī¸ Verifying CC Reporter checksum... -::debug::✅ CC Reported checksum verification completed... -::debug::ℹī¸ Verifying CC Reporter GPG signature... -::debug::✅ CC Reported GPG signature verification completed... -[command]${DEFAULT_WORKDIR}/test.sh before-build -::debug::✅ CC Reporter before-build checkin completed... -[command]${DEFAULT_ECHO} 'coverage ok' -'coverage ok' -::debug::✅ Coverage run completed... -[command]${DEFAULT_WORKDIR}/test.sh after-build --exit-code 0 -::error::The process '${DEFAULT_WORKDIR}/test.sh' failed with exit code 69 -::error::🚨 CC Reporter after-build checkin failed! -`, - 'should correctly throw the error.' - ); - unlinkSync(filePath); - unlinkSync(`${filePath}.sha256`); - unlinkSync(`${filePath}.sha256.sig`); - unlinkSync('public-key.asc'); - nock.cleanAll(); - t.end(); -}); - -// TODO: @paambaati — Figure out why this test itself passes but why tape fails with exit code 1. -test('đŸ§Ē run() should exit cleanly when the coverage command fails.', async (t) => { - t.plan(1); - t.teardown(() => sandbox.restore()); - const COVERAGE_COMMAND = 'wololololo'; // Random command that doesn't exist (and so should fail). - const filePath = './test.sh'; - nock('http://localhost.test') - .get('/dummy-cc-reporter') - .reply(200, async () => { - const dummyReporterFile = './test/fixtures/dummy-cc-reporter.sh'; - const dummyReporter = await readFileAsync(dummyReporterFile); - return toReadableStream(dummyReporter); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256') - .reply(200, async () => { - const checksumFile = `./test/fixtures/dummy-cc-reporter.sha256`; - const checksum = await readFileAsync(checksumFile); - return toReadableStream(checksum); - }); - - nock('http://localhost.test') - .get('/dummy-cc-reporter.sha256.sig') - .reply(200, async () => { - const signatureFile = `./test/fixtures/dummy-cc-reporter.sha256.sig`; - const signature = await readFileAsync(signatureFile); - return toReadableStream(signature); - }); - - nock('https://keys.openpgp.org') - .get(`/vks/v1/by-fingerprint/${CODECLIMATE_GPG_PUBLIC_KEY_ID}`) - .reply(200, async () => { - const publicKeyFile = `./test/fixtures/9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85.asc`; - const publicKey = await readFileAsync(publicKeyFile); - return toReadableStream(publicKey); - }); - - sandbox.stub(utils, 'verifySignature').resolves(true); - - let capturedOutput = ''; - const stdHook = hookStd((text: string) => { - capturedOutput += text; - }); - - try { - await run( - 'http://localhost.test/dummy-cc-reporter', - filePath, - COVERAGE_COMMAND - ); - stdHook.unhook(); - t.fail('Should throw an error.'); - } catch (err) { - stdHook.unhook(); - t.equal( - capturedOutput, - // prettier-ignore - `::debug::ℹī¸ Downloading CC Reporter from http://localhost.test/dummy-cc-reporter ... -::debug::✅ CC Reporter downloaded... -::debug::ℹī¸ Verifying CC Reporter checksum... -::debug::✅ CC Reported checksum verification completed... -::debug::ℹī¸ Verifying CC Reporter GPG signature... -::debug::✅ CC Reported GPG signature verification completed... -[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); - unlinkSync(`${filePath}.sha256`); - unlinkSync(`${filePath}.sha256.sig`); - unlinkSync('public-key.asc'); - nock.cleanAll(); - t.end(); - } -}); - -test('đŸ’Ŗ teardown', (t) => { - nock.restore(); - nock.cleanAll(); - nock.enableNetConnect(); - sandbox.restore(); - if (process.exitCode === 1) process.exitCode = 0; // This is required because @actions/core `setFailed` sets the exit code to 0 when we're testing errors. - t.end(); -}); diff --git a/test/utils.test.ts b/test/utils.test.ts deleted file mode 100644 index edb9d8de..00000000 --- a/test/utils.test.ts +++ /dev/null @@ -1,63 +0,0 @@ -import test from 'tape'; -import nock from 'nock'; -import toReadableStream from 'to-readable-stream'; -import { stat as statCallback, unlinkSync } from 'fs'; -import { promisify } from 'util'; -import { areObjectsEqual, downloadToFile } from '../src/utils'; - -const stat = promisify(statCallback); - -test('🛠 setup', (t) => { - nock.disableNetConnect(); - if (!nock.isActive()) nock.activate(); - t.end(); -}); - -test('đŸ§Ē areObjectsEqual() should correctly check object equality', (t) => { - t.plan(1); - const obj1 = { - a: 1, - b: true, - c: null, - d: undefined, - 45: -45.223232323, - }; - t.true( - areObjectsEqual(obj1, { ...obj1 }), - 'objects should be compared correctly.' - ); - t.end(); -}); - -test('đŸ§Ē downloadToFile() should download the give URL and write to given file location with given mode.', async (t) => { - t.plan(1); - const filePath = './test.sh'; - nock('http://localhost.test') - .get('/dummy-cc-reporter') - .reply(200, () => { - return toReadableStream(`#!/bin/bash -echo "hello" -`); - }); - await downloadToFile( - 'http://localhost.test/dummy-cc-reporter', - filePath, - 0o777 - ); - const stats = await stat(filePath); - t.equal( - stats.mode, - 33261, - 'downloaded file should exist and have executable permissions.' - ); - unlinkSync(filePath); - nock.cleanAll(); -}); - -test('đŸ’Ŗ teardown', (t) => { - nock.restore(); - nock.cleanAll(); - nock.enableNetConnect(); - if (process.exitCode === 1) process.exitCode = 0; // This is required because @actions/core `setFailed` sets the exit code to 0 when we're testing errors. - t.end(); -});