Merge pull request #315 from aminya/warnings [skip ci]

This commit is contained in:
Amin Yahyaabadi 2024-11-05 00:31:32 -08:00 committed by GitHub
commit 4481860df9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 139 additions and 33 deletions

View File

@ -66,6 +66,7 @@ words:
- libstdc
- libtinfo
- liuli
- mdimporterdir
- memoizee
- msbuild
- msvc
@ -92,6 +93,7 @@ words:
- pwsh
- pygments
- pypy
- qlplugindir
- Sccache
- setupcpp
- setx

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

@ -0,0 +1,97 @@
/**
* The options for installing a package using brew
*/
export type BrewPackOptions = {
/** Whether to overwrite the package if it already exists */
overwrite?: boolean
/** Whether to install the package as a cask */
cask?: boolean
/** Treat all named arguments as formulae */
formula?: boolean
/** If brewing fails, open an interactive debugging session */
debug?: boolean
/** Print install times for each package at the end of the run */
"display-times"?: boolean
/** Install formulae without checking for previously installed versions */
force?: boolean
/** Print the verification and post-install steps */
verbose?: boolean
/** Show what would be installed, but do not actually install anything */
"dry-run"?: boolean
/** Skip installing any dependencies of any kind */
"ignore-dependencies"?: boolean
/** Install the dependencies with specified options but do not install the formula itself */
"only-dependencies"?: boolean
/** Attempt to compile using the specified compiler */
cc?: string
/** Compile formula from source even if a bottle is provided */
"build-from-source"?: boolean
/** Install from a bottle if it exists */
"force-bottle"?: boolean
/** Install testing dependencies required to run brew test formula */
"include-test"?: boolean
/** Install the HEAD version */
HEAD?: boolean
/** Fetch the upstream repository to detect if the HEAD installation is outdated */
"fetch-HEAD"?: boolean
/** Retain the temporary files created during installation */
"keep-tmp"?: boolean
/** Generate debug symbols on build */
"debug-symbols"?: boolean
/** Prepare the formula for eventual bottling during installation */
"build-bottle"?: boolean
/** Install but skip any post-install steps */
"skip-post-install"?: boolean
/** Optimise bottles for the specified architecture */
"bottle-arch"?: string
/** Download and patch formula, then open a shell */
interactive?: boolean
/** Create a Git repository */
git?: boolean
/** Disable/enable linking of helper executables */
binaries?: boolean
/** Require all casks to have a checksum */
"require-sha"?: boolean
/** Disable/enable quarantining of downloads */
quarantine?: boolean
/** Adopt existing artifacts in the destination that are identical to those being installed */
adopt?: boolean
/** Skip installing cask dependencies */
"skip-cask-deps"?: boolean
/** Remove all files associated with a cask */
zap?: boolean
/** Target location for Applications */
appdir?: string
/** Target location for Keyboard Layouts */
"keyboard-layoutdir"?: string
/** Target location for Color Pickers */
colorpickerdir?: string
/** Target location for Preference Panes */
prefpanedir?: string
/** Target location for Quick Look Plugins */
qlplugindir?: string
/** Target location for Spotlight Plugins */
mdimporterdir?: string
/** Target location for Dictionaries */
dictionarydir?: string
/** Target location for Fonts */
fontdir?: string
/** Target location for Services */
servicedir?: string
/** Target location for Input Methods */
"input-methoddir"?: string
/** Target location for Internet Plugins */
"internet-plugindir"?: string
/** Target location for Audio Unit Plugins */
"audio-unit-plugindir"?: string
/** Target location for VST Plugins */
"vst-plugindir"?: string
/** Target location for VST3 Plugins */
"vst3-plugindir"?: string
/** Target location for Screen Savers */
"screen-saverdir"?: string
/** Comma-separated list of language codes to prefer for cask installation */
language?: string
/** Make some output more quiet */
quiet?: boolean
}

View File

@ -3,20 +3,12 @@ import { info } from "ci-log"
import { execaSync } from "execa"
import which from "which"
import type { InstallationInfo } from "./InstallationInfo.js"
import type { BrewPackOptions } from "./install-pack-options.js"
import { getBrewBinDir, setupBrew } from "./install.js"
/* eslint-disable require-atomic-updates */
let hasBrew = false
export type BrewPackOptions = {
/** Whether to overwrite the package if it already exists */
overwrite?: boolean
/** Whether to install the package as a cask */
cask?: boolean
/** Extra args */
args?: string[]
}
/** A function that installs a package using brew
*
* @param name The name of the package
@ -28,13 +20,13 @@ export type BrewPackOptions = {
export async function installBrewPack(
name: string,
version?: string,
givenOptions: BrewPackOptions = {},
options: BrewPackOptions = {},
): Promise<InstallationInfo> {
const options = {
overwrite: true,
cask: false,
args: [],
...givenOptions,
if (!("overwrite" in options)) {
options.overwrite = true // default to true if not specified
}
if (options.cask) {
options.overwrite = false // mutually exclusive with --overwrite
}
info(`Installing ${name} ${version ?? ""} via brew`)
@ -52,11 +44,13 @@ export async function installBrewPack(
"install",
(version !== undefined && version !== "") ? `${name}@${version}` : name,
]
if (options.overwrite) {
args.push("--overwrite")
}
if (options.cask) {
args.push("--cask")
// Add options to args
for (const [key, value] of Object.entries(options)) {
if (typeof value === "boolean" && value) {
args.push(`--${key}`)
} else if (typeof value === "string") {
args.push(`--${key}`, value)
}
}
// brew is not thread-safe

View File

@ -2,5 +2,7 @@ import { setupPipPack } from "../utils/setup/setupPipPack.js"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupCpplint(version: string | undefined, _setupDir: string, _arch: string) {
return setupPipPack("cpplint", version)
return setupPipPack("cpplint", version, {
pythonVersion: ">=3.8.0",
})
}

View File

@ -78,7 +78,9 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
// try {
// installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
// } catch {
const installationInfo = await installBrewPack("doxygen", undefined)
const installationInfo = await installBrewPack("doxygen", undefined, {
formula: true,
})
// }
// only install graphviz if the macOS version is greater than 11

View File

@ -4,7 +4,7 @@ import { dirname, join, parse as pathParse } from "path"
import { getExecOutput } from "@actions/exec"
import ciInfo from "ci-info"
const { GITHUB_ACTIONS } = ciInfo
import { info, warning } from "ci-log"
import { info, notice, warning } from "ci-log"
import { addPath } from "envosman"
import { execa } from "execa"
import { readdir } from "fs/promises"
@ -63,7 +63,7 @@ async function setupPipx(foundPython: string) {
await execa(foundPython, ["-m", "pipx", "ensurepath"], { stdio: "inherit" })
await setupVenv(foundPython)
} catch (err) {
warning(`Failed to install pipx: ${(err as Error).toString()}. Ignoring...`)
notice(`Failed to install pipx: ${(err as Error).toString()}. Ignoring...`)
}
}
@ -71,7 +71,7 @@ async function setupVenv(foundPython: string) {
try {
await setupPipPackWithPython(foundPython, "venv", undefined, { upgrade: false, usePipx: false })
} catch (err) {
warning(`Failed to install venv: ${(err as Error).toString()}. Ignoring...`)
info(`Failed to install venv: ${(err as Error).toString()}. Ignoring...`)
}
}
@ -85,7 +85,7 @@ async function setupWheel(foundPython: string) {
})
await setupPipPackWithPython(foundPython, "wheel", undefined, { upgrade: false, isLibrary: true, usePipx: false })
} catch (err) {
warning(`Failed to install setuptools/wheel: ${(err as Error).toString()}. Ignoring...`)
info(`Failed to install setuptools/wheel: ${(err as Error).toString()}. Ignoring...`)
}
}

View File

@ -30,6 +30,8 @@ export type SetupPipPackOptions = {
upgrade?: boolean
/** Whether the package is a library */
isLibrary?: boolean
/** python version (e.g. >=3.8.0) */
pythonVersion?: string
}
/** A function that installs a package using pip */
@ -38,7 +40,7 @@ export async function setupPipPack(
version?: string,
options: SetupPipPackOptions = {},
): Promise<InstallationInfo> {
return setupPipPackWithPython(await getPython(), name, version, options)
return setupPipPackWithPython(await getPython(options.pythonVersion), name, version, options)
}
export async function setupPipPackWithPython(
@ -173,12 +175,15 @@ const getPipxBinDir = memoize(getPipxBinDir_, { promise: true })
/* eslint-disable require-atomic-updates */
let pythonBin: string | undefined
async function getPython(): Promise<string> {
async function getPython(givenPythonVersion?: string): Promise<string> {
if (pythonBin !== undefined) {
return pythonBin
}
pythonBin = (await setupPython(getVersion("python", undefined, await ubuntuVersion()), "", process.arch)).bin
const pythonVersion = givenPythonVersion
?? getVersion("python", undefined, await ubuntuVersion())
pythonBin = (await setupPython(pythonVersion, "", process.arch)).bin
return pythonBin
}
@ -277,6 +282,10 @@ export function setupPipPackSystem(name: string, addPythonPrefix = true) {
return installAptPack([{ name: addPythonPrefix ? `python3-${name}` : name }])
}
} else if (process.platform === "darwin") {
if (["venv"].includes(name)) {
return null
}
return installBrewPack(name)
}
return null