mirror of https://github.com/aminya/setup-cpp
Merge pull request #242 from aminya/macos-arm [skip test]
This commit is contained in:
commit
34bb783813
|
@ -67,7 +67,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
|
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
|
||||||
echo "Detected uncommitted changes after build. See status below:"
|
echo "Detected uncommitted changes after build. See status below:"
|
||||||
git diff --ignore-space-at-eol --text dist/
|
git diff --ignore-space-at-eol --text dist/ ':(exclude)*.js.map'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ jobs:
|
||||||
os:
|
os:
|
||||||
- windows-2022
|
- windows-2022
|
||||||
- ubuntu-22.04
|
- ubuntu-22.04
|
||||||
|
- macos-13
|
||||||
- macos-12
|
- macos-12
|
||||||
node:
|
node:
|
||||||
- 20
|
- 20
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
/* eslint-disable import/no-extraneous-dependencies */
|
|
||||||
const { minify } = require("terser")
|
|
||||||
const { readFileSync, writeFileSync } = require("fs")
|
|
||||||
const { join, dirname } = require("path")
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
console.log("Disabling debug messages inside @actions/core")
|
|
||||||
const file = join(dirname(__dirname), "dist", "setup-cpp.js")
|
|
||||||
const { code, map } = await minify(readFileSync(file, "utf8"), { sourceMap: true, ...require("../.terserrc.js") })
|
|
||||||
|
|
||||||
writeFileSync(file, code)
|
|
||||||
writeFileSync(`${file}.map`, map)
|
|
||||||
}
|
|
||||||
|
|
||||||
main().catch(function(err) {
|
|
||||||
throw err
|
|
||||||
})
|
|
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
|
@ -19,7 +19,6 @@
|
||||||
"src",
|
"src",
|
||||||
"packages",
|
"packages",
|
||||||
"dev/docker",
|
"dev/docker",
|
||||||
"dev/docker/__tests__",
|
|
||||||
"README.md",
|
"README.md",
|
||||||
"LICENSE.txt",
|
"LICENSE.txt",
|
||||||
"LICENSE.dependencies.txt",
|
"LICENSE.dependencies.txt",
|
||||||
|
@ -47,10 +46,6 @@
|
||||||
"lint.tsc": "tsc --noEmit",
|
"lint.tsc": "tsc --noEmit",
|
||||||
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.mjs",
|
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.mjs",
|
||||||
"prepublishOnly": "rm ./dist/tsconfig.tsbuildinfo",
|
"prepublishOnly": "rm ./dist/tsconfig.tsbuildinfo",
|
||||||
"start.docker": "docker run -t setup-cpp .",
|
|
||||||
"start.docker.arch": "docker run -t setup-cpp:arch .",
|
|
||||||
"start.docker.fedora": "docker run -t setup-cpp:fedora .",
|
|
||||||
"start.docker.ubuntu": "docker run -t setup-cpp:ubuntu .",
|
|
||||||
"test.lint": "run-p --aggregate-output --continue-on-error lint.cspell test.lint.eslint test.lint.dprint lint.tsc",
|
"test.lint": "run-p --aggregate-output --continue-on-error lint.cspell test.lint.eslint test.lint.dprint lint.tsc",
|
||||||
"test.lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/",
|
"test.lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/",
|
||||||
"test.lint.dprint": "dprint check",
|
"test.lint.dprint": "dprint check",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { mkdirP } from "@actions/io"
|
import { mkdirP } from "@actions/io"
|
||||||
import { execaSync } from "execa"
|
import { execaSync } from "execa"
|
||||||
import { readFileSync } from "fs"
|
import { readFile } from "fs/promises"
|
||||||
import { tmpdir } from "os"
|
import { tmpdir } from "os"
|
||||||
import path, { join } from "path"
|
import path, { join } from "path"
|
||||||
import { dirname } from "patha"
|
import { dirname } from "patha"
|
||||||
|
@ -35,8 +35,7 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
|
||||||
const installSh = join(brewTempDirectory, "install.sh")
|
const installSh = join(brewTempDirectory, "install.sh")
|
||||||
|
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
const installShContent = readFileSync(installSh, "utf-8")
|
const installShContent = await readFile(installSh, "utf-8")
|
||||||
|
|
||||||
installShContent.replace("#!/bin/bash", "")
|
installShContent.replace("#!/bin/bash", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { execaSync } from "execa"
|
import { execaSync } from "execa"
|
||||||
import { chmodSync } from "fs"
|
import { chmod } from "fs/promises"
|
||||||
import { addExeExt, join } from "patha"
|
import { addExeExt, join } from "patha"
|
||||||
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
|
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
|
||||||
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||||
|
@ -31,7 +31,7 @@ describe("setup-gcc", () => {
|
||||||
const main_exe = join(__dirname, addExeExt("main"))
|
const main_exe = join(__dirname, addExeExt("main"))
|
||||||
execaSync("g++", [file, "-o", main_exe], { cwd: __dirname })
|
execaSync("g++", [file, "-o", main_exe], { cwd: __dirname })
|
||||||
if (process.platform !== "win32") {
|
if (process.platform !== "win32") {
|
||||||
chmodSync(main_exe, "755")
|
await chmod(main_exe, "755")
|
||||||
}
|
}
|
||||||
execaSync(main_exe, { cwd: __dirname, stdio: "inherit" })
|
execaSync(main_exe, { cwd: __dirname, stdio: "inherit" })
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import * as io from "@actions/io"
|
import * as io from "@actions/io"
|
||||||
import { execaSync } from "execa"
|
import { execaSync } from "execa"
|
||||||
import { chmodSync } from "fs"
|
import { chmod } from "fs/promises"
|
||||||
import { isUrlOnline } from "is-url-online"
|
import { isUrlOnline } from "is-url-online"
|
||||||
import path, { addExeExt } from "patha"
|
import { addExeExt, join } from "patha"
|
||||||
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
|
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
|
||||||
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
|
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
|
||||||
import { setupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
import { setupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||||
|
@ -98,11 +98,11 @@ describe("setup-llvm", () => {
|
||||||
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
|
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
|
||||||
|
|
||||||
// test compilation
|
// test compilation
|
||||||
const file = path.join(__dirname, "main.cpp")
|
const file = join(__dirname, "main.cpp")
|
||||||
const main_exe = path.join(__dirname, addExeExt("main"))
|
const main_exe = join(__dirname, addExeExt("main"))
|
||||||
execaSync("clang++", [file, "-o", main_exe], { cwd: __dirname })
|
execaSync("clang++", [file, "-o", main_exe], { cwd: __dirname })
|
||||||
if (process.platform !== "win32") {
|
if (process.platform !== "win32") {
|
||||||
chmodSync(main_exe, "755")
|
await chmod(main_exe, "755")
|
||||||
}
|
}
|
||||||
execaSync(main_exe, { cwd: __dirname, stdio: "inherit" })
|
execaSync(main_exe, { cwd: __dirname, stdio: "inherit" })
|
||||||
})
|
})
|
||||||
|
|
|
@ -93,7 +93,7 @@ export async function activateLLVM(directory: string) {
|
||||||
const ld = process.env.LD_LIBRARY_PATH ?? ""
|
const ld = process.env.LD_LIBRARY_PATH ?? ""
|
||||||
const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
|
const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
|
||||||
|
|
||||||
const actPromises: Promise<any>[] = [
|
const actPromises: Promise<void>[] = [
|
||||||
// the output of this action
|
// the output of this action
|
||||||
addEnv("LLVM_PATH", directory),
|
addEnv("LLVM_PATH", directory),
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import { execRoot } from "admina"
|
import { execRoot } from "admina"
|
||||||
import { info } from "console"
|
import { info } from "console"
|
||||||
import { execa } from "execa"
|
import { execa } from "execa"
|
||||||
import { promises } from "fs"
|
import { chmod, readFile, writeFile } from "fs/promises"
|
||||||
import { DEFAULT_TIMEOUT } from "../installTool"
|
import { DEFAULT_TIMEOUT } from "../installTool"
|
||||||
import { addPath } from "../utils/env/addEnv"
|
import { addPath } from "../utils/env/addEnv"
|
||||||
import { hasNala, isPackageInstalled, setupAptPack } from "../utils/setup/setupAptPack"
|
import { hasNala, isPackageInstalled, setupAptPack } from "../utils/setup/setupAptPack"
|
||||||
import { InstallationInfo } from "../utils/setup/setupBin"
|
import { InstallationInfo } from "../utils/setup/setupBin"
|
||||||
const { readFile, writeFile, chmod } = promises
|
|
||||||
|
|
||||||
export enum LLVMPackages {
|
export enum LLVMPackages {
|
||||||
All,
|
All,
|
||||||
|
@ -61,7 +60,7 @@ async function patchAptLLVMScript(path: string, target_path: string, majorVersio
|
||||||
}
|
}
|
||||||
|
|
||||||
function debugScript(script: string) {
|
function debugScript(script: string) {
|
||||||
if (!process.env.NODE_DEBUG) {
|
if (process.env.NODE_DEBUG !== "1" && process.env.NODE_DEBUG !== "true") {
|
||||||
return script.replace(/set -eux/g, "set -eu")
|
return script.replace(/set -eux/g, "set -eu")
|
||||||
}
|
}
|
||||||
return script
|
return script
|
||||||
|
|
|
@ -14,8 +14,8 @@ describe("setup-msvc", () => {
|
||||||
await setupMSVC("", "", process.arch)
|
await setupMSVC("", "", process.arch)
|
||||||
console.log(which.sync("cl"))
|
console.log(which.sync("cl"))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if ("toString" in (err as any)) {
|
if (err instanceof Error) {
|
||||||
warning((err as any).toString())
|
warning(err.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -30,8 +30,8 @@ describe("setup-msvc", () => {
|
||||||
await setupMSVC(`${version}`, "", process.arch)
|
await setupMSVC(`${version}`, "", process.arch)
|
||||||
console.log(which.sync("cl"))
|
console.log(which.sync("cl"))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if ("toString" in (err as any)) {
|
if (err instanceof Error) {
|
||||||
warning((err as any).toString())
|
warning(err.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -26,7 +26,7 @@ export async function setupPowershell(version: string | undefined, _setupDir: st
|
||||||
if (isArch()) {
|
if (isArch()) {
|
||||||
return setupPacmanPack("powershell-bin", version, "yay")
|
return setupPacmanPack("powershell-bin", version, "yay")
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
setupDnfPack([{ name: "curl" }])
|
await setupDnfPack([{ name: "curl" }])
|
||||||
execRootSync("/bin/bash", [
|
execRootSync("/bin/bash", [
|
||||||
"-c",
|
"-c",
|
||||||
`curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo`,
|
`curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo`,
|
||||||
|
|
|
@ -130,7 +130,10 @@ async function setupPythonSystem(setupDir: string, version: string) {
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
installInfo = await setupBrewPack("python3", version)
|
installInfo = await setupBrewPack("python3", version)
|
||||||
// add the python and pip binaries to the path
|
// add the python and pip binaries to the path
|
||||||
const brewPythonPrefix = await execa("brew", ["--prefix", "python"], { stdio: "pipe" })
|
const brewPythonPrefix: {
|
||||||
|
stdout: string
|
||||||
|
stderr: string
|
||||||
|
} = await execa("brew", ["--prefix", "python"], { stdio: "pipe" })
|
||||||
const brewPythonBin = join(brewPythonPrefix.stdout, "libexec", "bin")
|
const brewPythonBin = join(brewPythonPrefix.stdout, "libexec", "bin")
|
||||||
await addPath(brewPythonBin)
|
await addPath(brewPythonBin)
|
||||||
|
|
||||||
|
@ -176,6 +179,7 @@ async function isPythonUpToDate(candidate: string, binDir?: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
const pythonBinPaths = (await which(candidate, { nothrow: true, all: true })) ?? []
|
const pythonBinPaths = (await which(candidate, { nothrow: true, all: true })) ?? []
|
||||||
for (const pythonBinPath of pythonBinPaths) {
|
for (const pythonBinPath of pythonBinPaths) {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
@ -215,10 +219,11 @@ async function findPip() {
|
||||||
|
|
||||||
async function isPipUptoDate(pip: string) {
|
async function isPipUptoDate(pip: string) {
|
||||||
try {
|
try {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
const pipPaths = (await which(pip, { nothrow: true, all: true })) ?? []
|
const pipPaths = (await which(pip, { nothrow: true, all: true })) ?? []
|
||||||
for (const pipPath of pipPaths) {
|
for (const pipPath of pipPaths) {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
if (pipPath !== null && (await isBinUptoDate(pipPath, MinVersions.pip!))) {
|
if (await isBinUptoDate(pipPath, MinVersions.pip!)) {
|
||||||
return pipPath
|
return pipPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ function detectUsingOsVersion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// #46~22.04.1-Ubuntu SMP ...
|
// #46~22.04.1-Ubuntu SMP ...
|
||||||
const osVersion = os.version()
|
const osVersion: string = os.version()
|
||||||
const versionSplitted = osVersion.split(".")
|
const versionSplitted = osVersion.split(".")
|
||||||
const majorVersion = parseInt(versionSplitted[0].replace("#", ""), 10)
|
const majorVersion = parseInt(versionSplitted[0].replace("#", ""), 10)
|
||||||
const minorVersion = parseInt(versionSplitted[1].replace("~", ""), 10)
|
const minorVersion = parseInt(versionSplitted[1].replace("~", ""), 10)
|
||||||
|
|
|
@ -55,6 +55,6 @@ export async function extractTarByExe(file: string, dest: string, flags = ["--st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
grantUserWriteAccess(dest)
|
await grantUserWriteAccess(dest)
|
||||||
return dest
|
return dest
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import { execRoot, execRootSync } from "admina"
|
import { execRoot, execRootSync } from "admina"
|
||||||
import { GITHUB_ACTIONS } from "ci-info"
|
import { GITHUB_ACTIONS } from "ci-info"
|
||||||
import { promises as fsPromises } from "fs"
|
|
||||||
import { pathExists } from "path-exists"
|
|
||||||
import { addEnv, cpprc_path, sourceCpprc } from "../env/addEnv"
|
|
||||||
import { InstallationInfo } from "./setupBin"
|
|
||||||
const { appendFile } = fsPromises
|
|
||||||
import { info, warning } from "ci-log"
|
import { info, warning } from "ci-log"
|
||||||
import escapeRegex from "escape-string-regexp"
|
import escapeRegex from "escape-string-regexp"
|
||||||
import { execa, ExecaError } from "execa"
|
import { execa, ExecaError } from "execa"
|
||||||
|
import { appendFile } from "fs/promises"
|
||||||
|
import { pathExists } from "path-exists"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
|
import { addEnv, cpprc_path, sourceCpprc } from "../env/addEnv"
|
||||||
|
import { InstallationInfo } from "./setupBin"
|
||||||
|
|
||||||
/* eslint-disable require-atomic-updates */
|
/* eslint-disable require-atomic-updates */
|
||||||
let didUpdate: boolean = false
|
let didUpdate: boolean = false
|
||||||
|
@ -221,10 +220,10 @@ export async function addAptKeyViaDownload(name: string, url: string) {
|
||||||
|
|
||||||
export async function updateAptAlternatives(name: string, path: string, priority: number = 40) {
|
export async function updateAptAlternatives(name: string, path: string, priority: number = 40) {
|
||||||
if (GITHUB_ACTIONS) {
|
if (GITHUB_ACTIONS) {
|
||||||
return execRoot("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, priority.toString()])
|
await execRoot("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, priority.toString()])
|
||||||
} else {
|
} else {
|
||||||
await sourceCpprc()
|
await sourceCpprc()
|
||||||
return appendFile(
|
await appendFile(
|
||||||
cpprc_path,
|
cpprc_path,
|
||||||
`\nif [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${name} ${name} ${path} ${priority}; fi\n`,
|
`\nif [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${name} ${name} ${path} ${priority}; fi\n`,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue