mirror of https://github.com/aminya/setup-cpp
fix: use ci-detect instead of isCI
This commit is contained in:
parent
c5a2f11e38
commit
88c2d1ac03
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,6 +55,7 @@
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/io": "^1.1.2",
|
"@actions/io": "^1.1.2",
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"@actions/tool-cache": "^2.0.1",
|
||||||
|
"@npmcli/ci-detect": "^2.0.0",
|
||||||
"escape-path-with-spaces": "^1.0.0",
|
"escape-path-with-spaces": "^1.0.0",
|
||||||
"exec-powershell": "workspace:*",
|
"exec-powershell": "workspace:*",
|
||||||
"execa": "^5.1.1",
|
"execa": "^5.1.1",
|
||||||
|
|
|
@ -16,6 +16,7 @@ importers:
|
||||||
'@actions/exec': ^1.1.1
|
'@actions/exec': ^1.1.1
|
||||||
'@actions/io': ^1.1.2
|
'@actions/io': ^1.1.2
|
||||||
'@actions/tool-cache': ^2.0.1
|
'@actions/tool-cache': ^2.0.1
|
||||||
|
'@npmcli/ci-detect': ^2.0.0
|
||||||
'@types/cross-spawn': ^6.0.2
|
'@types/cross-spawn': ^6.0.2
|
||||||
'@types/jest': ^28.1.6
|
'@types/jest': ^28.1.6
|
||||||
'@types/mri': ^1.1.1
|
'@types/mri': ^1.1.1
|
||||||
|
@ -61,6 +62,7 @@ importers:
|
||||||
'@actions/exec': 1.1.1
|
'@actions/exec': 1.1.1
|
||||||
'@actions/io': 1.1.2
|
'@actions/io': 1.1.2
|
||||||
'@actions/tool-cache': 2.0.1
|
'@actions/tool-cache': 2.0.1
|
||||||
|
'@npmcli/ci-detect': 2.0.0
|
||||||
escape-path-with-spaces: 1.0.0
|
escape-path-with-spaces: 1.0.0
|
||||||
exec-powershell: link:packages/exec-powershell
|
exec-powershell: link:packages/exec-powershell
|
||||||
execa: 5.1.1
|
execa: 5.1.1
|
||||||
|
@ -1378,6 +1380,11 @@ packages:
|
||||||
fastq: 1.13.0
|
fastq: 1.13.0
|
||||||
dev: true
|
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:
|
/@npmcli/fs/2.1.1:
|
||||||
resolution: {integrity: sha512-1Q0uzx6c/NVNGszePbr5Gc2riSU1zLpNlo/1YWntH+eaPmMgBssAW0qXofCVkpdj3ce4swZtlDYQu+NKiYcptg==}
|
resolution: {integrity: sha512-1Q0uzx6c/NVNGszePbr5Gc2riSU1zLpNlo/1YWntH+eaPmMgBssAW0qXofCVkpdj3ce4swZtlDYQu+NKiYcptg==}
|
||||||
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
|
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { setupCmake } from "../cmake"
|
import { setupCmake } from "../cmake"
|
||||||
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||||
import { isGitHubCI } from "../../utils/env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { getVersion } from "../../default_versions"
|
import { getVersion } from "../../default_versions"
|
||||||
|
|
||||||
jest.setTimeout(300000)
|
jest.setTimeout(300000)
|
||||||
|
@ -19,7 +19,7 @@ describe("setup-cmake", () => {
|
||||||
it("should find CMake in the cache", async () => {
|
it("should find CMake in the cache", async () => {
|
||||||
const { binDir } = await setupCmake(getVersion("cmake", "true"), directory, process.arch)
|
const { binDir } = await setupCmake(getVersion("cmake", "true"), directory, process.arch)
|
||||||
await testBin("cmake", ["--version"], binDir)
|
await testBin("cmake", ["--version"], binDir)
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -9,7 +9,7 @@ import semverCoerce from "semver/functions/coerce"
|
||||||
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
|
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { warning, info } from "../utils/io/io"
|
import { warning, info } from "../utils/io/io"
|
||||||
import { isGitHubCI } from "../utils/env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { addBinExtension } from "extension-tools"
|
import { addBinExtension } from "extension-tools"
|
||||||
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
|
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
|
||||||
import { extract7Zip } from "../utils/setup/extract"
|
import { extract7Zip } from "../utils/setup/extract"
|
||||||
|
@ -186,7 +186,7 @@ async function activateGcc(version: string, binDir: string) {
|
||||||
|
|
||||||
promises.push(setupMacOSSDK())
|
promises.push(setupMacOSSDK())
|
||||||
|
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
addGccLoggingMatcher()
|
addGccLoggingMatcher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ describe("setup-Kcov", () => {
|
||||||
|
|
||||||
// it("should find Kcov in the cache", async () => {
|
// it("should find Kcov in the cache", async () => {
|
||||||
// const binDir = await testKcov("v39", directory)
|
// const binDir = await testKcov("v39", directory)
|
||||||
// if (isGitHubCI()) {
|
// if (ciDetect() === "github") {
|
||||||
// expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
// expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
||||||
// }
|
// }
|
||||||
// await cleanupTmpDir("kcov-v39")
|
// await cleanupTmpDir("kcov-v39")
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { setupLLVM, VERSIONS, getUrl, setupClangTools, getLinuxUrl } from "../ll
|
||||||
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
|
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
|
||||||
import { isValidUrl } from "../../utils/http/validate_url"
|
import { isValidUrl } from "../../utils/http/validate_url"
|
||||||
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||||
import { isGitHubCI } from "../../utils/env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import execa from "execa"
|
import execa from "execa"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { addBinExtension } from "extension-tools"
|
import { addBinExtension } from "extension-tools"
|
||||||
|
@ -101,7 +101,7 @@ describe("setup-llvm", () => {
|
||||||
const { binDir } = await setupLLVM(getVersion("llvm", "true", osVersion), directory, process.arch)
|
const { binDir } = await setupLLVM(getVersion("llvm", "true", osVersion), directory, process.arch)
|
||||||
await testBin("clang++", ["--version"], binDir)
|
await testBin("clang++", ["--version"], binDir)
|
||||||
|
|
||||||
if (isGitHubCI() && process.platform !== "linux") {
|
if (ciDetect() === "github" && process.platform !== "linux") {
|
||||||
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
||||||
// TODO returns the install dir on linux
|
// TODO returns the install dir on linux
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ describe("setup-llvm", () => {
|
||||||
expect(process.env.CC?.includes("clang")).toBeTruthy()
|
expect(process.env.CC?.includes("clang")).toBeTruthy()
|
||||||
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
|
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
|
||||||
|
|
||||||
if (isGitHubCI() && process.platform !== "linux") {
|
if (ciDetect() === "github" && process.platform !== "linux") {
|
||||||
expect(process.env.CC).toMatch("hostedtoolcache")
|
expect(process.env.CC).toMatch("hostedtoolcache")
|
||||||
expect(process.env.CXX).toMatch("hostedtoolcache")
|
expect(process.env.CXX).toMatch("hostedtoolcache")
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { setOutput } from "@actions/core"
|
||||||
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
|
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
|
||||||
import { info, warning } from "../utils/io/io"
|
import { info, warning } from "../utils/io/io"
|
||||||
import { existsSync } from "fs"
|
import { existsSync } from "fs"
|
||||||
import { isGitHubCI } from "../utils/env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { setupGcc } from "../gcc/gcc"
|
import { setupGcc } from "../gcc/gcc"
|
||||||
import { getVersion } from "../default_versions"
|
import { getVersion } from "../default_versions"
|
||||||
import { isArch } from "../utils/env/isArch"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
@ -353,7 +353,7 @@ export async function activateLLVM(directory: string, versionGiven: string) {
|
||||||
updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
|
updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
addLLVMLoggingMatcher()
|
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 */
|
/** 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> {
|
export function setupClangTools(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
addLLVMLoggingMatcher()
|
addLLVMLoggingMatcher()
|
||||||
}
|
}
|
||||||
return _setupLLVM(version, setupDir, arch)
|
return _setupLLVM(version, setupDir, arch)
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { setupOpencppcoverage } from "./opencppcoverage/opencppcoverage"
|
||||||
import { setupPython } from "./python/python"
|
import { setupPython } from "./python/python"
|
||||||
import mri from "mri"
|
import mri from "mri"
|
||||||
import { untildify_user as untildify } from "./utils/path/untildify"
|
import { untildify_user as untildify } from "./utils/path/untildify"
|
||||||
import { isGitHubCI } from "./utils/env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import * as timeDelta from "time-delta"
|
import * as timeDelta from "time-delta"
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -113,7 +113,7 @@ const inputs: Array<Inputs> = ["compiler", "architecture", ...tools]
|
||||||
|
|
||||||
/** The main entry function */
|
/** The main entry function */
|
||||||
export async function main(args: string[]): Promise<number> {
|
export async function main(args: string[]): Promise<number> {
|
||||||
if (!isGitHubCI()) {
|
if (ciDetect() !== "github") {
|
||||||
process.env.ACTIONS_ALLOW_UNSECURE_COMMANDS = "true"
|
process.env.ACTIONS_ALLOW_UNSECURE_COMMANDS = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ export async function main(args: string[]): Promise<number> {
|
||||||
|
|
||||||
info("setup_cpp finished")
|
info("setup_cpp finished")
|
||||||
|
|
||||||
if (!isGitHubCI()) {
|
if (ciDetect() !== "github") {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
warning("Run `RefreshEnv.cmd` or restart your shell to update the environment.")
|
warning("Run `RefreshEnv.cmd` or restart your shell to update the environment.")
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { setupVCVarsall } from "../vcvarsall/vcvarsall"
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { vsversion_to_versionnumber, findVcvarsall } from "msvc-dev-cmd/lib.js"
|
import { vsversion_to_versionnumber, findVcvarsall } from "msvc-dev-cmd/lib.js"
|
||||||
import { isGitHubCI } from "../utils/env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { existsSync } from "fs"
|
import { existsSync } from "fs"
|
||||||
import { error, info, warning } from "../utils/io/io"
|
import { error, info, warning } from "../utils/io/io"
|
||||||
|
@ -65,7 +65,7 @@ export async function setupMSVC(
|
||||||
// run vcvarsall.bat environment variables
|
// run vcvarsall.bat environment variables
|
||||||
await setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
await setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
||||||
|
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
addMSVCLoggingMatcher()
|
addMSVCLoggingMatcher()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { setupNinja } from "../ninja"
|
import { setupNinja } from "../ninja"
|
||||||
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||||
import { isGitHubCI } from "../../utils/env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { getVersion } from "../../default_versions"
|
import { getVersion } from "../../default_versions"
|
||||||
|
|
||||||
jest.setTimeout(300000)
|
jest.setTimeout(300000)
|
||||||
|
@ -22,7 +22,7 @@ describe("setup-ninja", () => {
|
||||||
|
|
||||||
it("should find Ninja in the cache", async () => {
|
it("should find Ninja in the cache", async () => {
|
||||||
const binDir = await testNinja(directory)
|
const binDir = await testNinja(directory)
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { setupPython } from "../python"
|
||||||
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||||
import { getVersion } from "../../default_versions"
|
import { getVersion } from "../../default_versions"
|
||||||
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
|
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
|
||||||
import { isGitHubCI } from "../../utils/env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { info } from "../../utils/io/io"
|
import { info } from "../../utils/io/io"
|
||||||
|
|
||||||
jest.setTimeout(300000)
|
jest.setTimeout(300000)
|
||||||
|
@ -13,7 +13,7 @@ describe("setup-python", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should setup python in GitHub Actions", async () => {
|
it("should setup python in GitHub Actions", async () => {
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
info("Installing python in GitHub Actions")
|
info("Installing python in GitHub Actions")
|
||||||
const { setupActionsPython } = await import("../actions_python")
|
const { setupActionsPython } = await import("../actions_python")
|
||||||
await setupActionsPython(getVersion("python", "true", await ubuntuVersion()), directory, process.arch)
|
await setupActionsPython(getVersion("python", "true", await ubuntuVersion()), directory, process.arch)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { existsSync } from "fs"
|
||||||
import { info, warning } from "../utils/io/io"
|
import { info, warning } from "../utils/io/io"
|
||||||
import { debug } from "@actions/core"
|
import { debug } from "@actions/core"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { isGitHubCI } from "../utils/env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS } from "setup-python/src/utils"
|
import { isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS } from "setup-python/src/utils"
|
||||||
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
|
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ export async function setupActionsPython(version: string, _setupDir: string, arc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
addPythonLoggingMatcher()
|
addPythonLoggingMatcher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||||
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
|
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
|
||||||
import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
||||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import { isGitHubCI } from "../utils/env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { warning, info } from "../utils/io/io"
|
import { warning, info } from "../utils/io/io"
|
||||||
import { isArch } from "../utils/env/isArch"
|
import { isArch } from "../utils/env/isArch"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
|
@ -14,7 +14,7 @@ import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
||||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||||
|
|
||||||
export async function setupPython(version: string, setupDir: string, arch: string) {
|
export async function setupPython(version: string, setupDir: string, arch: string) {
|
||||||
if (!isGitHubCI()) {
|
if (ciDetect() !== "github") {
|
||||||
// TODO parse version
|
// TODO parse version
|
||||||
return setupPythonViaSystem(version, setupDir, arch)
|
return setupPythonViaSystem(version, setupDir, arch)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { setupTask } from "../task"
|
import { setupTask } from "../task"
|
||||||
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||||
import { isGitHubCI } from "../../utils/env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { getVersion } from "../../default_versions"
|
import { getVersion } from "../../default_versions"
|
||||||
|
|
||||||
jest.setTimeout(300000)
|
jest.setTimeout(300000)
|
||||||
|
@ -18,7 +18,7 @@ describe("setup-task", () => {
|
||||||
|
|
||||||
it("should find task in the cache", async () => {
|
it("should find task in the cache", async () => {
|
||||||
const { binDir } = await setupTask(getVersion("task", "true"), directory, process.arch)
|
const { binDir } = await setupTask(getVersion("task", "true"), directory, process.arch)
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
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
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import { exportVariable, addPath as ghAddPath, info, setFailed } from "@actions/core"
|
import { exportVariable, addPath as ghAddPath, info, setFailed } from "@actions/core"
|
||||||
import { isGitHubCI } from "./isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { untildify_user as untildify } from "../path/untildify"
|
import { untildify_user as untildify } from "../path/untildify"
|
||||||
import { appendFileSync, existsSync, readFileSync } from "fs"
|
import { appendFileSync, existsSync, readFileSync } from "fs"
|
||||||
import { error, warning } from "../io/io"
|
import { error, warning } from "../io/io"
|
||||||
|
@ -15,7 +15,7 @@ import { escapeSpace } from "../path/escape_space"
|
||||||
export async function addEnv(name: string, valGiven: string | undefined, shouldEscapeSpace: boolean = false) {
|
export async function addEnv(name: string, valGiven: string | undefined, shouldEscapeSpace: boolean = false) {
|
||||||
const val = shouldEscapeSpace ? escapeSpace(valGiven) : valGiven
|
const val = shouldEscapeSpace ? escapeSpace(valGiven) : valGiven
|
||||||
try {
|
try {
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
try {
|
try {
|
||||||
exportVariable(name, val)
|
exportVariable(name, val)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -39,7 +39,7 @@ export async function addEnv(name: string, valGiven: string | undefined, shouldE
|
||||||
export async function addPath(path: string) {
|
export async function addPath(path: string) {
|
||||||
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
|
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
|
||||||
try {
|
try {
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
try {
|
try {
|
||||||
ghAddPath(path)
|
ghAddPath(path)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
export function isCI() {
|
|
||||||
return process.env.CI === "true"
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isGitHubCI() {
|
|
||||||
return isCI() && process.env.GITHUB_ACTIONS === "true"
|
|
||||||
}
|
|
|
@ -1,8 +1,8 @@
|
||||||
import * as core from "@actions/core"
|
import * as core from "@actions/core"
|
||||||
import { isGitHubCI } from "../env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
|
|
||||||
export function error(err: string | Error) {
|
export function error(err: string | Error) {
|
||||||
return isGitHubCI() ? core.error(err) : console.log(`\x1b[31m${err}\x1b[0m`)
|
return ciDetect() === "github" ? core.error(err) : console.log(`\x1b[31m${err}\x1b[0m`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function success(msg: string) {
|
export function success(msg: string) {
|
||||||
|
@ -10,13 +10,13 @@ export function success(msg: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function warning(msg: string) {
|
export function warning(msg: string) {
|
||||||
return isGitHubCI() ? core.warning(msg) : console.log(`\x1b[33m${msg}\x1b[0m`)
|
return ciDetect() === "github" ? core.warning(msg) : console.log(`\x1b[33m${msg}\x1b[0m`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function notice(msg: string) {
|
export function notice(msg: string) {
|
||||||
return isGitHubCI() ? core.notice(msg) : console.log(`\x1b[94m${msg}\x1b[0m`)
|
return ciDetect() === "github" ? core.notice(msg) : console.log(`\x1b[94m${msg}\x1b[0m`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function info(msg: string) {
|
export function info(msg: string) {
|
||||||
return isGitHubCI() ? core.info(msg) : console.log(msg)
|
return ciDetect() === "github" ? core.info(msg) : console.log(msg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import { InstallationInfo } from "./setupBin"
|
import { InstallationInfo } from "./setupBin"
|
||||||
import { execRootSync } from "root-tools"
|
import { execRootSync } from "root-tools"
|
||||||
import { info } from "@actions/core"
|
import { info } from "@actions/core"
|
||||||
import { isGitHubCI } from "../env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
|
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
|
||||||
import { appendFileSync, existsSync } from "fs"
|
import { appendFileSync, existsSync } from "fs"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
|
@ -124,7 +124,7 @@ export async function addAptKeyViaDownload(name: string, url: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateAptAlternatives(name: string, path: string) {
|
export function updateAptAlternatives(name: string, path: string) {
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
return execRootSync("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])
|
return execRootSync("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])
|
||||||
} else {
|
} else {
|
||||||
setupCppInProfile()
|
setupCppInProfile()
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { addPath } from "../env/addEnv"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
import { existsSync } from "fs"
|
import { existsSync } from "fs"
|
||||||
import { tmpdir } from "os"
|
import { tmpdir } from "os"
|
||||||
import { isGitHubCI } from "../env/isCI"
|
import ciDetect from "@npmcli/ci-detect"
|
||||||
import { setupAptPack } from "./setupAptPack"
|
import { setupAptPack } from "./setupAptPack"
|
||||||
import { setupPacmanPack } from "./setupPacmanPack"
|
import { setupPacmanPack } from "./setupPacmanPack"
|
||||||
import { isArch } from "../env/isArch"
|
import { isArch } from "../env/isArch"
|
||||||
|
@ -64,7 +64,7 @@ export async function setupBin(
|
||||||
)
|
)
|
||||||
|
|
||||||
// Restore from cache (if found).
|
// Restore from cache (if found).
|
||||||
if (isGitHubCI()) {
|
if (ciDetect() === "github") {
|
||||||
try {
|
try {
|
||||||
const dir = find(name, version)
|
const dir = find(name, version)
|
||||||
if (dir) {
|
if (dir) {
|
||||||
|
@ -129,7 +129,7 @@ export async function setupBin(
|
||||||
await addPath(binDir)
|
await addPath(binDir)
|
||||||
|
|
||||||
// check if inside Github Actions. If so, cache the installation
|
// check if inside Github Actions. If so, cache the installation
|
||||||
if (isGitHubCI() && typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
if (ciDetect() === "github" && typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
||||||
await cacheDir(setupDir, name, version)
|
await cacheDir(setupDir, name, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue