From ea280dfd67ce2ed8db0619576ac6a60726ca2d3b Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 16 Sep 2021 03:49:25 -0500 Subject: [PATCH] feat: add opencppcoverage --- action.yml | 3 +++ src/main.ts | 7 +++++++ .../__tests__/opencppcoverage.test.ts | 17 +++++++++++++++++ src/opencppcoverage/opencppcoverage.ts | 10 ++++++++++ 4 files changed, 37 insertions(+) create mode 100644 src/opencppcoverage/__tests__/opencppcoverage.test.ts create mode 100644 src/opencppcoverage/opencppcoverage.ts diff --git a/action.yml b/action.yml index f5f375ff..6ec9256a 100644 --- a/action.yml +++ b/action.yml @@ -42,6 +42,9 @@ inputs: cppcheck: description: "The cppcheck version to install." required: false + opencppcoverage: + description: "The opencppcoverage version to install." + required: false runs: using: "node12" diff --git a/src/main.ts b/src/main.ts index ba54dfd7..fc9f5087 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,6 +11,7 @@ import { setupLLVM } from "./llvm/llvm" import { setupMeson } from "./meson/meson" import { setupMSVC } from "./msvc/msvc" import { setupNinja } from "./ninja/ninja" +import { setupOpencppcoverage } from "./opencppcoverage/opencppcoverage" import { setupPython } from "./python/python" function maybeGetInput(key: string) { @@ -61,6 +62,12 @@ export async function main(): Promise { await setupGcovr(gcovrVersion) } + // setup opencppCoverage + const opencppCoverageVersion = maybeGetInput("opencppcoverage") + if (opencppCoverageVersion !== undefined) { + await setupOpencppcoverage(gcovrVersion) + } + // setup llvm const llvmVersion = maybeGetInput("llvm") if (llvmVersion !== undefined) { diff --git a/src/opencppcoverage/__tests__/opencppcoverage.test.ts b/src/opencppcoverage/__tests__/opencppcoverage.test.ts new file mode 100644 index 00000000..ca00db92 --- /dev/null +++ b/src/opencppcoverage/__tests__/opencppcoverage.test.ts @@ -0,0 +1,17 @@ +import { setupOpencppcoverage } from "../opencppcoverage" +import { spawnSync as spawn } from "child_process" + +jest.setTimeout(200000) +describe("setup-OpenCppCoverage", () => { + it("should setup OpenCppCoverage", async () => { + if (process.platform !== "win32") { + return + } + await setupOpencppcoverage() + + const { status } = spawn("OpenCppCoverage", ["--version"], { + encoding: "utf8", + }) + expect(status).toBe(0) + }) +}) diff --git a/src/opencppcoverage/opencppcoverage.ts b/src/opencppcoverage/opencppcoverage.ts new file mode 100644 index 00000000..9478ea59 --- /dev/null +++ b/src/opencppcoverage/opencppcoverage.ts @@ -0,0 +1,10 @@ +import { addPath } from "@actions/core" +import { setupChocoPack } from "../utils/setup/setupChocoPack" + +export async function setupOpencppcoverage(version?: string) { + if (process.platform !== "win32") { + return + } + await setupChocoPack("opencppcoverage", version) + addPath("C:/Program Files/OpenCppCoverage") +}