Skip to content

Commit fb2a9a2

Browse files
authored
Merge pull request #294 from aminya/cmakelang [skip ci]
2 parents d7f5466 + c9bc540 commit fb2a9a2

File tree

16 files changed

+324
-80
lines changed

16 files changed

+324
-80
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
1717
| category | tools |
1818
| --------------------- | --------------------------------------------------------------------------- |
1919
| compiler and analyzer | llvm, gcc, msvc, apple-clang, vcvarsall, cppcheck, clang-tidy, clang-format |
20-
| build system | cmake, ninja, meson, make, task, bazel |
20+
| build system | cmake, ninja, meson, make, task, bazel, cmakelang, cmake-format, cmake-lint |
2121
| package manager | vcpkg, conan, choco, brew, nala |
2222
| cache | ccache, sccache |
2323
| documentation | doxygen, graphviz |

action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ inputs:
7070
cmake:
7171
description: "Wether to install cmake (true/false) or the specific version to install."
7272
required: false
73+
cmakelang:
74+
description: "Wether to install cmakelang (true/false) or the specific version to install."
75+
required: false
76+
cmake-lint:
77+
description: "Wether to install cmake-lint (true/false) or the specific version to install."
78+
required: false
79+
cmakelint:
80+
description: "Wether to install cmake-lint (true/false) or the specific version to install."
81+
required: false
82+
cmake-format:
83+
description: "Wether to install cmake-format (true/false) or the specific version to install."
84+
required: false
85+
cmakeformat:
86+
description: "Wether to install cmake-format (true/false) or the specific version to install."
87+
required: false
7388
ninja:
7489
description: "Wether to install ninja (true/false) or the specific version to install."
7590
required: false

cspell.config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ words:
2828
- choco
2929
- clangd
3030
- cmake
31+
- cmakeformat
3132
- cobertura
3233
- copr
3334
- CPATH

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/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
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/setup-apt/src/install.ts

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -68,55 +68,60 @@ const retryErrors = [
6868
* ```
6969
*/
7070
export async function installAptPack(packages: AptPackage[], update = false): Promise<InstallationInfo> {
71-
const apt: string = getApt()
72-
73-
for (const { name, version } of packages) {
74-
info(`Installing ${name} ${version ?? ""} via ${apt}`)
75-
}
71+
try {
72+
const apt: string = getApt()
7673

77-
// Update the repos if needed
78-
if (update) {
79-
updateAptReposMemoized(apt)
80-
}
74+
for (const { name, version } of packages) {
75+
info(`Installing ${name} ${version ?? ""} via ${apt}`)
76+
}
8177

82-
// Add the repos if needed
83-
await addRepositories(apt, packages)
78+
// Update the repos if needed
79+
if (update) {
80+
updateAptReposMemoized(apt)
81+
}
8482

85-
const needToInstall = await filterAndQualifyAptPackages(packages, apt)
83+
// Add the repos if needed
84+
await addRepositories(apt, packages)
8685

87-
if (needToInstall.length === 0) {
88-
info("All packages are already installed")
89-
return { binDir: "/usr/bin/" }
90-
}
86+
const needToInstall = await filterAndQualifyAptPackages(packages, apt)
9187

92-
// Initialize apt if needed
93-
await initAptMemoized(apt)
88+
if (needToInstall.length === 0) {
89+
info("All packages are already installed")
90+
return { binDir: "/usr/bin/" }
91+
}
9492

95-
try {
96-
// Add the keys if needed
97-
await addAptKeys(packages)
98-
99-
// Install
100-
execRootSync(apt, ["install", "--fix-broken", "-y", ...needToInstall], {
101-
...defaultExecOptions,
102-
env: getAptEnv(apt),
103-
})
104-
} catch (err) {
105-
if (isExecaError(err)) {
106-
if (retryErrors.some((error) => err.stderr.includes(error))) {
107-
warning(`Failed to install packages ${needToInstall}. Retrying...`)
108-
execRootSync(
109-
apt,
110-
["install", "--fix-broken", "-y", "-o", aptTimeout, ...needToInstall],
111-
{ ...defaultExecOptions, env: getAptEnv(apt) },
112-
)
93+
// Initialize apt if needed
94+
await initAptMemoized(apt)
95+
96+
try {
97+
// Add the keys if needed
98+
await addAptKeys(packages)
99+
100+
// Install
101+
execRootSync(apt, ["install", "--fix-broken", "-y", ...needToInstall], {
102+
...defaultExecOptions,
103+
env: getAptEnv(apt),
104+
})
105+
} catch (err) {
106+
if (isExecaError(err)) {
107+
if (retryErrors.some((error) => err.stderr.includes(error))) {
108+
warning(`Failed to install packages ${needToInstall}. Retrying...`)
109+
execRootSync(
110+
apt,
111+
["install", "--fix-broken", "-y", "-o", aptTimeout, ...needToInstall],
112+
{ ...defaultExecOptions, env: getAptEnv(apt) },
113+
)
114+
}
115+
} else {
116+
throw err
113117
}
114-
} else {
115-
throw err
116118
}
117-
}
118119

119-
return { binDir: "/usr/bin/" }
120+
return { binDir: "/usr/bin/" }
121+
} catch (err) {
122+
const msg = err instanceof Error ? `${err.message}\n${err.stack}` : String(err)
123+
throw new Error(`Failed to install apt packages: ${msg}`)
124+
}
120125
}
121126

122127
async function addRepositories(apt: string, packages: AptPackage[]) {

src/cli-options.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ All the available tools:
3535
"compiler and analyzer": {
3636
tools: "--llvm, --gcc, --msvc, --apple-clang, --vcvarsall, --cppcheck, --clang-tidy, --clang-format",
3737
},
38-
"build system": { tools: "--cmake, --ninja, --meson, --make, --task, --bazel" },
38+
"build system": {
39+
tools: "--cmake, --ninja, --meson, --make, --task, --bazel, --cmakelang, --cmake-lint, --cmake-format",
40+
},
3941
"package manager": { tools: "--vcpkg, --conan, --choco, --brew, --nala" },
4042
cache: { tools: "--ccache, --sccache" },
4143
documentation: { tools: "--doxygen, --graphviz" },
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ubuntuVersion } from "../../utils/env/ubuntu_version.js"
2+
import { testBin } from "../../utils/tests/test-helpers.js"
3+
import { getVersion } from "../../versions/versions.js"
4+
import { setupCmakelang } from "../cmakelang.js"
5+
6+
jest.setTimeout(300000)
7+
describe("setup-cmakelang", () => {
8+
it("should setup cmakelang", async () => {
9+
const installInfo = await setupCmakelang(getVersion("cmakelang", "true", await ubuntuVersion()), "", process.arch)
10+
await testBin("cmake-lint", ["--version"], installInfo.binDir)
11+
await testBin("cmake-format", ["--version"], installInfo.binDir)
12+
})
13+
})

0 commit comments

Comments
 (0)