Skip to content

Commit

Permalink
Merge pull request #242 from aminya/macos-arm [skip test]
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Apr 10, 2024
2 parents 17a5a83 + cceb0f9 commit 34bb783
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 83 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -92,6 +92,7 @@ jobs:
os:
- windows-2022
- ubuntu-22.04
- macos-13
- macos-12
node:
- 20
Expand Down
17 changes: 0 additions & 17 deletions dev/scripts/debug_remove.js

This file was deleted.

18 changes: 9 additions & 9 deletions dist/actions/setup-cpp.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions 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.

14 changes: 7 additions & 7 deletions dist/modern/setup-cpp.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"src",
"packages",
"dev/docker",
"dev/docker/__tests__",
"README.md",
"LICENSE.txt",
"LICENSE.dependencies.txt",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions src/brew/brew.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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", "")
}

Expand Down
4 changes: 2 additions & 2 deletions src/gcc/__tests__/gcc.test.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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" })
})
Expand Down
10 changes: 5 additions & 5 deletions src/llvm/__tests__/llvm.test.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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" })
})
Expand Down
2 changes: 1 addition & 1 deletion src/llvm/llvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down
5 changes: 2 additions & 3 deletions src/llvm/llvm_installer.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/msvc/__tests__/msvc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
})
Expand All @@ -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())
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/powershell/powershell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
9 changes: 7 additions & 2 deletions src/python/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/env/ubuntu_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/setup/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ export async function extractTarByExe(file: string, dest: string, flags = ["--st
}
}

grantUserWriteAccess(dest)
await grantUserWriteAccess(dest)
return dest
}
13 changes: 6 additions & 7 deletions src/utils/setup/setupAptPack.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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`,
)
Expand Down

0 comments on commit 34bb783

Please sign in to comment.