Skip to content

Commit

Permalink
Merge pull request #315 from aminya/warnings [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Nov 5, 2024
2 parents 75454f9 + 867ce44 commit 4481860
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 33 deletions.
2 changes: 2 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ words:
- libstdc
- libtinfo
- liuli
- mdimporterdir
- memoizee
- msbuild
- msvc
Expand All @@ -92,6 +93,7 @@ words:
- pwsh
- pygments
- pypy
- qlplugindir
- Sccache
- setupcpp
- setx
Expand Down
2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs.map

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions packages/setup-brew/src/install-pack-options.ts
Original file line number Diff line number Diff line change
@@ -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
}
34 changes: 14 additions & 20 deletions packages/setup-brew/src/install-pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`)
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/cpplint/cpplint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
}
4 changes: 3 additions & 1 deletion src/doxygen/doxygen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/python/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -63,15 +63,15 @@ 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...`)
}
}

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...`)
}
}

Expand All @@ -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...`)
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/utils/setup/setupPipPack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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(
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4481860

Please sign in to comment.