Merge branch 'master' into fix/update-node

This commit is contained in:
abeimler 2023-04-23 15:42:46 +02:00
commit 4fc7c95a44
50 changed files with 747 additions and 387 deletions

View File

@ -75,6 +75,7 @@ words:
- tsbuildinfo
- ucrt
- untildify
- upleveled
- vbatts
- vcpkg
- vcvarsall

@ -1 +1 @@
Subproject commit b10f2e841835b93cee67dff1eb70d6fa5c0ac0cd
Subproject commit c30589196b2c59a3055dfc7c24244b4a1f48b081

View File

@ -1,5 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
import { node } from "execa"
import { execaNode } from "execa"
function getPlatformName() {
switch (process.platform) {
@ -27,7 +27,7 @@ function main() {
return Promise.all(
exes.map((exe) =>
node("./node_modules/caxa/build/index.mjs", [
execaNode("./node_modules/caxa/build/index.mjs", [
"--input",
"./dist/node16",
"--output",

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

View File

@ -9,9 +9,6 @@
"import": "./dist/node16/setup-cpp.mjs",
"require": "./dist/node16/setup-cpp.js"
},
"main": "./dist/node16/setup-cpp.js",
"main.legacy": "./dist/node12/setup-cpp.js",
"main.actions": "./dist/node18/setup-cpp.js",
"source": "./src/main.ts",
"bin": {
"setup-cpp": "./dist/node16/setup-cpp.js"
@ -33,8 +30,8 @@
"build.docker.arch": "pnpm build && docker build -f ./dev/docker/arch_node.dockerfile -t setup-cpp:arch .",
"build.docker.fedora": "pnpm build && docker build -f ./dev/docker/fedora_node.dockerfile -t setup-cpp:fedora .",
"build.docker.ubuntu": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup-cpp:ubuntu .",
"build.parcel": "cross-env NODE_ENV=production parcel build",
"bump": "ncu -u -x execa,numerous,path-exists && pnpm update",
"build.parcel": "cross-env NODE_ENV=production parcel build && babel ./dist --out-dir dist --plugins @upleveled/babel-plugin-remove-node-prefix --compact --no-babelrc --source-maps true",
"bump": "ncu -u -x numerous && pnpm update",
"clean": "shx rm -rf .parcel-cache dist exe",
"copy.matchers": "run-p copy.matchers.node12 copy.matchers.node16 copy.matchers.node18",
"copy.matchers.node12": "shx cp ./src/gcc/gcc_matcher.json ./dist/node12/ && shx cp ./src/msvc/msvc_matcher.json ./dist/node12/ && shx cp ./src/python/python_matcher.json ./dist/node12/ && shx cp ./src/llvm/llvm_matcher.json ./dist/node12/",
@ -69,18 +66,20 @@
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1",
"@npmcli/ci-detect": "^3.0.2",
"@babel/cli": "^7.21.0",
"@types/cross-spawn": "^6.0.2",
"@types/eslint": "^8.37.0",
"@types/jest": "^29.5.1",
"@types/mri": "^1.1.1",
"@types/node": "^18.15.13",
"@types/node": "^18.16.0",
"@types/npmcli__ci-detect": "^2.0.0",
"@types/prettier": "2.7.2",
"@types/semver": "^7.3.13",
"@types/which": "^3.0.0",
"@upleveled/babel-plugin-remove-node-prefix": "github:aminya/babel-plugin-remove-node-prefix#95fcbd92405b99a6eece48c493548996f12e6519",
"admina": "^0.1.3",
"caxa": "^3.0.1",
"ci-info": "^3.8.0",
"ci-log": "workspace:*",
"cross-env": "7.0.3",
"cross-spawn": "^7.0.3",
@ -88,10 +87,11 @@
"escape-path-with-spaces": "^1.0.2",
"escape-quotes": "^1.0.2",
"escape-string-regexp": "^5.0.0",
"eslint": "^8.38.0",
"eslint": "^8.39.0",
"eslint-config-atomic": "^1.18.3",
"exec-powershell": "workspace:*",
"execa": "^5.1.1",
"execa": "^7.1.1",
"fast-glob": "^3.2.12",
"gen-readme": "^1.6.0",
"is-url-online": "^1.5.0",
"jest": "^29.5.0",
@ -101,14 +101,14 @@
"npm-run-all2": "^6.0.5",
"numerous": "1.0.3",
"parcel": "2.8.3",
"path-exists": "^4.0.0",
"path-exists": "^5.0.0",
"patha": "^0.4.1",
"prettier": "2.7.1",
"prettier": "2.8.8",
"prettier-config-atomic": "^3.1.0",
"quote-unquote": "^1.0.0",
"readme-md-generator": "^1.0.0",
"retry-as-promised": "^7.0.4",
"semver": "7.3.8",
"semver": "7.5.0",
"setup-python": "github:actions/setup-python#v4.6.0",
"shx": "0.3.4",
"terser-config-atomic": "^0.1.1",
@ -148,26 +148,9 @@
"electron": false,
"patha": "patha/dist/index.node.mjs"
},
"pnpm": {
"overrides": {
"semver": "7.3.8",
"eslint": "^8.28.0",
"prettier": "2.7.1",
"lru-cache": "7.8.1",
"core-js": "*",
"babel-eslint": "npm:@babel/eslint-parser",
"got@<11.8.5": ">=11.8.5",
"minimist@<0.2.1": ">=0.2.1",
"http-cache-semantics@<4.1.1": ">=4.1.1",
"minimist@<0.2.4": ">=0.2.4",
"deep-extend@<0.5.1": ">=0.5.1"
},
"peerDependencyRules": {
"allowedVersions": {
"eslint": "*"
}
}
},
"main": "./dist/node16/setup-cpp.js",
"main.legacy": "./dist/node12/setup-cpp.js",
"main.actions": "./dist/node18/setup-cpp.js",
"targets": {
"main.legacy": {
"context": "node",

View File

@ -1,8 +1,8 @@
import * as core from "@actions/core"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
export function error(err: string | Error) {
return ciDetect() === "github-actions" ? core.error(err) : console.log(`\x1b[31m${err}\x1b[0m`)
return 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-actions" ? core.warning(msg) : console.log(`\x1b[33m${msg}\x1b[0m`)
return GITHUB_ACTIONS ? core.warning(msg) : console.log(`\x1b[33m${msg}\x1b[0m`)
}
export function notice(msg: string) {
return ciDetect() === "github-actions" ? core.notice(msg) : console.log(`\x1b[94m${msg}\x1b[0m`)
return GITHUB_ACTIONS ? core.notice(msg) : console.log(`\x1b[94m${msg}\x1b[0m`)
}
export function info(msg: string) {
return ciDetect() === "github-actions" ? core.info(msg) : console.log(msg)
return GITHUB_ACTIONS ? core.info(msg) : console.log(msg)
}

View File

@ -38,7 +38,7 @@ Execute a powershell command.
- command (`string`) - The powershell command to execute
- startupFlags (`string[]`) - The optional startup flags to be passed to powershell. Defaults to `["-NoProfile", "-NoLogo", "-NonInteractive"]`. This means that the Powershell profile is not sourced first.
- execOptions (`execa.SyncOptions`) - The options passed to `execa`. Defaults to `{ stdio: "inherit" }`
- execOptions (`execaSyncOptions`) - The options passed to `execa`. Defaults to `{ stdio: "inherit" }`
**returns:** execa.ExecaSyncReturnValue<string>

View File

@ -11,7 +11,7 @@
"build": "tsc"
},
"dependencies": {
"execa": "^5.1.1",
"execa": "^7.1.1",
"which": "^2.0.2"
},
"devDependencies": {

View File

@ -1,4 +1,4 @@
import execa from "execa"
import * as execa from "execa"
import which from "which"
/** The cached powershell path */
@ -19,7 +19,7 @@ export function execPowershell(
startupFlags: string[] = ["-NoProfile", "-NoLogo", "-NonInteractive"],
execOptions: execa.Options = { stdio: "inherit" }
): execa.ExecaChildProcess<string> {
return execa(getPowerShell(), [...startupFlags, "-c", command], execOptions)
return execa.execa(getPowerShell(), [...startupFlags, "-c", command], execOptions)
}
/**
@ -37,7 +37,7 @@ export function execPowershellSync(
startupFlags: string[] = ["-NoProfile", "-NoLogo", "-NonInteractive"],
execOptions: execa.SyncOptions = { stdio: "inherit" }
): execa.ExecaSyncReturnValue<string> {
return execa.sync(getPowerShell(), [...startupFlags, "-c", command], execOptions)
return execa.execaSync(getPowerShell(), [...startupFlags, "-c", command], execOptions)
}
/**

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
import execa from "execa"
import { execaSync } from "execa"
import { dirname } from "patha"
import which from "which"
import { tmpdir } from "os"
@ -28,7 +28,7 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
const brewTempDirectory = path.join(tmpdir(), "setup-cpp", "brew")
await mkdirP(brewTempDirectory)
execa.sync("curl", ["-LJO", "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"], {
execaSync("curl", ["-LJO", "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"], {
cwd: brewTempDirectory,
})
const installSh = join(brewTempDirectory, "install.sh")
@ -39,7 +39,7 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
installShContent.replace("#!/bin/bash", "")
}
execa.sync("/bin/bash", [installSh], {
execaSync("/bin/bash", [installSh], {
stdio: "inherit",
env: {
NONINTERACTIVE: "1",

View File

@ -1,7 +1,6 @@
/* eslint-disable require-atomic-updates */
import execa from "execa"
import pathExists from "path-exists"
import { execaSync } from "execa"
import { pathExists } from "path-exists"
import { dirname } from "patha"
import which from "which"
import { addPath } from "../utils/env/addEnv"
@ -40,7 +39,7 @@ export async function setupChocolatey(
}
// https://docs.chocolatey.org/en-us/choco/setup#install-with-cmd.exe
execa.sync(
execaSync(
powershell,
[
"-NoProfile",

View File

@ -1,6 +1,6 @@
import { setupCmake } from "../cmake"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { getVersion } from "../../versions/versions"
jest.setTimeout(300000)
@ -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-actions") {
if (GITHUB_ACTIONS) {
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
}
})

View File

@ -14,7 +14,7 @@ import { isArch } from "../utils/env/isArch"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
import pathExists from "path-exists"
import { pathExists } from "path-exists"
import retry from "retry-as-promised"
/** Get the platform data for cmake */

View File

@ -2,7 +2,7 @@ import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-help
import { setupGcc } from "../gcc"
import { getVersion } from "../../versions/versions"
import { join, addExeExt } from "patha"
import execa from "execa"
import { execaSync } from "execa"
import { chmodSync } from "fs"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
@ -29,11 +29,11 @@ describe("setup-gcc", () => {
// test compilation
const file = join(__dirname, "main.cpp")
const main_exe = join(__dirname, addExeExt("main"))
execa.sync("g++", [file, "-o", main_exe], { cwd: __dirname })
execaSync("g++", [file, "-o", main_exe], { cwd: __dirname })
if (process.platform !== "win32") {
chmodSync(main_exe, "755")
}
execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" })
execaSync(main_exe, { cwd: __dirname, stdio: "inherit" })
})
afterAll(async () => {

View File

@ -9,14 +9,14 @@ import semverCoerce from "semver/functions/coerce"
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
import { join, addExeExt } from "patha"
import { warning, info } from "ci-log"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { extract7Zip } from "../utils/setup/extract"
import { isArch } from "../utils/env/isArch"
import { isUbuntu } from "../utils/env/isUbuntu"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import pathExists from "path-exists"
import { pathExists } from "path-exists"
interface MingwInfo {
releaseName: string
@ -197,7 +197,7 @@ async function activateGcc(version: string, binDir: string) {
promises.push(setupMacOSSDK())
if (ciDetect() === "github-actions") {
if (GITHUB_ACTIONS) {
await addGccLoggingMatcher()
}

View File

@ -39,7 +39,7 @@ describe("setup-Kcov", () => {
// it("should find Kcov in the cache", async () => {
// const binDir = await testKcov("v39", directory)
// if (ciDetect() === "github-actions") {
// if (GITHUB_ACTIONS) {
// expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
// }
// await cleanupTmpDir("kcov-v39")

View File

@ -1,4 +1,4 @@
import execa from "execa"
import { execa } from "execa"
import { join, addExeExt } from "patha"
import which from "which"
import { setupCmake } from "../cmake/cmake"

View File

@ -2,8 +2,8 @@ import { setupLLVM, setupClangTools } from "../llvm"
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
import { isUrlOnline } from "is-url-online"
import { setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import ciDetect from "@npmcli/ci-detect"
import execa from "execa"
import { GITHUB_ACTIONS } from "ci-info"
import { execaSync } from "execa"
import path, { addExeExt } from "patha"
import { chmodSync } from "fs"
import { getVersion } from "../../versions/versions"
@ -56,6 +56,7 @@ describe("setup-llvm", () => {
it("Finds valid LLVM URLs", async () => {
await Promise.all(
[
...(process.platform === "darwin" ? [] : ["16.0.2", "16.0.0"]),
"15.0.2",
// "14.0.1",
"14.0.0",
@ -91,11 +92,11 @@ describe("setup-llvm", () => {
// test compilation
const file = path.join(__dirname, "main.cpp")
const main_exe = path.join(__dirname, addExeExt("main"))
execa.sync("clang++", [file, "-o", main_exe], { cwd: __dirname })
execaSync("clang++", [file, "-o", main_exe], { cwd: __dirname })
if (process.platform !== "win32") {
chmodSync(main_exe, "755")
}
execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" })
execaSync(main_exe, { cwd: __dirname, stdio: "inherit" })
})
it("should find llvm in the cache", async () => {
@ -103,7 +104,7 @@ describe("setup-llvm", () => {
const { binDir } = await setupLLVM(getVersion("llvm", "true", osVersion), directory, process.arch)
await testBin("clang++", ["--version"], binDir)
if (ciDetect() === "github-actions" && process.platform !== "linux") {
if (GITHUB_ACTIONS && process.platform !== "linux") {
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
// TODO returns the install dir on linux
}
@ -111,7 +112,7 @@ describe("setup-llvm", () => {
expect(process.env.CC?.includes("clang")).toBeTruthy()
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
if (ciDetect() === "github-actions" && process.platform !== "linux") {
if (GITHUB_ACTIONS && process.platform !== "linux") {
expect(process.env.CC).toMatch("hostedtoolcache")
expect(process.env.CXX).toMatch("hostedtoolcache")
}

View File

@ -8,13 +8,13 @@ import { addEnv } from "../utils/env/addEnv"
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
import { info, warning } from "ci-log"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { setupGcc } from "../gcc/gcc"
import { getVersion } from "../versions/versions"
import { isUbuntu } from "../utils/env/isUbuntu"
import { getLLVMPackageInfo } from "./llvm_url"
import { ubuntuVersion } from "../utils/env/ubuntu_version"
import pathExists from "path-exists"
import { pathExists } from "path-exists"
import { ExecaReturnValue } from "execa"
export async function setupLLVM(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
@ -115,7 +115,7 @@ export async function activateLLVM(directory: string, versionGiven: string) {
)
}
if (ciDetect() === "github-actions") {
if (GITHUB_ACTIONS) {
await addLLVMLoggingMatcher()
}
@ -124,7 +124,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 async function setupClangTools(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
if (ciDetect() === "github-actions") {
if (GITHUB_ACTIONS) {
await addLLVMLoggingMatcher()
}
return setupLLVMWithoutActivation(version, setupDir, arch)

View File

@ -61,6 +61,10 @@ export const VERSIONS: Set<string> = getVersions([
"15.0.4",
"15.0.5",
"15.0.6",
"15.0.7",
"16.0.0",
"16.0.1",
"16.0.2",
])
/** The LLVM versions that were never released for the Windows platform. */
@ -81,9 +85,14 @@ const DARWIN_MISSING = new Set([
"11.0.1",
"11.1.0",
"12.0.1",
// missing x86_64
// TODO add arm64 support
"15.0.4",
"15.0.5",
"15.0.6",
"16.0.0",
"16.0.1",
"16.0.2",
])
/**
@ -141,6 +150,8 @@ const UBUNTU_SUFFIX_MAP: { [key: string]: string } = {
"15.0.2": "-rhel86",
"15.0.5": "-ubuntu-18.04",
"15.0.6": "-ubuntu-18.04",
"16.0.0": "-ubuntu-18.04",
"16.0.2": "-ubuntu-22.04",
}
/** The latest supported LLVM version for the Linux (Ubuntu) platform. */

View File

@ -2,7 +2,7 @@
/* eslint-disable node/shebang */
import { endGroup, getInput, notice, startGroup } from "@actions/core"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { error, info, success, warning } from "ci-log"
import mri from "mri"
import * as numerous from "numerous"
@ -89,7 +89,7 @@ const inputs: Array<Inputs> = ["compiler", "architecture", ...tools]
/** The main entry function */
export async function main(args: string[]): Promise<number> {
if (ciDetect() !== "github-actions") {
if (!GITHUB_ACTIONS) {
process.env.ACTIONS_ALLOW_UNSECURE_COMMANDS = "true"
}
@ -280,7 +280,7 @@ export async function main(args: string[]): Promise<number> {
info("setup-cpp finished")
if (ciDetect() !== "github-actions") {
if (!GITHUB_ACTIONS) {
switch (process.platform) {
case "win32": {
warning("Run `RefreshEnv.cmd` or restart your shell to update the environment.")

View File

@ -3,11 +3,11 @@ import { setupVCVarsall } from "../vcvarsall/vcvarsall"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { vsversion_to_versionnumber, findVcvarsall } from "msvc-dev-cmd/lib.js"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { join } from "patha"
import { error, info, warning } from "ci-log"
import pathExists from "path-exists"
import { pathExists } from "path-exists"
type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string
@ -66,7 +66,7 @@ export async function setupMSVC(
// run vcvarsall.bat environment variables
await setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
if (ciDetect() === "github-actions") {
if (GITHUB_ACTIONS) {
await addMSVCLoggingMatcher()
}
}

View File

@ -1,6 +1,6 @@
import { setupNinja } from "../ninja"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { getVersion } from "../../versions/versions"
jest.setTimeout(300000)
@ -22,7 +22,7 @@ describe("setup-ninja", () => {
it("should find Ninja in the cache", async () => {
const binDir = await testNinja(directory)
if (ciDetect() === "github-actions") {
if (GITHUB_ACTIONS) {
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
}
})

View File

@ -1,12 +1,12 @@
import { setupPowershell } from "../powershell"
import { testBin } from "../../utils/tests/test-helpers"
import { getVersion } from "../../versions/versions"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
jest.setTimeout(300000)
describe("setup-powershell", () => {
it("should setup powershell", async () => {
if (process.platform === "win32" && ciDetect() === "github-actions") {
if (process.platform === "win32" && GITHUB_ACTIONS) {
// results in errors
return
}

View File

@ -2,7 +2,7 @@ import { setupPython } from "../python"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { getVersion } from "../../versions/versions"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { info } from "ci-log"
jest.setTimeout(300000)
@ -13,7 +13,7 @@ describe("setup-python", () => {
})
it("should setup python in GitHub Actions", async () => {
if (ciDetect() === "github-actions") {
if (GITHUB_ACTIONS) {
info("Installing python in GitHub Actions")
const { setupActionsPython } = await import("../actions_python")
await setupActionsPython(getVersion("python", "true", await ubuntuVersion()), directory, process.arch)

View File

@ -4,10 +4,10 @@ import { findPyPyVersion } from "setup-python/src/find-pypy"
import { info, warning } from "ci-log"
import { debug } from "@actions/core"
import { join } from "patha"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { isCacheFeatureAvailable, IS_MAC } from "setup-python/src/utils"
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
import pathExists from "path-exists"
import { pathExists } from "path-exists"
function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith("pypy")
@ -51,7 +51,7 @@ export async function setupActionsPython(version: string, _setupDir: string, arc
}
}
if (ciDetect() === "github-actions") {
if (GITHUB_ACTIONS) {
await addPythonLoggingMatcher()
}

View File

@ -3,7 +3,7 @@ import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { warning, info } from "ci-log"
import { isArch } from "../utils/env/isArch"
import which from "which"
@ -16,11 +16,11 @@ import { getExecOutput } from "@actions/exec"
import { isBinUptoDate } from "../utils/setup/version"
import { getVersion } from "../versions/versions"
import assert from "assert"
import execa from "execa"
import { execaSync } from "execa"
import { unique } from "../utils/std"
export async function setupPython(version: string, setupDir: string, arch: string) {
if (ciDetect() !== "github-actions") {
if (!GITHUB_ACTIONS) {
// TODO parse version
return setupPythonViaSystem(version, setupDir, arch)
}
@ -71,12 +71,12 @@ export async function setupPythonViaSystem(
} else if (isUbuntu()) {
installInfo = await setupAptPack([{ name: "python3", version }, { name: "python3-pip" }])
} else {
throw new Error(`Unsupported linux distributions`)
throw new Error("Unsupported linux distributions")
}
return installInfo
}
default: {
throw new Error(`Unsupported platform`)
throw new Error("Unsupported platform")
}
}
}
@ -109,7 +109,7 @@ export async function setupPythonAndPip(): Promise<string> {
if (process.platform === "win32") {
// downgrade pip on Windows
// https://github.com/pypa/pip/issues/10875#issuecomment-1030293005
execa.sync(foundPython, ["-m", "pip", "install", "-U", "pip==21.3.1"], { stdio: "inherit" })
execaSync(foundPython, ["-m", "pip", "install", "-U", "pip==21.3.1"], { stdio: "inherit" })
} else if (process.platform === "linux") {
// ensure that pip is installed on Linux (happens when python is found but pip not installed)
if (isArch()) {
@ -122,7 +122,7 @@ export async function setupPythonAndPip(): Promise<string> {
}
// install wheel (required for Conan, Meson, etc.)
execa.sync(foundPython, ["-m", "pip", "install", "-U", "wheel"], { stdio: "inherit" })
execaSync(foundPython, ["-m", "pip", "install", "-U", "wheel"], { stdio: "inherit" })
return foundPython
}

View File

@ -1,6 +1,6 @@
import { setupTask } from "../task"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { getVersion } from "../../versions/versions"
jest.setTimeout(300000)
@ -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-actions") {
if (GITHUB_ACTIONS) {
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
}
})

View File

@ -1,5 +1,5 @@
import { exportVariable, addPath as ghAddPath, info, setFailed } from "@actions/core"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { untildifyUser } from "untildify-user"
import { appendFileSync, readFileSync, writeFileSync } from "fs"
import { error, warning } from "ci-log"
@ -8,7 +8,7 @@ import { delimiter } from "path"
import escapeSpace from "escape-path-with-spaces"
import { giveUserAccess } from "user-access"
import escapeQuote from "escape-quotes"
import pathExists from "path-exists"
import { pathExists } from "path-exists"
/**
* Add an environment variable.
@ -18,7 +18,7 @@ import pathExists from "path-exists"
export async function addEnv(name: string, valGiven: string | undefined, shouldEscapeSpace: boolean = false) {
const val = escapeString(valGiven ?? "", shouldEscapeSpace)
try {
if (ciDetect() === "github-actions") {
if (GITHUB_ACTIONS) {
try {
exportVariable(name, val)
} catch (err) {
@ -47,7 +47,7 @@ function escapeString(valGiven: string, shouldEscapeSpace: boolean = false) {
export async function addPath(path: string) {
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
try {
if (ciDetect() === "github-actions") {
if (GITHUB_ACTIONS) {
try {
ghAddPath(path)
} catch (err) {
@ -69,7 +69,7 @@ async function addEnvSystem(name: string, valGiven: string | undefined) {
const val = valGiven ?? ""
switch (process.platform) {
case "win32": {
// We do not use `execa.sync(`setx PATH "${path};%PATH%"`)` because of its character limit
// We do not use `execaSync(`setx PATH "${path};%PATH%"`)` because of its character limit
await execPowershell(`[Environment]::SetEnvironmentVariable('${name}', '${val}', "User")`)
info(`${name}='${val}' was set in the environment.`)
return
@ -91,7 +91,7 @@ async function addEnvSystem(name: string, valGiven: string | undefined) {
async function addPathSystem(path: string) {
switch (process.platform) {
case "win32": {
// We do not use `execa.sync(`setx PATH "${path};%PATH%"`)` because of its character limit and also because %PATH% is different for user and system
// We do not use `execaSync(`setx PATH "${path};%PATH%"`)` because of its character limit and also because %PATH% is different for user and system
await execPowershell(
`$USER_PATH=([Environment]::GetEnvironmentVariable("PATH", "User")); [Environment]::SetEnvironmentVariable("PATH", "${path};$USER_PATH", "User")`
)

View File

@ -1,4 +1,4 @@
import execa from "execa"
import { execa } from "execa"
import { mkdirP } from "@actions/io"
import which from "which"
import { setupSevenZip } from "../../sevenzip/sevenzip"

View File

@ -2,13 +2,13 @@
import { InstallationInfo } from "./setupBin"
import { execRoot, execRootSync } from "admina"
import { info } from "@actions/core"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
import which from "which"
import pathExists from "path-exists"
import { pathExists } from "path-exists"
import { promises as fsPromises } from "fs"
const { appendFile } = fsPromises
import execa from "execa"
import { execa } from "execa"
import escapeRegex from "escape-string-regexp"
let didUpdate: boolean = false
@ -149,7 +149,7 @@ export async function addAptKeyViaDownload(name: string, url: string) {
}
export async function updateAptAlternatives(name: string, path: string) {
if (ciDetect() === "github-actions") {
if (GITHUB_ACTIONS) {
return execRoot("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])
} else {
await setupCppInProfile()

View File

@ -4,14 +4,14 @@ import { join } from "patha"
import { info } from "ci-log"
import { tmpdir } from "os"
import ciDetect from "@npmcli/ci-detect"
import { GITHUB_ACTIONS } from "ci-info"
import { setupAptPack } from "./setupAptPack"
import { setupPacmanPack } from "./setupPacmanPack"
import { isArch } from "../env/isArch"
import { hasDnf } from "../env/hasDnf"
import { setupDnfPack } from "./setupDnfPack"
import { isUbuntu } from "../env/isUbuntu"
import pathExists from "path-exists"
import { pathExists } from "path-exists"
import retry from "retry-as-promised"
/** A type that describes a package */
@ -66,7 +66,7 @@ export async function setupBin(
)
// Restore from cache (if found).
if (ciDetect() === "github-actions") {
if (GITHUB_ACTIONS) {
try {
const dir = find(name, version)
if (dir) {
@ -136,7 +136,7 @@ export async function setupBin(
await addPath(binDir)
// check if inside Github Actions. If so, cache the installation
if (ciDetect() === "github-actions" && typeof process.env.RUNNER_TOOL_CACHE === "string") {
if (GITHUB_ACTIONS && typeof process.env.RUNNER_TOOL_CACHE === "string") {
await cacheDir(setupDir, name, version)
}

View File

@ -1,6 +1,6 @@
/* eslint-disable require-atomic-updates */
import { info } from "@actions/core"
import execa from "execa"
import { execaSync } from "execa"
import { join } from "patha"
import which from "which"
import { getBrewPath, setupBrew } from "../../brew/brew"
@ -24,7 +24,7 @@ export async function setupBrewPack(
const binDir = getBrewPath()
// brew is not thread-safe
execa.sync(
execaSync(
join(binDir, "brew"),
["install", version !== undefined && version !== "" ? `${name}@${version}` : name, ...extraArgs],
{

View File

@ -3,7 +3,7 @@ import { addPath } from "../env/addEnv"
import which from "which"
import { setupChocolatey } from "../../chocolatey/chocolatey"
import { InstallationInfo } from "./setupBin"
import execa from "execa"
import { execaSync } from "execa"
import { info } from "@actions/core"
import { notice } from "ci-log"
@ -27,14 +27,14 @@ export async function setupChocoPack(name: string, version?: string, args: strin
env.PATH = PATH
if (version !== undefined && version !== "") {
execa.sync("choco", ["install", "-y", name, `--version=${version}`, ...args], {
execaSync("choco", ["install", "-y", name, `--version=${version}`, ...args], {
env,
extendEnv: false,
stdio: "inherit",
})
} else {
try {
execa.sync("choco", ["install", "-y", name, ...args], { env, extendEnv: false, stdio: "inherit" })
execaSync("choco", ["install", "-y", name, ...args], { env, extendEnv: false, stdio: "inherit" })
} catch (err) {
// if the package requires a reboot, downgrade the error to a notice
if ((err as Error).message.includes("exit code 3010")) {

View File

@ -1,13 +1,12 @@
/* eslint-disable require-atomic-updates */
import execa from "execa"
import { info } from "@actions/core"
import { addPythonBaseExecPrefix, setupPythonAndPip } from "../../python/python"
import { InstallationInfo } from "./setupBin"
import { execaSync } from "execa"
import { pathExists } from "path-exists"
import { addExeExt, dirname, join } from "patha"
import { addPath } from "../env/addEnv"
import which from "which"
import pathExists from "path-exists"
import { addPythonBaseExecPrefix, setupPythonAndPip } from "../../python/python"
import { addPath } from "../env/addEnv"
import { InstallationInfo } from "./setupBin"
let python: string | undefined
let binDirs: string[] | undefined
@ -20,7 +19,7 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
python = await setupPythonAndPip()
}
execa.sync(python, ["-m", "pip", "install", version !== undefined && version !== "" ? `${name}==${version}` : name], {
execaSync(python, ["-m", "pip", "install", version !== undefined && version !== "" ? `${name}==${version}` : name], {
stdio: "inherit",
})

View File

@ -4,7 +4,7 @@ import * as path from "patha"
import { addExeExt, join } from "patha"
import spawn from "cross-spawn"
import pathExists from "path-exists"
import { pathExists } from "path-exists"
export async function setupTmpDir(testName: string) {
const tempDirectory = path.join(tmpdir(), "setup cpp temp", testName)

View File

@ -1,18 +1,17 @@
import execa from "execa"
import { dirname, join, addShExt, addShRelativePrefix } from "patha"
import { execaSync } from "execa"
import { notice } from "ci-log"
import { pathExists } from "path-exists"
import { addShExt, addShRelativePrefix, dirname, join } from "patha"
import { giveUserAccess } from "user-access"
import which from "which"
import { addPath } from "../utils/env/addEnv"
import { notice } from "ci-log"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { InstallationInfo } from "../utils/setup/setupBin"
import { isArch } from "../utils/env/isArch"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isArch } from "../utils/env/isArch"
import { isUbuntu } from "../utils/env/isUbuntu"
import { giveUserAccess } from "user-access"
import pathExists from "path-exists"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { InstallationInfo } from "../utils/setup/setupBin"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
let hasVCPKG = false
@ -48,12 +47,12 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
}
if (!(await pathExists(join(setupDir, addShExt("bootstrap-vcpkg", ".bat"))))) {
execa.sync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir), stdio: "inherit" })
execaSync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir), stdio: "inherit" })
} else {
notice(`Vcpkg folder already exists at ${setupDir}. This might mean that ~/vcpkg is restored from the cache.`)
}
execa.sync(addShExt(addShRelativePrefix("bootstrap-vcpkg"), ".bat"), {
execaSync(addShExt(addShRelativePrefix("bootstrap-vcpkg"), ".bat"), {
cwd: setupDir,
shell: true,
stdio: "inherit",

View File

@ -3,7 +3,7 @@
import { setupMSVCDevCmd } from "msvc-dev-cmd/lib.js"
import { addEnv } from "../utils/env/addEnv"
import { info } from "ci-log"
import pathExists from "path-exists"
import { pathExists } from "path-exists"
function getArch(arch: string): string {
switch (arch) {