From 9d9f62c579a2ac335f858b0191667bebf7994e18 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 14 Sep 2021 12:42:08 -0500 Subject: [PATCH] feat: add gcovr installation --- README.md | 2 +- action.yml | 3 +++ src/gcovr/__tests__/gcovr.test.ts | 15 +++++++++++++++ src/gcovr/gcovr.ts | 15 +++++++++++++++ src/main.ts | 7 +++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/gcovr/__tests__/gcovr.test.ts create mode 100644 src/gcovr/gcovr.ts diff --git a/README.md b/README.md index 1aa1b67b..6a3914bb 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,10 @@ The package will be usable from any environment (locally, GitHub Actions, etc). - [x] setup llvm - [x] setup conan - [x] setup meson +- [x] setup gcovr - [ ] setup msvc - [ ] setup gcc/mingw - [ ] setup vcpkg -- [ ] setup gcovr - [ ] setup OpenCppCoverage - [ ] setup cppcheck - [ ] setup doxygen diff --git a/action.yml b/action.yml index 3ae8202b..ec2e82cc 100644 --- a/action.yml +++ b/action.yml @@ -23,6 +23,9 @@ inputs: meson: description: "The meson version to install." required: false + gcovr: + description: "The gcovr version to install." + required: false runs: using: "node12" diff --git a/src/gcovr/__tests__/gcovr.test.ts b/src/gcovr/__tests__/gcovr.test.ts new file mode 100644 index 00000000..83f31f8e --- /dev/null +++ b/src/gcovr/__tests__/gcovr.test.ts @@ -0,0 +1,15 @@ +import { setupGcovr } from "../gcovr" +import { spawnSync as spawn } from "child_process" + +jest.setTimeout(100000) + +describe("setup-gcovr", () => { + it("should setup gcovr", async () => { + await setupGcovr("5.0") + + const { status } = spawn("gcovr", ["--version"], { + encoding: "utf8", + }) + expect(status).toBe(0) + }) +}) diff --git a/src/gcovr/gcovr.ts b/src/gcovr/gcovr.ts new file mode 100644 index 00000000..06d27eda --- /dev/null +++ b/src/gcovr/gcovr.ts @@ -0,0 +1,15 @@ +import { setupPip } from "../utils/setup/setupPip" +import { addPath, startGroup, endGroup } from "@actions/core" + +export async function setupGcovr(version?: string) { + await setupPip("gcovr", version) + + if (process.platform === "linux") { + try { + startGroup(`Add /home/runner/.local/bin to PATH`) + addPath("/home/runner/.local/bin/") + } finally { + endGroup() + } + } +} diff --git a/src/main.ts b/src/main.ts index cffd2a63..c64396a6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,7 @@ import * as core from "@actions/core" import { setupCmake } from "./cmake/cmake" import { setupConan } from "./conan/conan" +import { setupGcovr } from "./gcovr/gcovr" import { setupLLVM } from "./llvm/llvm" import { setupMeson } from "./meson/meson" import { setupNinja } from "./ninja/ninja" @@ -40,6 +41,12 @@ export async function main(): Promise { await setupMeson(mesonVersion) } + // setup gcovr + const gcovrVersion = maybeGetInput("gcovr") + if (gcovrVersion !== undefined) { + await setupGcovr(gcovrVersion) + } + // setup llvm const llvmVersion = maybeGetInput("llvm") if (llvmVersion !== undefined) {