feat: add ccache

This commit is contained in:
Amin Yahyaabadi 2021-09-16 03:41:47 -05:00
parent a614cdbf27
commit 10883e7f0e
5 changed files with 46 additions and 0 deletions

View File

@ -22,6 +22,8 @@ The package will be usable from any environment (locally, GitHub Actions, etc).
- [x] setup python - [x] setup python
- [x] setup msvc - [x] setup msvc
- [x] setup cppcheck - [x] setup cppcheck
- [x] setup doxygen
- [x] setup ccache
- [ ] setup gcc/mingw - [ ] setup gcc/mingw
- [ ] setup OpenCppCoverage - [ ] setup OpenCppCoverage
- [ ] setup doxygen - [ ] setup doxygen

View File

@ -33,6 +33,9 @@ inputs:
description: "The pyhon version to install." description: "The pyhon version to install."
default: "3.x" default: "3.x"
required: false required: false
ccache:
description: "The ccache version to install."
required: false
runs: runs:
using: "node12" using: "node12"

View File

@ -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)
})
})

20
src/ccache/ccache.ts Normal file
View File

@ -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`)
}
}
}

View File

@ -1,5 +1,6 @@
import * as core from "@actions/core" import * as core from "@actions/core"
import { setupBrew } from "./brew/brew" import { setupBrew } from "./brew/brew"
import { setupCcache } from "./ccache/ccache"
import { setupChocolatey } from "./chocolatey/chocolatey" import { setupChocolatey } from "./chocolatey/chocolatey"
import { setupCmake } from "./cmake/cmake" import { setupCmake } from "./cmake/cmake"
import { setupConan } from "./conan/conan" import { setupConan } from "./conan/conan"
@ -76,6 +77,12 @@ export async function main(): Promise<number> {
await setupBrew() await setupBrew()
} }
// setup ccache
const ccacheVersion = maybeGetInput("ccache")
if (ccacheVersion !== undefined) {
await setupCcache(ccacheVersion)
}
// setup msvc // setup msvc
const msvcVersion = maybeGetInput("msvc") const msvcVersion = maybeGetInput("msvc")
if (msvcVersion !== undefined) { if (msvcVersion !== undefined) {