From 263805a5f4716e4c23f0c35d01c3d619e904d44c Mon Sep 17 00:00:00 2001 From: Alex Foster Date: Tue, 5 Oct 2021 11:04:20 +0100 Subject: [PATCH] Use getBooleanInput for update-comment argument Fixes #21 --- package.json | 2 +- src/__tests__/index_test.js | 7 ++++++- src/index.js | 2 +- yarn.lock | 22 ++++++++++++++++++---- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index f65c6a8..e67c4b1 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "format": "prettier --write src/*.js src/**/*.js" }, "dependencies": { - "@actions/core": "^1.2.0", + "@actions/core": "^1.6.0", "@actions/github": "^1.1.0", "lcov-parse": "^1.0.0" }, diff --git a/src/__tests__/index_test.js b/src/__tests__/index_test.js index 1e79891..d68bd6e 100644 --- a/src/__tests__/index_test.js +++ b/src/__tests__/index_test.js @@ -6,6 +6,7 @@ import { commentIdentifier, diff } from "../comment" jest.mock("@actions/core", () => ({ getInput: jest.fn(), + getBooleanInput: jest.fn(), setFailed: jest.fn(), })) @@ -39,10 +40,14 @@ beforeEach(() => { if (arg === "name") return "NAME" if (arg === "lcov-file") return "LCOV_FILE" if (arg === "lcov-base") return "LCOV_BASE" - if (arg === "update-comment") return updateComment return "" }) + core.getBooleanInput.mockImplementation(arg => { + if (arg === "update-comment") return updateComment + return false + }) + context.payload.pull_request = { base: { ref: "base-ref" }, head: { ref: "head-ref" }, diff --git a/src/index.js b/src/index.js index ef177fc..39f1207 100644 --- a/src/index.js +++ b/src/index.js @@ -10,7 +10,7 @@ async function main() { const name = core.getInput("name") const lcovFile = core.getInput("lcov-file") || "./coverage/lcov.info" const baseFile = core.getInput("lcov-base") - const updateComment = core.getInput("update-comment") + const updateComment = core.getBooleanInput("update-comment") const raw = await fs.readFile(lcovFile, "utf-8").catch(err => null) if (!raw) { diff --git a/yarn.lock b/yarn.lock index 02aa055..e3c1c02 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,12 @@ # yarn lockfile v1 -"@actions/core@^1.2.0": - version "1.2.6" - resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09" - integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA== +"@actions/core@^1.6.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.6.0.tgz#0568e47039bfb6a9170393a73f3b7eb3b22462cb" + integrity sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw== + dependencies: + "@actions/http-client" "^1.0.11" "@actions/github@^1.1.0": version "1.1.0" @@ -15,6 +17,13 @@ "@octokit/graphql" "^2.0.1" "@octokit/rest" "^16.15.0" +"@actions/http-client@^1.0.11": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.11.tgz#c58b12e9aa8b159ee39e7dd6cbd0e91d905633c0" + integrity sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg== + dependencies: + tunnel "0.0.6" + "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" @@ -4510,6 +4519,11 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" +tunnel@0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" + integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg== + tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"