Skip to content

Commit

Permalink
feat: find LLVM assets based on platform/arch/version heuristics
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 8, 2024
1 parent 22bfbec commit e003dfd
Show file tree
Hide file tree
Showing 13 changed files with 361 additions and 434 deletions.
2 changes: 1 addition & 1 deletion cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ ignorePaths:
- patches/*.patch
- "**/github_*.json"
- "**/llvm_org_releases.json"

words:
- aarch
- aminya
- applellvm
- armv
- bazel
- bazelisk
- biome
Expand Down
2 changes: 1 addition & 1 deletion 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.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/__tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parseArgs } from "../cli-options.js"
import { getCompilerInfo } from "../compilers.js"
import type { Inputs } from "../tool.js"
import { DefaultLinuxVersion } from "../versions/default_versions.js"
import { DefaultUbuntuVersion } from "../versions/default_versions.js"
import { getVersion, syncVersions } from "../versions/versions.js"

jest.setTimeout(300000)
Expand Down Expand Up @@ -55,18 +55,18 @@ describe("getVersion", () => {
it("gcovr", () => {
expect(getVersion("gcovr", "5.0")).toBe("5.0")
if (process.platform === "linux") {
expect(getVersion("gcovr", "true", [22, 4])).toBe(DefaultLinuxVersion.gcovr![22])
expect(getVersion("gcovr", "true", [20, 4])).toBe(DefaultLinuxVersion.gcovr![20])
expect(getVersion("gcovr", "true", [18, 4])).toBe(DefaultLinuxVersion.gcovr![18])
expect(getVersion("gcovr", "true", [22, 4])).toBe(DefaultUbuntuVersion.gcovr![22])
expect(getVersion("gcovr", "true", [20, 4])).toBe(DefaultUbuntuVersion.gcovr![20])
expect(getVersion("gcovr", "true", [18, 4])).toBe(DefaultUbuntuVersion.gcovr![18])
}
})

it("llvm", () => {
expect(getVersion("llvm", "13.0.0")).toBe("13.0.0")
if (process.platform === "linux") {
expect(getVersion("llvm", "true", [20, 4])).toBe(DefaultLinuxVersion.llvm![20])
expect(getVersion("llvm", "true", [18, 4])).toBe(DefaultLinuxVersion.llvm![18])
expect(getVersion("llvm", "true", [16, 4])).toBe(DefaultLinuxVersion.llvm![16])
expect(getVersion("llvm", "true", [20, 4])).toBe(DefaultUbuntuVersion.llvm![20])
expect(getVersion("llvm", "true", [18, 4])).toBe(DefaultUbuntuVersion.llvm![18])
expect(getVersion("llvm", "true", [16, 4])).toBe(DefaultUbuntuVersion.llvm![16])
}
})
})
4 changes: 4 additions & 0 deletions src/gcc/gcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ async function getGccPackageInfo(version: string, platform: NodeJS.Platform, arc
},
)

if (asset === undefined) {
throw new Error(`No asset found for version ${version} and arch ${arch}`)
}

return {
binRelativeDir: "bin/",
binFileName: addExeExt("g++"),
Expand Down
48 changes: 8 additions & 40 deletions src/llvm/__tests__/llvm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,16 @@ import { fileURLToPath } from "url"
import * as io from "@actions/io"
import { execaSync } from "execa"
import { chmod } from "fs/promises"
import { isUrlOnline } from "is-url-online"
import { addExeExt } from "patha"
import { ubuntuVersion } from "../../utils/env/ubuntu_version.js"
import { getSpecificVersionAndUrl } from "../../utils/setup/version.js"
import { setupTmpDir, testBin } from "../../utils/tests/test-helpers.js"
import { getVersion } from "../../versions/versions.js"
import { setupClangFormat, setupClangTools, setupLLVM } from "../llvm.js"
import { VERSIONS, getLinuxUrl, getUrl } from "../llvm_url.js"
import { getLLVMAssetURL } from "../llvm_url.js"

const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))

jest.setTimeout(400000)
async function testUrl(version: string) {
const [specificVersion, url] = await getSpecificVersionAndUrl(VERSIONS, process.platform, version, getUrl)

if (!(await isUrlOnline(url))) {
throw new Error(`Failed to install Version: ${version} => ${specificVersion} \n URL: ${url}`)
}
}

describe("setup-llvm", () => {
let directory: string
Expand All @@ -31,38 +22,15 @@ describe("setup-llvm", () => {

it("Finds URL for ubuntu version", async () => {
expect(
await getSpecificVersionAndUrl(
VERSIONS,
"linux",
"13.0.0-ubuntu-16.04",
(_plantform, version) => getLinuxUrl(version),
),
).toStrictEqual([
"13.0.0-ubuntu-16.04",
await getLLVMAssetURL("linux", "x86_64", "13.0.0"),
).toStrictEqual(
"https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz",
])
)
expect(
await getSpecificVersionAndUrl(
VERSIONS,
"linux",
"13.0.1-ubuntu-18.04",
(_plantform, version) => getLinuxUrl(version),
),
).toStrictEqual([
"13.0.1-ubuntu-18.04",
await getLLVMAssetURL("linux", "x86_64", "13.0.1"),
).toStrictEqual(
"https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz",
])
expect(
await getSpecificVersionAndUrl(
VERSIONS,
"linux",
"13.0.0-ubuntu-20.04",
(_plantform, version) => getLinuxUrl(version),
),
).toStrictEqual([
"13.0.0-ubuntu-20.04",
"https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz",
])
)
})

it("Finds valid LLVM URLs", async () => {
Expand All @@ -89,7 +57,7 @@ describe("setup-llvm", () => {
"5",
"5.0.0",
"4",
].map((version) => testUrl(version)),
].map((version) => getLLVMAssetURL(process.platform, process.arch, version)),
)
})

Expand Down
Loading

0 comments on commit e003dfd

Please sign in to comment.