Skip to content

Commit 5528c08

Browse files
committed
fix: parallelize apt update alternatives
1 parent 5505d67 commit 5528c08

File tree

7 files changed

+29
-23
lines changed

7 files changed

+29
-23
lines changed

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/gcc/gcc.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async function setupChocoMingw(version: string, arch: string): Promise<Installat
152152
}
153153

154154
async function activateGcc(version: string, binDir: string) {
155-
const promises: Promise<void>[] = []
155+
const promises: Promise<any>[] = []
156156
// Setup gcc as the compiler
157157

158158
// TODO
@@ -174,19 +174,23 @@ async function activateGcc(version: string, binDir: string) {
174174
promises.push(addEnv("CC", `${binDir}/gcc-${majorVersion}`), addEnv("CXX", `${binDir}/g++-${majorVersion}`))
175175

176176
if (isUbuntu()) {
177-
await updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`)
178-
await updateAptAlternatives("cxx", `${binDir}/g++-${majorVersion}`)
179-
await updateAptAlternatives("gcc", `${binDir}/gcc-${majorVersion}`)
180-
await updateAptAlternatives("g++", `${binDir}/g++-${majorVersion}`)
177+
promises.push(
178+
updateAptAlternatives("cc", `${binDir}/gcc-${majorVersion}`),
179+
updateAptAlternatives("cxx", `${binDir}/g++-${majorVersion}`),
180+
updateAptAlternatives("gcc", `${binDir}/gcc-${majorVersion}`),
181+
updateAptAlternatives("g++", `${binDir}/g++-${majorVersion}`)
182+
)
181183
}
182184
} else {
183185
promises.push(addEnv("CC", `${binDir}/gcc-${version}`), addEnv("CXX", `${binDir}/g++-${version}`))
184186

185187
if (isUbuntu()) {
186-
await updateAptAlternatives("cc", `${binDir}/gcc-${version}`)
187-
await updateAptAlternatives("cxx", `${binDir}/g++-${version}`)
188-
await updateAptAlternatives("gcc", `${binDir}/gcc-${version}`)
189-
await updateAptAlternatives("g++", `${binDir}/g++-${version}`)
188+
promises.push(
189+
updateAptAlternatives("cc", `${binDir}/gcc-${version}`),
190+
updateAptAlternatives("cxx", `${binDir}/g++-${version}`),
191+
updateAptAlternatives("gcc", `${binDir}/gcc-${version}`),
192+
updateAptAlternatives("g++", `${binDir}/g++-${version}`)
193+
)
190194
}
191195
}
192196
}

src/llvm/llvm.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export async function activateLLVM(directory: string, versionGiven: string) {
7070
const ld = process.env.LD_LIBRARY_PATH ?? ""
7171
const dyld = process.env.DYLD_LIBRARY_PATH ?? ""
7272

73-
const promises = [
73+
const promises: Promise<any>[] = [
7474
// the output of this action
7575
addEnv("LLVM_PATH", directory),
7676

@@ -103,13 +103,15 @@ export async function activateLLVM(directory: string, versionGiven: string) {
103103
}
104104

105105
if (isUbuntu()) {
106-
await updateAptAlternatives("cc", `${directory}/bin/clang`)
107-
await updateAptAlternatives("cxx", `${directory}/bin/clang++`)
108-
await updateAptAlternatives("clang", `${directory}/bin/clang`)
109-
await updateAptAlternatives("clang++", `${directory}/bin/clang++`)
110-
await updateAptAlternatives("lld", `${directory}/bin/lld`)
111-
await updateAptAlternatives("ld.lld", `${directory}/bin/ld.lld`)
112-
await updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
106+
promises.push(
107+
updateAptAlternatives("cc", `${directory}/bin/clang`),
108+
updateAptAlternatives("cxx", `${directory}/bin/clang++`),
109+
updateAptAlternatives("clang", `${directory}/bin/clang`),
110+
updateAptAlternatives("clang++", `${directory}/bin/clang++`),
111+
updateAptAlternatives("lld", `${directory}/bin/lld`),
112+
updateAptAlternatives("ld.lld", `${directory}/bin/ld.lld`),
113+
updateAptAlternatives("llvm-ar", `${directory}/bin/llvm-ar`)
114+
)
113115
}
114116

115117
if (ciDetect() === "github-actions") {

src/utils/setup/setupAptPack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable require-atomic-updates */
22
import { InstallationInfo } from "./setupBin"
3-
import { execRootSync } from "admina"
3+
import { execRoot, execRootSync } from "admina"
44
import { info } from "@actions/core"
55
import ciDetect from "@npmcli/ci-detect"
66
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
@@ -146,7 +146,7 @@ export async function addAptKeyViaDownload(name: string, url: string) {
146146

147147
export async function updateAptAlternatives(name: string, path: string) {
148148
if (ciDetect() === "github-actions") {
149-
return execRootSync("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])
149+
return execRoot("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])
150150
} else {
151151
await setupCppInProfile()
152152
return appendFile(

0 commit comments

Comments
 (0)