Skip to content

Commit a63071e

Browse files
authored
Merge pull request #363 from aminya/linux-arm-ci
ci: tests and executables for Linux arm + fix Doxygen, Sccache on Linux Arm + fix old LLVM on latest Ubuntu arm + fix apt installation fallbacks to latest
2 parents 1d64427 + 8115710 commit a63071e

31 files changed

+254
-114
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
os:
8787
- windows-2019
8888
- ubuntu-20.04
89+
- ubuntu-22.04-arm
8990
- macos-13 # x64
9091
- macos-14 # arm64
9192
steps:
@@ -143,7 +144,9 @@ jobs:
143144
os:
144145
- windows-2022
145146
- windows-2019
147+
- ubuntu-24.04-arm
146148
- ubuntu-24.04
149+
- ubuntu-22.04-arm
147150
- ubuntu-22.04
148151
- ubuntu-20.04
149152
- macos-15 # arm64

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,14 @@ Download the executable for your platform from [here](https://github.com/aminya/
7575
```shell
7676
# windows x64
7777
curl -o ./setup-cpp.exe -LJ "https://github.com/aminya/setup-cpp/releases/download/v1.1.1/setup-cpp-x64-windows.exe"
78-
7978
# linux x64
8079
curl -o ./setup-cpp -LJ "https://github.com/aminya/setup-cpp/releases/download/v1.1.1/setup-cpp-x64-linux"
81-
chmod +x ./setup-cpp
82-
80+
# linux arm64
81+
curl -o ./setup-cpp -LJ "https://github.com/aminya/setup-cpp/releases/download/v1.1.1/setup-cpp-arm64-linux"
8382
# macos arm64
8483
curl -o ./setup-cpp -LJ "https://github.com/aminya/setup-cpp/releases/download/v1.1.1/setup-cpp-arm64-macos"
85-
chmod +x ./setup-cpp
86-
8784
# macos x64
8885
curl -o ./setup-cpp -LJ "https://github.com/aminya/setup-cpp/releases/download/v1.1.1/setup-cpp-x64-macos"
89-
chmod +x ./setup-cpp
9086
```
9187

9288
An example that installs llvm, cmake, ninja, ccache, and vcpkg:
@@ -99,6 +95,7 @@ An example that installs llvm, cmake, ninja, ccache, and vcpkg:
9995

10096
```shell
10197
# linux/macos example
98+
chmod +x ./setup-cpp
10299
sudo ./setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
103100
source ~/.cpprc # activate cpp environment variables
104101
```

dist/legacy/github_brechtsanders_winlibs_mingw.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/legacy/github_llvm_llvm-project.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/legacy/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/legacy/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/legacy/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"ninja":"1.12.1","cmake":"3.31.4","task":"3.40.1","powershell":"7.4.5","pip":">=22.2.0","python":">=3.7.9","meson":{"linux":{"ubuntu":{"20":"1.6.1","18":"0.61.4","else":"0.61.4"},"else":"1.6.1"},"else":"1.6.1"},"kcov":{"linux":{"ubuntu":{"22":"42-binary","20":"40-binary","14":"40","else":"42"},"else":"42"},"else":"42"},"doxygen":{"linux":{"archlinux":"1.12.0-2","ubuntu":{"22":"1.12.0","18":"1.10.0","else":"1.10.0"},"else":"1.12.0"},"else":"1.12.0"},"gcc":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"mingw":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"gcovr":{"linux":{"ubuntu":{"20":"","18":"5.0","else":"5.0"},"else":""},"else":""},"nala":{"linux":{"ubuntu":{"22":"","21":"legacy","else":"legacy"},"else":""},"else":""},"llvm":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang++":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang-tidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clangtidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang-format":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clangformat":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"}}
1+
{"ninja":"1.12.1","cmake":"3.31.4","task":"3.40.1","powershell":"7.4.5","pip":">=22.2.0","python":">=3.7.9","meson":{"linux":{"ubuntu":{"20":"1.6.1","18":"0.61.4","else":"0.61.4"},"else":"1.6.1"},"else":"1.6.1"},"kcov":{"linux":{"ubuntu":{"22":"42-binary","20":"40-binary","14":"40","else":"42"},"else":"42"},"else":"42"},"doxygen":{"linux":{"archlinux":"1.13.2-1","ubuntu":{"22":"1.13.2","18":"1.10.0","else":"1.10.0"},"else":"1.13.2"},"else":"1.13.2"},"gcc":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"mingw":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"gcovr":{"linux":{"ubuntu":{"20":"","18":"5.0","else":"5.0"},"else":""},"else":""},"nala":{"linux":{"ubuntu":{"22":"","21":"legacy","else":"legacy"},"else":""},"else":""},"llvm":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang++":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang-tidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clangtidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang-format":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clangformat":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"}}

dist/modern/github_brechtsanders_winlibs_mingw.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/github_llvm_llvm-project.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"ninja":"1.12.1","cmake":"3.31.4","task":"3.40.1","powershell":"7.4.5","pip":">=22.2.0","python":">=3.7.9","meson":{"linux":{"ubuntu":{"20":"1.6.1","18":"0.61.4","else":"0.61.4"},"else":"1.6.1"},"else":"1.6.1"},"kcov":{"linux":{"ubuntu":{"22":"42-binary","20":"40-binary","14":"40","else":"42"},"else":"42"},"else":"42"},"doxygen":{"linux":{"archlinux":"1.12.0-2","ubuntu":{"22":"1.12.0","18":"1.10.0","else":"1.10.0"},"else":"1.12.0"},"else":"1.12.0"},"gcc":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"mingw":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"gcovr":{"linux":{"ubuntu":{"20":"","18":"5.0","else":"5.0"},"else":""},"else":""},"nala":{"linux":{"ubuntu":{"22":"","21":"legacy","else":"legacy"},"else":""},"else":""},"llvm":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang++":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang-tidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clangtidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang-format":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clangformat":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"}}
1+
{"ninja":"1.12.1","cmake":"3.31.4","task":"3.40.1","powershell":"7.4.5","pip":">=22.2.0","python":">=3.7.9","meson":{"linux":{"ubuntu":{"20":"1.6.1","18":"0.61.4","else":"0.61.4"},"else":"1.6.1"},"else":"1.6.1"},"kcov":{"linux":{"ubuntu":{"22":"42-binary","20":"40-binary","14":"40","else":"42"},"else":"42"},"else":"42"},"doxygen":{"linux":{"archlinux":"1.13.2-1","ubuntu":{"22":"1.13.2","18":"1.10.0","else":"1.10.0"},"else":"1.13.2"},"else":"1.13.2"},"gcc":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"mingw":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"gcovr":{"linux":{"ubuntu":{"20":"","18":"5.0","else":"5.0"},"else":""},"else":""},"nala":{"linux":{"ubuntu":{"22":"","21":"legacy","else":"legacy"},"else":""},"else":""},"llvm":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang++":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang-tidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clangtidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clang-format":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"},"clangformat":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"19.1.6"}}

packages/setup-apt/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-apt",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description": "Setup apt packages and repositories in Debian/Ubuntu-based distributions",
55
"repository": "https://github.com/aminya/setup-cpp",
66
"homepage": "https://github.com/aminya/setup-cpp/tree/master/packages/setup-apt",

packages/setup-apt/src/qualify-install.ts

Lines changed: 62 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { warning } from "ci-log"
1+
import { info } from "ci-log"
22
import escapeRegex from "escape-string-regexp"
33
import { execa } from "execa"
44
import { getAptEnv } from "./apt-env.js"
@@ -37,70 +37,97 @@ export async function qualifiedNeededAptPackage(pack: AptPackage, apt: string =
3737
return (await isAptPackInstalled(qualified)) ? undefined : qualified
3838
}
3939

40-
async function aptPackageType(apt: string, name: string, version: string | undefined): Promise<AptPackageType> {
41-
if (version !== undefined && version !== "") {
42-
const { stdout } = await execa("apt-cache", [
43-
"search",
44-
"--names-only",
45-
`^${escapeRegex(name)}-${escapeRegex(version)}$`,
46-
], { env: getAptEnv(apt), stdio: "pipe" })
47-
if (stdout.trim() !== "") {
40+
async function aptPackageType(
41+
apt: string,
42+
name: string,
43+
version: string | undefined,
44+
fallBackToLatest: boolean,
45+
): Promise<AptPackageType> {
46+
const hasVersion = version !== undefined && version !== ""
47+
const canFallBackToLatest = !hasVersion || fallBackToLatest
48+
49+
if (hasVersion) {
50+
// check if apt-get search can find the version
51+
if (await aptCacheSearchHasPackage(apt, name, version)) {
4852
return AptPackageType.NameDashVersion
4953
}
5054

51-
try {
52-
// check if apt-get show can find the version
53-
// eslint-disable-next-line @typescript-eslint/no-shadow
54-
const { stdout } = await execa("apt-cache", ["show", `${name}=${version}`], { env: getAptEnv(apt) })
55-
if (stdout.trim() === "") {
56-
return AptPackageType.NameEqualsVersion
57-
}
58-
} catch {
59-
// ignore
55+
// check if apt-get show can find the version
56+
if (await aptCacheShowHasPackage(apt, `${name}=${version}`)) {
57+
return AptPackageType.NameEqualsVersion
6058
}
6159
}
6260

63-
try {
64-
const { stdout: showStdout } = await execa("apt-cache", ["show", name], { env: getAptEnv(apt), stdio: "pipe" })
65-
if (showStdout.trim() !== "") {
66-
return AptPackageType.Name
61+
const logFallback = () => {
62+
if (hasVersion && fallBackToLatest) {
63+
info(`Could not find package ${name} ${version}. Falling back to latest version.`)
6764
}
68-
} catch {
69-
// ignore
65+
}
66+
67+
if (canFallBackToLatest && await aptCacheShowHasPackage(apt, name)) {
68+
// if the version is undefined or empty, return the name as a package name
69+
logFallback()
70+
return AptPackageType.Name
7071
}
7172

7273
// If apt-cache fails, update the repos and try again
7374
if (!updatedRepos) {
7475
updateAptReposMemoized(apt)
75-
return aptPackageType(apt, name, version)
76+
return aptPackageType(apt, name, version, fallBackToLatest)
7677
}
7778

78-
if (version === undefined || version === "") {
79+
if (canFallBackToLatest) {
7980
// if the version is undefined or empty, return the name as a package name
81+
logFallback()
8082
return AptPackageType.Name
8183
}
8284

8385
return AptPackageType.None
8486
}
8587

88+
async function aptCacheSearchHasPackage(apt: string, name: string, version: string) {
89+
try {
90+
const { stdout } = await execa("apt-cache", [
91+
"search",
92+
"--names-only",
93+
`^${escapeRegex(name)}-${escapeRegex(version)}$`,
94+
], { env: getAptEnv(apt), stdio: "pipe" })
95+
if (stdout.trim() !== "") {
96+
return true
97+
}
98+
} catch {
99+
// ignore
100+
}
101+
return false
102+
}
103+
104+
async function aptCacheShowHasPackage(apt: string, arg: string) {
105+
try {
106+
const { stdout } = await execa("apt-cache", ["show", arg], {
107+
env: getAptEnv(apt),
108+
stdio: "pipe",
109+
verbose: true,
110+
})
111+
if (stdout.trim() !== "") {
112+
return true
113+
}
114+
} catch {
115+
// ignore
116+
}
117+
return false
118+
}
119+
86120
async function getAptArg(apt: string, pack: AptPackage) {
87121
const { name, version, fallBackToLatest = false } = pack
88122

89-
const package_type = await aptPackageType(apt, name, version)
123+
const package_type = await aptPackageType(apt, name, version, fallBackToLatest)
90124
switch (package_type) {
91125
case AptPackageType.NameDashVersion:
92126
return `${name}-${version}`
93127
case AptPackageType.NameEqualsVersion:
94128
return `${name}=${version}`
95129
case AptPackageType.Name: {
96-
if (version === undefined || version === "") {
97-
return name
98-
}
99-
if (fallBackToLatest) {
100-
warning(`Could not find package '${name}' with version '${version}'. Installing the latest version.`)
101-
return name
102-
}
103-
throw new Error(`Could not find package '${name}' with version '${version}'`)
130+
return name
104131
}
105132
default:
106133
throw new Error(`Could not find package '${name}' ${version ?? "with unspecified version"}`)

packages/setup-brew/__tests__/brew.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { setupBrew } from "../src/index.js"
77

88
jest.setTimeout(300000)
99
describe("setup-brew", () => {
10-
if (process.platform === "win32") {
10+
if (
11+
process.platform === "win32"
12+
|| process.platform === "linux" && process.arch !== "x64"
13+
) {
1114
it.skip("should setup brew", () => {})
1215
return
1316
}

packages/setup-brew/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-brew",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Setup brew and brew packages",
55
"repository": "https://github.com/aminya/setup-cpp",
66
"homepage": "https://github.com/aminya/setup-cpp/tree/master/packages/setup-brew",

packages/setup-brew/src/install.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { tmpdir } from "os"
22
import { dirname, join } from "path"
3+
import { warning } from "ci-log"
34
import { type AddPathOptions, addPath } from "envosman"
45
import { execaSync } from "execa"
56
import { DownloaderHelper } from "node-downloader-helper"
@@ -21,9 +22,20 @@ export type SetupBrewOptions = {
2122
arch?: never
2223
}
2324

25+
/**
26+
* Install brew
27+
*
28+
* @param options - Options for adding the brew path to the rc file
29+
* @returns The path to the bin directory of brew if brew is installed, otherwise undefined if brew is not supported on the current platform
30+
*/
2431
export async function setupBrew(options: SetupBrewOptions = {}): Promise<InstallationInfo | undefined> {
25-
// brew is only available on darwin and linux
26-
if (!["darwin", "linux"].includes(process.platform)) {
32+
if (
33+
// brew is only available on darwin and linux
34+
!["darwin", "linux"].includes(process.platform)
35+
// brew is only supported on Linux x64
36+
|| (process.platform === "linux" && process.arch !== "x64")
37+
) {
38+
warning(`Brew is not supported on ${process.platform} ${process.arch}`)
2739
return undefined
2840
}
2941

src/asset-list.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { basename, dirname } from "path"
2+
import { execa } from "execa"
3+
import glob from "fast-glob"
4+
5+
async function main() {
6+
// create a github token from gh
7+
const token = await execa("gh", ["auth", "token"])
8+
process.env.GITHUB_TOKEN = token.stdout
9+
10+
const files = await glob("src/*/assets-list.ts", {
11+
onlyFiles: true,
12+
absolute: true,
13+
ignore: ["node_modules"],
14+
})
15+
16+
await Promise.all(files.map(async (file) => {
17+
console.log(`Updating ${basename(dirname(file))}`)
18+
19+
const jsFile = file.replace(".ts", ".js")
20+
await import(jsFile)
21+
}))
22+
}
23+
24+
main().catch((err) => {
25+
console.error(err)
26+
process.exit(1)
27+
})

src/bazel/__tests__/bazel.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { setupBazel } from "../bazel.js"
44

55
jest.setTimeout(300000)
66
describe("setup-bazel", () => {
7+
if (process.platform === "linux" && process.arch === "arm64") {
8+
it("should skip bazel tests on Linux arm64", () => {
9+
expect(true).toBe(true)
10+
})
11+
return
12+
}
713
it("should setup bazel", async () => {
814
const installInfo = await setupBazel("", "", process.arch)
915

src/bazel/bazel.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { execRootSync } from "admina"
1+
import { execRoot } from "admina"
22
import { addAptKeyViaURL, installAptPack } from "setup-apt"
33
import { installBrewPack } from "setup-brew"
4+
import { getDebArch } from "../utils/env/arch.js"
45
import { hasDnf } from "../utils/env/hasDnf.js"
56
import { isArch } from "../utils/env/isArch.js"
67
import { isUbuntu } from "../utils/env/isUbuntu.js"
@@ -24,17 +25,19 @@ export async function setupBazel(version: string, _setupDir: string, _arch: stri
2425
} else if (hasDnf()) {
2526
// https://bazel.build/install/redhat
2627
await setupDnfPack([{ name: "dnf-plugins-core" }])
27-
execRootSync("dnf", ["copr", "enable", "vbatts/bazel"])
28+
await execRoot("dnf", ["copr", "enable", "vbatts/bazel"])
2829
return setupDnfPack([{ name: "bazel4" }])
2930
} else if (isUbuntu()) {
3031
// https://bazel.build/install/ubuntu
3132
const keyFileName = await addAptKeyViaURL({
3233
fileName: "bazel-archive-keyring.gpg",
3334
keyUrl: "https://bazel.build/bazel-release.pub.gpg",
3435
})
35-
execRootSync("bash", [
36+
await execRoot("bash", [
3637
"-c",
37-
`echo "deb [arch=amd64 signed-by=${keyFileName}] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list`,
38+
`echo "deb [arch=${
39+
getDebArch(process.arch)
40+
} signed-by=${keyFileName}] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list`,
3841
])
3942
return installAptPack([{ name: "bazel", version }], true)
4043
}

0 commit comments

Comments
 (0)