Skip to content

Commit be9c96f

Browse files
authored
Merge pull request #334 from aminya/keywords [skip ci]
feat: support exclusive asset matching keywords+ Fix clang 15/16 on Ubuntu 24
2 parents 87d6792 + a2312d2 commit be9c96f

16 files changed

+160
-53
lines changed

cspell.config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ words:
2121
- bazel
2222
- bazelisk
2323
- biome
24+
- mkdirp
2425
- biomejs
2526
- buildtools
2627
- caxa

dist/legacy/assets/actions_python-Czj4ScEf.js renamed to dist/legacy/assets/actions_python-Dd4yvI9c.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/assets/actions_python-Czj4ScEf.js.map renamed to dist/legacy/assets/actions_python-Dd4yvI9c.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/assets/actions_python-C5ar-1oi.mjs renamed to dist/modern/assets/actions_python-NQlJj7Cn.mjs

+2-2
Large diffs are not rendered by default.

dist/modern/assets/actions_python-C5ar-1oi.mjs.map renamed to dist/modern/assets/actions_python-NQlJj7Cn.mjs.map

+1-1
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs

+1-1
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

+1-1
Large diffs are not rendered by default.

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"@types/cross-spawn": "^6.0.6",
8484
"@types/escape-quotes": "~1.0.0",
8585
"@types/eslint": "^9.6.1",
86+
"@types/fs-extra": "^11.0.4",
8687
"@types/iarna__toml": "~2.0.5",
8788
"@types/jest": "^29.5.14",
8889
"@types/memoizee": "^0.4.11",
@@ -107,6 +108,7 @@
107108
"eslint-config-atomic": "^1.22.1",
108109
"exec-powershell": "workspace:*",
109110
"execa": "^7",
111+
"fs-extra": "^11.3.0",
110112
"is-url-online": "^1.5.0",
111113
"jest": "^29.7.0",
112114
"lefthook": "^1.10.3",
@@ -186,13 +188,14 @@
186188
"untildify-user",
187189
"util.types",
188190
"web-streams-polyfill",
189-
"timers-browserify"
191+
"timers-browserify",
192+
"fs-extra"
190193
],
191194
"engines": {
192195
"node": ">=12.x",
193-
"pnpm": "^9"
196+
"pnpm": "^10"
194197
},
195-
"packageManager": "pnpm@9.15.4",
198+
"packageManager": "pnpm@10.2.0",
196199
"workspaces": [
197200
"packages/*"
198201
],

pnpm-lock.yaml

+43-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/llvm/__tests__/llvm.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,22 @@ describe("setup-llvm", () => {
117117

118118
await io.rmRF(directory)
119119
})
120+
121+
// test installation of LLVM 10 to 19 on Linux
122+
for (let version = 10; version <= 19; version++) {
123+
if (process.platform !== "linux") {
124+
continue
125+
}
126+
it(`should setup LLVM ${version} on Linux`, async () => {
127+
const directory = await setupTmpDir("llvm")
128+
129+
const { binDir } = await setupLLVM(`${version}`, directory, process.arch)
130+
await testBin("clang++", ["--version"], binDir)
131+
132+
expect(process.env.CC?.includes("clang")).toBeTruthy()
133+
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
134+
135+
await io.rmRF(directory)
136+
})
137+
}
120138
})

src/llvm/llvm.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ async function llvmBinaryDeps_(_majorVersion: number) {
9999
for (const dep of ["libtinfo5", "libtinfo6"]) {
100100
/* eslint-disable no-await-in-loop */
101101
try {
102+
await installAptPack([{ name: dep }])
103+
} catch (_err) {
102104
try {
103-
await installAptPack([{ name: dep }])
104-
} catch (err) {
105105
if (dep === "libtinfo5") {
106106
// Manually install libtinfo5 if the package is not available
107-
info(`Failed to install ${dep} ${err}\nManually installing the package`)
107+
info(`Failed to install ${dep}\nManually installing the package`)
108108
const arch = x86_64.includes(process.arch)
109109
? "amd64"
110110
: arm64.includes(process.arch)
@@ -114,16 +114,17 @@ async function llvmBinaryDeps_(_majorVersion: number) {
114114
const fileName = `libtinfo5_6.3-2ubuntu0.1_${arch}.deb`
115115
const url = `http://launchpadlibrarian.net/666971015/${fileName}`
116116
const dl = new DownloaderHelper(url, tmpdir(), { fileName })
117-
dl.on("error", (dlErr) => {
118-
throw new Error(`Failed to download ${url}: ${dlErr}`)
117+
dl.on("error", async (dlErr) => {
118+
info(`Failed to download ${url}: ${dlErr}`)
119+
await dl.stop()
119120
})
120121
await dl.start()
121122
// Install the downloaded package via dpkg
122123
execRootSync("dpkg", ["-i", join(tmpdir(), fileName)])
123124
}
125+
} catch (_errFallback) {
126+
info(`Failed to install ${dep}. Ignoring`)
124127
}
125-
} catch (err) {
126-
info(`Failed to install ${dep}. Ignoring`)
127128
}
128129
/* eslint-enable no-await-in-loop */
129130
}

src/llvm/llvm_url.ts

+20-16
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { arm64, armv7, powerpc64le, sparc64, sparcv9, x86, x86_64 } from "../uti
77
import { hasDnf } from "../utils/env/hasDnf.js"
88
import { isUbuntu } from "../utils/env/isUbuntu.js"
99
import { ubuntuVersion } from "../utils/env/ubuntu_version.js"
10-
import { extractExe, extractTarByExe } from "../utils/setup/extract.js"
10+
import { extractExe, extractTarByExe, getArchiveType, getExtractFunction } from "../utils/setup/extract.js"
1111
import type { PackageInfo } from "../utils/setup/setupBin.js"
1212

1313
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
@@ -26,7 +26,7 @@ export async function getLLVMPackageInfo(
2626
binRelativeDir: "bin",
2727
binFileName: addExeExt("clang"),
2828
extractFunction: platform === "win32"
29-
? extractExe
29+
? getExtractFunction(getArchiveType(url))
3030
: (file: string, dest: string) => {
3131
return extractTarByExe(file, dest, 1)
3232
},
@@ -78,28 +78,32 @@ export async function getLLVMAssetURL(platform: string, arch: string, version: s
7878
}
7979

8080
async function getAssetKeywords(platform: string, arch: string) {
81-
const keywords: string[] = []
82-
const optionalKeywords: string[] = []
81+
const keywords: (string | string[])[] = []
82+
const optionalKeywords: (string | string[])[] = []
8383

8484
switch (platform) {
8585
case "win32": {
86-
optionalKeywords.push("windows", "Windows")
86+
// prefer exe over tar.xz for windows
87+
optionalKeywords.push(".exe", ".exe")
88+
const osKeywordsChoice: string[] = []
8789
if (x86_64.includes(arch)) {
88-
// prefer win64 keyword over x86_64 or x64
89-
optionalKeywords.push("win64", "win64", "win64", "x86_64", "X64")
90+
osKeywordsChoice.push("win64")
91+
optionalKeywords.push(["x86_64", "X64"])
9092
// TODO fallback to win32 if win64 is not available (e.g. for LLVM 3.6.2 and older)
9193
} else if (x86.includes(arch)) {
92-
keywords.push("win32")
94+
osKeywordsChoice.push("win32")
9395
} else if (arm64.includes(arch)) {
94-
keywords.push("woa64")
96+
osKeywordsChoice.push("woa64")
9597
} else {
9698
info(`Using arch ${arch} for LLVM`)
97-
keywords.push(arch)
99+
osKeywordsChoice.push(arch)
98100
}
101+
osKeywordsChoice.push("windows", "Windows")
102+
keywords.push(osKeywordsChoice)
99103
break
100104
}
101105
case "linux": {
102-
optionalKeywords.push("linux", "Linux")
106+
const osKeywordsChoice = ["linux", "Linux"]
103107

104108
if (isUbuntu()) {
105109
optionalKeywords.push("ubuntu")
@@ -117,7 +121,7 @@ async function getAssetKeywords(platform: string, arch: string) {
117121
}
118122

119123
if (x86_64.includes(arch)) {
120-
optionalKeywords.push("x86_64", "X64")
124+
keywords.push(["x86_64", "X64"])
121125
} else if (x86.includes(arch)) {
122126
keywords.push("x86")
123127
} else if (arm64.includes(arch)) {
@@ -132,17 +136,17 @@ async function getAssetKeywords(platform: string, arch: string) {
132136
info(`Using arch ${arch} for LLVM`)
133137
keywords.push(arch)
134138
}
135-
139+
keywords.push(osKeywordsChoice)
136140
break
137141
}
138142
case "darwin": {
139-
optionalKeywords.push("apple", "macos", "macOS")
143+
keywords.push(["apple", "macos", "macOS"])
140144

141145
if (x86_64.includes(arch)) {
142-
optionalKeywords.push("x86_64", "X64")
146+
optionalKeywords.push(["x86_64", "X64"])
143147
} else if (arm64.includes(arch)) {
144148
// allow falling back to x86_64 if arm64 is not available
145-
optionalKeywords.push("arm64", "ARM64")
149+
optionalKeywords.push(["arm64", "ARM64"])
146150
} else {
147151
info(`Using arch ${arch} for LLVM`)
148152
keywords.push(arch)

0 commit comments

Comments
 (0)