feat: add conan installation

This commit is contained in:
Amin Yahyaabadi 2021-09-14 12:06:20 -05:00
parent 4927f3a272
commit 0c07dec72e
6 changed files with 53 additions and 2 deletions

View File

@ -16,9 +16,9 @@ The package will be usable from any environment (locally, GitHub Actions, etc).
- [x] setup cmake - [x] setup cmake
- [x] setup ninja - [x] setup ninja
- [x] setup llvm - [x] setup llvm
- [x] setup conan
- [ ] setup gcc/mingw - [ ] setup gcc/mingw
- [ ] setup msvc - [ ] setup msvc
- [ ] setup conan
- [ ] setup meson - [ ] setup meson
- [ ] setup vcpkg - [ ] setup vcpkg
- [ ] setup gcovr - [ ] setup gcovr

View File

@ -16,7 +16,10 @@ inputs:
ninja: ninja:
description: "The ninja version to install." description: "The ninja version to install."
default: "1.10.2" default: "1.10.2"
required: true required: false
conan:
description: "The concan version to install."
required: false
runs: runs:
using: "node12" using: "node12"

View File

@ -0,0 +1,15 @@
import { setupConan } from "../conan"
import { spawnSync as spawn } from "child_process"
jest.setTimeout(100000)
describe("setup-conan", () => {
it("should setup conan", async () => {
await setupConan("1.40.1")
const { status } = spawn("conan", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
})
})

15
src/conan/conan.ts Normal file
View File

@ -0,0 +1,15 @@
import { setupPip } from "../utils/setup/setupPip"
import { addPath, startGroup, endGroup } from "@actions/core"
export async function setupConan(version?: string) {
await setupPip("conan", version)
if (process.platform === "linux") {
try {
startGroup(`Add /home/runner/.local/bin to PATH`)
addPath("/home/runner/.local/bin/")
} finally {
endGroup()
}
}
}

View File

@ -1,5 +1,6 @@
import * as core from "@actions/core" import * as core from "@actions/core"
import { setupCmake } from "./cmake/cmake" import { setupCmake } from "./cmake/cmake"
import { setupConan } from "./conan/conan"
import { setupLLVM } from "./llvm/llvm" import { setupLLVM } from "./llvm/llvm"
import { setupNinja } from "./ninja/ninja" import { setupNinja } from "./ninja/ninja"
@ -26,6 +27,12 @@ export async function main(): Promise<number> {
await setupNinja(ninjaVersion, setupCppDir) await setupNinja(ninjaVersion, setupCppDir)
} }
// setup conan
const conanVersion = maybeGetInput("conan")
if (conanVersion !== undefined) {
await setupConan(conanVersion)
}
// setup llvm // setup llvm
const llvmVersion = maybeGetInput("llvm") const llvmVersion = maybeGetInput("llvm")
if (llvmVersion !== undefined) { if (llvmVersion !== undefined) {

View File

@ -0,0 +1,11 @@
import { exec } from "@actions/exec"
/** A function that installs a package using pip */
export async function setupPip(name: string, version?: string) {
// pip3 install conan --upgrade
const exit = await exec("pip", ["install", "--user", version !== undefined ? `${name}==${version}` : name])
if (exit !== 0) {
throw new Error(`Failed to install ${name} ${version}`)
}
}