Skip to content

Commit 740f226

Browse files
authored
Merge pull request #147 from aminya/sccache [skip ci]
2 parents 946a5bb + 66a38eb commit 740f226

File tree

16 files changed

+105
-20
lines changed

16 files changed

+105
-20
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ inputs:
5151
ccache:
5252
description: "The ccache version to install."
5353
required: false
54+
sccache:
55+
description: "The sccache version to install."
56+
required: false
5457
doxygen:
5558
description: "The doxygen version to install."
5659
required: false

cspell.config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ words:
6767
- pwsh
6868
- pygments
6969
- pypy
70+
- Sccache
7071
- setupcpp
7172
- setx
7273
- Syuu

dist/node12/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node12/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node16/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node16/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/brew/__tests__/brew.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("setup-brew", () => {
77
if (process.platform !== "darwin") {
88
return
99
}
10-
const installInfo = setupBrew("", "", process.arch)
10+
const installInfo = await setupBrew("", "", process.arch)
1111
await testBin("brew", ["--version"], installInfo?.binDir)
1212
})
1313
})

src/brew/brew.ts

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
import { execFileSync } from "child_process"
1+
import execa from "execa"
22
import { dirname } from "patha"
33
import which from "which"
4+
import { tmpdir } from "os"
5+
import path, { join } from "path"
6+
import { mkdirP } from "@actions/io"
7+
import { readFileSync } from "fs"
8+
import { addPath } from "../utils/env/addEnv"
49

510
let binDir: string | undefined
611

712
// eslint-disable-next-line @typescript-eslint/no-unused-vars
8-
export function setupBrew(_version: string, _setupDir: string, _arch: string) {
13+
export async function setupBrew(_version: string, _setupDir: string, _arch: string) {
914
if (!["darwin", "linux"].includes(process.platform)) {
1015
return undefined
1116
}
@@ -20,10 +25,37 @@ export function setupBrew(_version: string, _setupDir: string, _arch: string) {
2025
}
2126

2227
// brew is not thread-safe
23-
execFileSync(`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`, {
28+
const brewTempDirectory = path.join(tmpdir(), "setup_cpp", "brew")
29+
await mkdirP(brewTempDirectory)
30+
31+
execa.sync("curl", ["-LJO", "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"], {
32+
cwd: brewTempDirectory,
33+
})
34+
const installSh = join(brewTempDirectory, "install.sh")
35+
36+
if (process.platform === "linux") {
37+
const installShContent = readFileSync(installSh, "utf-8")
38+
39+
installShContent.replace("#!/bin/bash", "")
40+
}
41+
42+
execa.sync("/bin/bash", [installSh], {
2443
stdio: "inherit",
44+
env: {
45+
NONINTERACTIVE: "1",
46+
},
2547
})
26-
binDir = "/usr/local/bin/"
48+
49+
binDir = getBrewPath()
50+
await addPath(binDir)
2751

2852
return { binDir }
2953
}
54+
55+
export function getBrewPath() {
56+
if (process.platform === "linux") {
57+
return "/home/linuxbrew/.linuxbrew/bin/"
58+
} else {
59+
return "/usr/local/bin/"
60+
}
61+
}

src/doxygen/doxygen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
5454
return installationInfo
5555
}
5656
case "darwin": {
57-
const installationInfo = setupBrewPack("doxygen", undefined)
57+
const installationInfo = await setupBrewPack("doxygen", undefined)
5858
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
5959
return installationInfo
6060
}

src/gcc/gcc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
8383
break
8484
}
8585
case "darwin": {
86-
installationInfo = setupBrewPack("gcc", version)
86+
installationInfo = await setupBrewPack("gcc", version)
8787
break
8888
}
8989
case "linux": {

0 commit comments

Comments
 (0)