mirror of https://github.com/aminya/setup-cpp
fix: fix github-actions detection
Use the types from https://github.com/npm/ci-detect/pull/31
This commit is contained in:
parent
f8515dfc8b
commit
3d08c16e03
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -55,7 +55,7 @@
|
|||
"@actions/exec": "^1.1.1",
|
||||
"@actions/io": "^1.1.2",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"@npmcli/ci-detect": "^2.0.0",
|
||||
"@npmcli/ci-detect": "github:aminya/ci-detect#37fe40075bebec96794ba0a7c4a6d5c70cbea00d",
|
||||
"escape-path-with-spaces": "^1.0.0",
|
||||
"exec-powershell": "workspace:*",
|
||||
"execa": "^5.1.1",
|
||||
|
|
|
@ -16,7 +16,7 @@ importers:
|
|||
'@actions/exec': ^1.1.1
|
||||
'@actions/io': ^1.1.2
|
||||
'@actions/tool-cache': ^2.0.1
|
||||
'@npmcli/ci-detect': ^2.0.0
|
||||
'@npmcli/ci-detect': github:aminya/ci-detect#37fe40075bebec96794ba0a7c4a6d5c70cbea00d
|
||||
'@types/cross-spawn': ^6.0.2
|
||||
'@types/jest': ^28.1.6
|
||||
'@types/mri': ^1.1.1
|
||||
|
@ -62,7 +62,7 @@ importers:
|
|||
'@actions/exec': 1.1.1
|
||||
'@actions/io': 1.1.2
|
||||
'@actions/tool-cache': 2.0.1
|
||||
'@npmcli/ci-detect': 2.0.0
|
||||
'@npmcli/ci-detect': github.com/aminya/ci-detect/37fe40075bebec96794ba0a7c4a6d5c70cbea00d
|
||||
escape-path-with-spaces: 1.0.0
|
||||
exec-powershell: link:packages/exec-powershell
|
||||
execa: 5.1.1
|
||||
|
@ -1380,11 +1380,6 @@ packages:
|
|||
fastq: 1.13.0
|
||||
dev: true
|
||||
|
||||
/@npmcli/ci-detect/2.0.0:
|
||||
resolution: {integrity: sha512-8yQtQ9ArHh/TzdUDKQwEvwCgpDuhSWTDAbiKMl3854PcT+Dk4UmWaiawuFTLy9n5twzXOBXVflWe+90/ffXQrA==}
|
||||
engines: {node: ^12.13.0 || ^14.15.0 || >=16}
|
||||
dev: false
|
||||
|
||||
/@npmcli/fs/2.1.1:
|
||||
resolution: {integrity: sha512-1Q0uzx6c/NVNGszePbr5Gc2riSU1zLpNlo/1YWntH+eaPmMgBssAW0qXofCVkpdj3ce4swZtlDYQu+NKiYcptg==}
|
||||
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
|
||||
|
@ -9409,6 +9404,13 @@ packages:
|
|||
- encoding
|
||||
dev: false
|
||||
|
||||
github.com/aminya/ci-detect/37fe40075bebec96794ba0a7c4a6d5c70cbea00d:
|
||||
resolution: {tarball: https://codeload.github.com/aminya/ci-detect/tar.gz/37fe40075bebec96794ba0a7c4a6d5c70cbea00d}
|
||||
name: '@npmcli/ci-detect'
|
||||
version: 2.0.0
|
||||
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
|
||||
dev: false
|
||||
|
||||
github.com/aminya/msvc-dev-cmd/9f672c1:
|
||||
resolution: {tarball: https://codeload.github.com/aminya/msvc-dev-cmd/tar.gz/9f672c1}
|
||||
name: msvc-dev-cmd
|
||||
|
|
|
@ -19,7 +19,7 @@ describe("setup-cmake", () => {
|
|||
it("should find CMake in the cache", async () => {
|
||||
const { binDir } = await setupCmake(getVersion("cmake", "true"), directory, process.arch)
|
||||
await testBin("cmake", ["--version"], binDir)
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
||||
}
|
||||
})
|
||||
|
|
|
@ -186,7 +186,7 @@ async function activateGcc(version: string, binDir: string) {
|
|||
|
||||
promises.push(setupMacOSSDK())
|
||||
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
addGccLoggingMatcher()
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ describe("setup-Kcov", () => {
|
|||
|
||||
// it("should find Kcov in the cache", async () => {
|
||||
// const binDir = await testKcov("v39", directory)
|
||||
// if (ciDetect() === "github") {
|
||||
// if (ciDetect() === "github-actions") {
|
||||
// expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
||||
// }
|
||||
// await cleanupTmpDir("kcov-v39")
|
||||
|
|
|
@ -101,7 +101,7 @@ describe("setup-llvm", () => {
|
|||
const { binDir } = await setupLLVM(getVersion("llvm", "true", osVersion), directory, process.arch)
|
||||
await testBin("clang++", ["--version"], binDir)
|
||||
|
||||
if (ciDetect() === "github" && process.platform !== "linux") {
|
||||
if (ciDetect() === "github-actions" && process.platform !== "linux") {
|
||||
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
||||
// TODO returns the install dir on linux
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ describe("setup-llvm", () => {
|
|||
expect(process.env.CC?.includes("clang")).toBeTruthy()
|
||||
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
|
||||
|
||||
if (ciDetect() === "github" && process.platform !== "linux") {
|
||||
if (ciDetect() === "github-actions" && process.platform !== "linux") {
|
||||
expect(process.env.CC).toMatch("hostedtoolcache")
|
||||
expect(process.env.CXX).toMatch("hostedtoolcache")
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ export async function activateLLVM(directory: string, versionGiven: string) {
|
|||
updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
|
||||
}
|
||||
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
addLLVMLoggingMatcher()
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ export async function activateLLVM(directory: string, versionGiven: string) {
|
|||
|
||||
/** Setup llvm tools (clang tidy, clang format, etc) without activating llvm and using it as the compiler */
|
||||
export function setupClangTools(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
addLLVMLoggingMatcher()
|
||||
}
|
||||
return _setupLLVM(version, setupDir, arch)
|
||||
|
|
|
@ -113,7 +113,7 @@ const inputs: Array<Inputs> = ["compiler", "architecture", ...tools]
|
|||
|
||||
/** The main entry function */
|
||||
export async function main(args: string[]): Promise<number> {
|
||||
if (ciDetect() !== "github") {
|
||||
if (ciDetect() !== "github-actions") {
|
||||
process.env.ACTIONS_ALLOW_UNSECURE_COMMANDS = "true"
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ export async function main(args: string[]): Promise<number> {
|
|||
|
||||
info("setup_cpp finished")
|
||||
|
||||
if (ciDetect() !== "github") {
|
||||
if (ciDetect() !== "github-actions") {
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
warning("Run `RefreshEnv.cmd` or restart your shell to update the environment.")
|
||||
|
|
|
@ -65,7 +65,7 @@ export async function setupMSVC(
|
|||
// run vcvarsall.bat environment variables
|
||||
await setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
||||
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
addMSVCLoggingMatcher()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ describe("setup-ninja", () => {
|
|||
|
||||
it("should find Ninja in the cache", async () => {
|
||||
const binDir = await testNinja(directory)
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
||||
}
|
||||
})
|
||||
|
|
|
@ -13,7 +13,7 @@ describe("setup-python", () => {
|
|||
})
|
||||
|
||||
it("should setup python in GitHub Actions", async () => {
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
info("Installing python in GitHub Actions")
|
||||
const { setupActionsPython } = await import("../actions_python")
|
||||
await setupActionsPython(getVersion("python", "true", await ubuntuVersion()), directory, process.arch)
|
||||
|
|
|
@ -72,7 +72,7 @@ export async function setupActionsPython(version: string, _setupDir: string, arc
|
|||
}
|
||||
}
|
||||
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
addPythonLoggingMatcher()
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
|||
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||
|
||||
export async function setupPython(version: string, setupDir: string, arch: string) {
|
||||
if (ciDetect() !== "github") {
|
||||
if (ciDetect() !== "github-actions") {
|
||||
// TODO parse version
|
||||
return setupPythonViaSystem(version, setupDir, arch)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ describe("setup-task", () => {
|
|||
|
||||
it("should find task in the cache", async () => {
|
||||
const { binDir } = await setupTask(getVersion("task", "true"), directory, process.arch)
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
declare module "@npmcli/ci-detect" {
|
||||
/**
|
||||
* Returns one of the following strings, or `false` if none match, by looking at the appropriate environment variables.
|
||||
*
|
||||
* - `'gerrit'` Gerrit
|
||||
* - `'gitlab'` GitLab
|
||||
* - `'circleci'` Circle-CI
|
||||
* - `'semaphore'` Semaphore
|
||||
* - `'drone'` Drone
|
||||
* - `'github-actions'` GitHub Actions
|
||||
* - `'tddium'` TDDium
|
||||
* - `'jenkins'` Jenkins
|
||||
* - `'bamboo'` Bamboo
|
||||
* - `'gocd'` GoCD
|
||||
* - `'wercker'` Oracle Wercker
|
||||
* - `'netlify'` Netlify
|
||||
* - `'now-github'` Zeit.co's Now for GitHub deployment service
|
||||
* - `'now-bitbucket'` Zeit.co's Now for BitBucket deployment service
|
||||
* - `'now-gitlab'` Zeit.co's Now for GitLab deployment service
|
||||
* - `'now'` Zeit.co's Now service, but not GitHub/BitBucket/GitLab
|
||||
* - `'azure-pipelines'` Azure Pipelines
|
||||
* - `'bitbucket-pipelines'` Bitbucket Pipelines
|
||||
* - `'bitrise'` Bitrise
|
||||
* - `'buddy'` Buddy
|
||||
* - `'buildkite'` Buildkite
|
||||
* - `'cirrus'` Cirrus CI
|
||||
* - `'dsari'` dsari CI
|
||||
* - `'screwdriver'` Screwdriver CI
|
||||
* - `'strider'` Strider CI
|
||||
* - `'taskcluster'` Mozilla Taskcluster
|
||||
* - `'hudson'` Hudson CI
|
||||
* - `'magnum'` Magnum CI
|
||||
* - `'nevercode'` Nevercode
|
||||
* - `'render'` Render CI
|
||||
* - `'sail'` Sail CI
|
||||
* - `'shippable'` Shippable
|
||||
* - `'heroku'` Heroku
|
||||
* - `'codeship'` CodeShip
|
||||
* - `'teamcity'` TeamCity
|
||||
* - `'vercel'` Vercel
|
||||
* - `'vercel-github'` Vercel GitHub
|
||||
* - `'vercel-gitlab'` Vercel Gitlab
|
||||
* - `'vercel-bitbucket'` Vercel Bitbucket
|
||||
* - Anything that sets the `CI_NAME` environment variable will return the value as the result. (This is how CodeShip is
|
||||
* detected.)
|
||||
* - `'travis-ci'` Travis-CI - A few other CI systems set `TRAVIS=1` in the environment, because devs use that to
|
||||
* indicate "test mode", so this one can get some false positives, and is tested later in the process to minimize
|
||||
* this effect.
|
||||
* - `'aws-codebuild'` AWS CodeBuild
|
||||
* - `'builder'` Google Cloud Builder - This one is a bit weird. It doesn't really set anything that can be reliably
|
||||
* detected except `BUILDER_OUTPUT`, so it can get false positives pretty easily.
|
||||
* - `'custom'` anything else that sets `CI` environment variable to either `'1'` or `'true'`.
|
||||
*/
|
||||
function ciDetect(): string | boolean
|
||||
export = ciDetect
|
||||
}
|
|
@ -15,7 +15,7 @@ import { escapeSpace } from "../path/escape_space"
|
|||
export async function addEnv(name: string, valGiven: string | undefined, shouldEscapeSpace: boolean = false) {
|
||||
const val = shouldEscapeSpace ? escapeSpace(valGiven) : valGiven
|
||||
try {
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
try {
|
||||
exportVariable(name, val)
|
||||
} catch (err) {
|
||||
|
@ -39,7 +39,7 @@ export async function addEnv(name: string, valGiven: string | undefined, shouldE
|
|||
export async function addPath(path: string) {
|
||||
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
|
||||
try {
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
try {
|
||||
ghAddPath(path)
|
||||
} catch (err) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as core from "@actions/core"
|
|||
import ciDetect from "@npmcli/ci-detect"
|
||||
|
||||
export function error(err: string | Error) {
|
||||
return ciDetect() === "github" ? core.error(err) : console.log(`\x1b[31m${err}\x1b[0m`)
|
||||
return ciDetect() === "github-actions" ? core.error(err) : console.log(`\x1b[31m${err}\x1b[0m`)
|
||||
}
|
||||
|
||||
export function success(msg: string) {
|
||||
|
@ -10,13 +10,13 @@ export function success(msg: string) {
|
|||
}
|
||||
|
||||
export function warning(msg: string) {
|
||||
return ciDetect() === "github" ? core.warning(msg) : console.log(`\x1b[33m${msg}\x1b[0m`)
|
||||
return ciDetect() === "github-actions" ? core.warning(msg) : console.log(`\x1b[33m${msg}\x1b[0m`)
|
||||
}
|
||||
|
||||
export function notice(msg: string) {
|
||||
return ciDetect() === "github" ? core.notice(msg) : console.log(`\x1b[94m${msg}\x1b[0m`)
|
||||
return ciDetect() === "github-actions" ? core.notice(msg) : console.log(`\x1b[94m${msg}\x1b[0m`)
|
||||
}
|
||||
|
||||
export function info(msg: string) {
|
||||
return ciDetect() === "github" ? core.info(msg) : console.log(msg)
|
||||
return ciDetect() === "github-actions" ? core.info(msg) : console.log(msg)
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ export async function addAptKeyViaDownload(name: string, url: string) {
|
|||
}
|
||||
|
||||
export function updateAptAlternatives(name: string, path: string) {
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
return execRootSync("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])
|
||||
} else {
|
||||
setupCppInProfile()
|
||||
|
|
|
@ -64,7 +64,7 @@ export async function setupBin(
|
|||
)
|
||||
|
||||
// Restore from cache (if found).
|
||||
if (ciDetect() === "github") {
|
||||
if (ciDetect() === "github-actions") {
|
||||
try {
|
||||
const dir = find(name, version)
|
||||
if (dir) {
|
||||
|
@ -129,7 +129,7 @@ export async function setupBin(
|
|||
await addPath(binDir)
|
||||
|
||||
// check if inside Github Actions. If so, cache the installation
|
||||
if (ciDetect() === "github" && typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
||||
if (ciDetect() === "github-actions" && typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
||||
await cacheDir(setupDir, name, version)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue