diff --git a/README.md b/README.md index 327be75a..0d22b180 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ The package will be usable from any environment (locally, GitHub Actions, etc). - [x] setup python - [x] setup msvc - [x] setup cppcheck +- [x] setup doxygen +- [x] setup ccache - [ ] setup gcc/mingw - [ ] setup OpenCppCoverage - [ ] setup doxygen diff --git a/action.yml b/action.yml index 8faf67b1..22ddc3d0 100644 --- a/action.yml +++ b/action.yml @@ -33,6 +33,9 @@ inputs: description: "The pyhon version to install." default: "3.x" required: false + ccache: + description: "The ccache version to install." + required: false runs: using: "node12" diff --git a/src/ccache/__tests__/ccache.test.ts b/src/ccache/__tests__/ccache.test.ts new file mode 100644 index 00000000..315a2c80 --- /dev/null +++ b/src/ccache/__tests__/ccache.test.ts @@ -0,0 +1,14 @@ +import { setupCcache } from "../ccache" +import { spawnSync as spawn } from "child_process" + +jest.setTimeout(200000) +describe("setup-ccache", () => { + it("should setup ccache", async () => { + await setupCcache() + + const { status } = spawn("ccache", ["--version"], { + encoding: "utf8", + }) + expect(status).toBe(0) + }) +}) diff --git a/src/ccache/ccache.ts b/src/ccache/ccache.ts new file mode 100644 index 00000000..171151c9 --- /dev/null +++ b/src/ccache/ccache.ts @@ -0,0 +1,20 @@ +import { setupAptPack } from "../utils/setup/setupAptPack" +import { setupBrewPack } from "../utils/setup/setupBrewPack" +import { setupChocoPack } from "../utils/setup/setupChocoPack" + +export function setupCcache(version?: string) { + switch (process.platform) { + case "win32": { + return setupChocoPack("ccache", version) + } + case "darwin": { + return setupBrewPack("ccache", version) + } + case "linux": { + return setupAptPack("ccache", version) + } + default: { + throw new Error(`Unsupported platform`) + } + } +} diff --git a/src/main.ts b/src/main.ts index a354270b..5a7de6d5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,6 @@ import * as core from "@actions/core" import { setupBrew } from "./brew/brew" +import { setupCcache } from "./ccache/ccache" import { setupChocolatey } from "./chocolatey/chocolatey" import { setupCmake } from "./cmake/cmake" import { setupConan } from "./conan/conan" @@ -76,6 +77,12 @@ export async function main(): Promise { await setupBrew() } + // setup ccache + const ccacheVersion = maybeGetInput("ccache") + if (ccacheVersion !== undefined) { + await setupCcache(ccacheVersion) + } + // setup msvc const msvcVersion = maybeGetInput("msvc") if (msvcVersion !== undefined) {