Skip to content

Commit 252db2e

Browse files
committed
feat: make graphviz installation separate
1 parent c96659e commit 252db2e

File tree

9 files changed

+87
-14
lines changed

9 files changed

+87
-14
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The package can be used locally or from CI services like GitHub Actions.
4040
- choco
4141
- brew
4242
- sevenzip
43+
- graphviz
4344

4445
# Usage
4546

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ inputs:
5454
doxygen:
5555
description: "The doxygen version to install."
5656
required: false
57+
graphviz:
58+
description: "The graphviz version to install."
59+
required: false
5760
cppcheck:
5861
description: "The cppcheck version to install."
5962
required: false

dist/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/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/doxygen/__tests__/doxygen.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { setupDoxygen } from "../doxygen"
22
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
33
import { InstallationInfo } from "../../utils/setup/setupBin"
44
import { getVersion } from "../../default_versions"
5+
import which from "which"
56

67
jest.setTimeout(300000)
78
describe("setup-doxygen", () => {
@@ -14,7 +15,8 @@ describe("setup-doxygen", () => {
1415
const installInfo = await setupDoxygen(getVersion("doxygen", undefined), directory, process.arch)
1516

1617
await testBin("doxygen", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
17-
await testBin("dot", ["-V"])
18+
19+
expect(which.sync("dot")).toBeDefined()
1820
})
1921

2022
afterAll(async () => {

src/doxygen/doxygen.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { setupChocoPack } from "../utils/setup/setupChocoPack"
66
import { addBinExtension } from "../utils/extension/extension"
77
import { extractTar } from "../utils/setup/extract"
88
import { warning } from "../utils/io/io"
9+
import { setupGraphviz } from "../graphviz/graphviz"
10+
import { getVersion } from "../default_versions"
911

1012
/** Get the platform data for cmake */
1113
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -30,17 +32,13 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
3032
switch (process.platform) {
3133
case "win32": {
3234
await setupChocoPack("doxygen.install", version)
33-
try {
34-
await setupChocoPack("graphviz", undefined)
35-
} catch (err) {
36-
warning(`${err}`)
37-
}
35+
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
3836
const binDir = activateWinDoxygen()
3937
return { binDir }
4038
}
4139
case "darwin": {
4240
const installationInfo = setupBrewPack("doxygen", undefined)
43-
setupBrewPack("graphviz", undefined)
41+
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
4442
return installationInfo
4543
}
4644
case "linux": {
@@ -52,7 +50,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
5250
warning(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
5351
installationInfo = await setupAptPack("doxygen", undefined)
5452
}
55-
await setupAptPack("graphviz", undefined)
53+
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
5654
return installationInfo
5755
}
5856
default: {
@@ -62,8 +60,14 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
6260
}
6361

6462
function activateWinDoxygen() {
65-
addPath("C:/Program Files/Graphviz/bin")
66-
const binDir = "C:/Program Files/doxygen/bin"
67-
addPath(binDir)
68-
return binDir
63+
switch (process.platform) {
64+
case "win32": {
65+
const binDir = "C:/Program Files/doxygen/bin"
66+
addPath(binDir)
67+
return binDir
68+
}
69+
default: {
70+
throw new Error(`Unsupported platform`)
71+
}
72+
}
6973
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { setupGraphviz } from "../graphviz"
2+
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
3+
import { InstallationInfo } from "../../utils/setup/setupBin"
4+
import { getVersion } from "../../default_versions"
5+
6+
jest.setTimeout(300000)
7+
describe("setup-graphviz", () => {
8+
let directory: string
9+
beforeAll(async () => {
10+
directory = await setupTmpDir("graphviz")
11+
})
12+
13+
it("should setup graphviz", async () => {
14+
const installInfo = await setupGraphviz(getVersion("graphviz", undefined), directory, process.arch)
15+
16+
await testBin("dot", ["-V"], (installInfo as InstallationInfo | undefined)?.binDir)
17+
})
18+
19+
afterAll(async () => {
20+
await cleanupTmpDir("graphviz")
21+
}, 100000)
22+
})

src/graphviz/graphviz.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { addPath } from "../utils/path/addPath"
2+
import { setupAptPack } from "../utils/setup/setupAptPack"
3+
import { InstallationInfo } from "../utils/setup/setupBin"
4+
import { setupBrewPack } from "../utils/setup/setupBrewPack"
5+
import { setupChocoPack } from "../utils/setup/setupChocoPack"
6+
7+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
8+
export function setupGraphviz(version: string, _setupDir: string, _arch: string) {
9+
switch (process.platform) {
10+
case "win32": {
11+
setupChocoPack("graphviz", version)
12+
return activateGraphviz()
13+
}
14+
case "darwin": {
15+
return setupBrewPack("graphviz", version)
16+
}
17+
case "linux": {
18+
return setupAptPack("graphviz", version)
19+
}
20+
default: {
21+
throw new Error(`Unsupported platform`)
22+
}
23+
}
24+
}
25+
26+
function activateGraphviz(): InstallationInfo {
27+
switch (process.platform) {
28+
case "win32": {
29+
const binDir = "C:/Program Files/Graphviz/bin"
30+
addPath(binDir)
31+
return { binDir }
32+
}
33+
default: {
34+
throw new Error(`Unsupported platform`)
35+
}
36+
}
37+
}

src/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { setupKcov } from "./kcov/kcov"
3131
import { addEnv } from "./utils/env/addEnv"
3232
import { setupSevenZip } from "./sevenzip/sevenzip"
3333
import { endGroup, startGroup } from "@actions/core"
34+
import { setupGraphviz } from "./graphviz/graphviz"
3435

3536
/** The setup functions */
3637
const setups = {
@@ -48,6 +49,7 @@ const setups = {
4849
brew: setupBrew,
4950
ccache: setupCcache,
5051
doxygen: setupDoxygen,
52+
graphviz: setupGraphviz,
5153
cppcheck: setupCppcheck,
5254
clangtidy: setupClangTools,
5355
clangformat: setupClangTools,
@@ -73,6 +75,7 @@ const tools: Array<keyof typeof setups> = [
7375
"opencppcoverage",
7476
"ccache",
7577
"doxygen",
78+
"graphviz",
7679
"cppcheck",
7780
"clangtidy",
7881
"clangformat",
@@ -304,6 +307,7 @@ All the available tools:
304307
--choco
305308
--brew
306309
--sevenzip
310+
--graphviz
307311
`)
308312
}
309313

0 commit comments

Comments
 (0)