Merge pull request #242 from aminya/macos-arm [skip test]

This commit is contained in:
Amin Yahyaabadi 2024-04-10 12:16:24 -07:00 committed by GitHub
commit 34bb783813
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 64 additions and 83 deletions

View File

@ -67,7 +67,7 @@ jobs:
run: |
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
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
fi
@ -92,6 +92,7 @@ jobs:
os:
- windows-2022
- ubuntu-22.04
- macos-13
- macos-12
node:
- 20

View File

@ -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

View File

@ -19,7 +19,6 @@
"src",
"packages",
"dev/docker",
"dev/docker/__tests__",
"README.md",
"LICENSE.txt",
"LICENSE.dependencies.txt",
@ -47,10 +46,6 @@
"lint.tsc": "tsc --noEmit",
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.mjs",
"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.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",

View File

@ -1,6 +1,6 @@
import { mkdirP } from "@actions/io"
import { execaSync } from "execa"
import { readFileSync } from "fs"
import { readFile } from "fs/promises"
import { tmpdir } from "os"
import path, { join } from "path"
import { dirname } from "patha"
@ -35,8 +35,7 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
const installSh = join(brewTempDirectory, "install.sh")
if (process.platform === "linux") {
const installShContent = readFileSync(installSh, "utf-8")
const installShContent = await readFile(installSh, "utf-8")
installShContent.replace("#!/bin/bash", "")
}

View File

@ -1,5 +1,5 @@
import { execaSync } from "execa"
import { chmodSync } from "fs"
import { chmod } from "fs/promises"
import { addExeExt, join } from "patha"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
@ -31,7 +31,7 @@ describe("setup-gcc", () => {
const main_exe = join(__dirname, addExeExt("main"))
execaSync("g++", [file, "-o", main_exe], { cwd: __dirname })
if (process.platform !== "win32") {
chmodSync(main_exe, "755")
await chmod(main_exe, "755")
}
execaSync(main_exe, { cwd: __dirname, stdio: "inherit" })
})

View File

@ -1,8 +1,8 @@
import * as io from "@actions/io"
import { execaSync } from "execa"
import { chmodSync } from "fs"
import { chmod } from "fs/promises"
import { isUrlOnline } from "is-url-online"
import path, { addExeExt } from "patha"
import { addExeExt, join } from "patha"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
import { setupTmpDir, testBin } from "../../utils/tests/test-helpers"
@ -98,11 +98,11 @@ describe("setup-llvm", () => {
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
// test compilation
const file = path.join(__dirname, "main.cpp")
const main_exe = path.join(__dirname, addExeExt("main"))
const file = join(__dirname, "main.cpp")
const main_exe = join(__dirname, addExeExt("main"))
execaSync("clang++", [file, "-o", main_exe], { cwd: __dirname })
if (process.platform !== "win32") {
chmodSync(main_exe, "755")
await chmod(main_exe, "755")
}
execaSync(main_exe, { cwd: __dirname, stdio: "inherit" })
})

View File

@ -93,7 +93,7 @@ export async function activateLLVM(directory: string) {
const ld = process.env.LD_LIBRARY_PATH ?? ""
const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
const actPromises: Promise<any>[] = [
const actPromises: Promise<void>[] = [
// the output of this action
addEnv("LLVM_PATH", directory),

View File

@ -1,12 +1,11 @@
import { execRoot } from "admina"
import { info } from "console"
import { execa } from "execa"
import { promises } from "fs"
import { chmod, readFile, writeFile } from "fs/promises"
import { DEFAULT_TIMEOUT } from "../installTool"
import { addPath } from "../utils/env/addEnv"
import { hasNala, isPackageInstalled, setupAptPack } from "../utils/setup/setupAptPack"
import { InstallationInfo } from "../utils/setup/setupBin"
const { readFile, writeFile, chmod } = promises
export enum LLVMPackages {
All,
@ -61,7 +60,7 @@ async function patchAptLLVMScript(path: string, target_path: string, majorVersio
}
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

View File

@ -14,8 +14,8 @@ describe("setup-msvc", () => {
await setupMSVC("", "", process.arch)
console.log(which.sync("cl"))
} catch (err) {
if ("toString" in (err as any)) {
warning((err as any).toString())
if (err instanceof Error) {
warning(err.toString())
}
}
})
@ -30,8 +30,8 @@ describe("setup-msvc", () => {
await setupMSVC(`${version}`, "", process.arch)
console.log(which.sync("cl"))
} catch (err) {
if ("toString" in (err as any)) {
warning((err as any).toString())
if (err instanceof Error) {
warning(err.toString())
}
}
})

View File

@ -26,7 +26,7 @@ export async function setupPowershell(version: string | undefined, _setupDir: st
if (isArch()) {
return setupPacmanPack("powershell-bin", version, "yay")
} else if (hasDnf()) {
setupDnfPack([{ name: "curl" }])
await setupDnfPack([{ name: "curl" }])
execRootSync("/bin/bash", [
"-c",
`curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo`,

View File

@ -130,7 +130,10 @@ async function setupPythonSystem(setupDir: string, version: string) {
case "darwin": {
installInfo = await setupBrewPack("python3", version)
// 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")
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 })) ?? []
for (const pythonBinPath of pythonBinPaths) {
// eslint-disable-next-line no-await-in-loop
@ -215,10 +219,11 @@ async function findPip() {
async function isPipUptoDate(pip: string) {
try {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const pipPaths = (await which(pip, { nothrow: true, all: true })) ?? []
for (const pipPath of pipPaths) {
// eslint-disable-next-line no-await-in-loop
if (pipPath !== null && (await isBinUptoDate(pipPath, MinVersions.pip!))) {
if (await isBinUptoDate(pipPath, MinVersions.pip!)) {
return pipPath
}
}

View File

@ -43,7 +43,7 @@ function detectUsingOsVersion() {
}
// #46~22.04.1-Ubuntu SMP ...
const osVersion = os.version()
const osVersion: string = os.version()
const versionSplitted = osVersion.split(".")
const majorVersion = parseInt(versionSplitted[0].replace("#", ""), 10)
const minorVersion = parseInt(versionSplitted[1].replace("~", ""), 10)

View File

@ -55,6 +55,6 @@ export async function extractTarByExe(file: string, dest: string, flags = ["--st
}
}
grantUserWriteAccess(dest)
await grantUserWriteAccess(dest)
return dest
}

View File

@ -1,14 +1,13 @@
import { execRoot, execRootSync } from "admina"
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 escapeRegex from "escape-string-regexp"
import { execa, ExecaError } from "execa"
import { appendFile } from "fs/promises"
import { pathExists } from "path-exists"
import which from "which"
import { addEnv, cpprc_path, sourceCpprc } from "../env/addEnv"
import { InstallationInfo } from "./setupBin"
/* eslint-disable require-atomic-updates */
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) {
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 {
await sourceCpprc()
return appendFile(
await appendFile(
cpprc_path,
`\nif [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${name} ${name} ${path} ${priority}; fi\n`,
)