Merge pull request #38 from aminya/dot [skip ci]

This commit is contained in:
Amin Yahyaabadi 2022-02-13 20:34:25 -08:00 committed by GitHub
commit e2d3378c89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 140 additions and 37 deletions

View File

@ -17,7 +17,10 @@ jobs:
os:
- windows-2022
- windows-2019
- windows-2016
- ubuntu-20.04
- ubuntu-18.04
- macos-11
- macos-10.15
node:
- 14 # installed on the images
@ -56,10 +59,12 @@ jobs:
# Create self-contained executable that bundles Nodejs
- name: Create Executable
if: "contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-20.04') || contains(matrix.os, 'macos-11')"
run: |
pnpm run pack.exe
- name: Upload Executable
if: "contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-20.04') || contains(matrix.os, 'macos-11')"
uses: actions/upload-artifact@v2
with:
path: |
@ -74,6 +79,7 @@ jobs:
if: "!contains(github.event.head_commit.message, '[skip ci test]')"
run: |
pnpm run test
continue-on-error: ${{ contains(matrix.os, 'ubuntu-18.04') }}
Docker:
runs-on: ${{ matrix.os }}

View File

@ -40,6 +40,7 @@ The package can be used locally or from CI services like GitHub Actions.
- choco
- brew
- sevenzip
- graphviz
# Usage
@ -133,15 +134,15 @@ jobs:
fail-fast: false
matrix:
os:
- windows-2019
- windows-2022
- ubuntu-20.04
- macos-10.15
- macos-11
compiler:
- llvm
- gcc
# you can specify the version after `-` like `llvm-13.0.0`.
include:
- os: "windows-latest"
- os: "windows-2022"
compiler: "msvc"
steps:
- uses: actions/checkout@v2

View File

@ -54,6 +54,9 @@ inputs:
doxygen:
description: "The doxygen version to install."
required: false
graphviz:
description: "The graphviz version to install."
required: false
cppcheck:
description: "The cppcheck version to install."
required: false

View File

@ -6,9 +6,9 @@ ADD "./dist/" "/"
WORKDIR "/"
# run installation
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true
# reload the environment
CMD source ~/.profile
# reload the environment and print the versions
CMD source ~/.profile && clang --version && cmake --version && ninja --version && ccache --version && cppcheck --version && vcpkg --version && doxygen --version && dot --version && gcovr --version
ENTRYPOINT [ "/bin/sh" ]

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,7 @@
"build": "cross-env NODE_ENV=production parcel build --detailed-report && npm run copy.matchers",
"build.docker": "pnpm build && docker build -f ./building/docker/debian_node.dockerfile -t setup_cpp .",
"bump": "ncu -u -x execa",
"clean": "shx rm -rf dist exe",
"clean": "shx rm -rf .parcel-cache dist exe",
"copy.matchers": "shx cp ./src/gcc/gcc_matcher.json ./dist/ && shx cp ./src/msvc/msvc_matcher.json ./dist && shx cp ./src/python/python_matcher.json ./dist/ && shx cp ./src/llvm/llvm_matcher.json ./dist/ ",
"dev": "cross-env NODE_ENV=development parcel watch",
"format": "prettier --write .",

View File

@ -1,6 +1,7 @@
import { setupPipPack } from "../utils/setup/setupPipPack"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupConan(version: string | undefined, _setupDir: string, _arch: string) {
export async function setupConan(version: string | undefined, _setupDir: string, _arch: string) {
await setupPipPack("setuptools", "")
return setupPipPack("conan", version)
}

View File

@ -2,6 +2,7 @@ import { setupDoxygen } from "../doxygen"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { InstallationInfo } from "../../utils/setup/setupBin"
import { getVersion } from "../../default_versions"
import which from "which"
jest.setTimeout(300000)
describe("setup-doxygen", () => {
@ -10,10 +11,12 @@ describe("setup-doxygen", () => {
directory = await setupTmpDir("doxygen")
})
it("should setup doxygen", async () => {
it("should setup doxygen and dot", async () => {
const installInfo = await setupDoxygen(getVersion("doxygen", undefined), directory, process.arch)
await testBin("doxygen", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
expect(which.sync("dot")).toBeDefined()
})
afterAll(async () => {

View File

@ -6,6 +6,8 @@ import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { addBinExtension } from "../utils/extension/extension"
import { extractTar } from "../utils/setup/extract"
import { warning } from "../utils/io/io"
import { setupGraphviz } from "../graphviz/graphviz"
import { getVersion } from "../default_versions"
/** Get the platform data for cmake */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -30,17 +32,13 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
switch (process.platform) {
case "win32": {
await setupChocoPack("doxygen.install", version)
try {
await setupChocoPack("graphviz", undefined)
} catch (err) {
warning(`${err}`)
}
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
const binDir = activateWinDoxygen()
return { binDir }
}
case "darwin": {
const installationInfo = setupBrewPack("doxygen", undefined)
setupBrewPack("graphviz", undefined)
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
return installationInfo
}
case "linux": {
@ -52,7 +50,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
warning(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
installationInfo = await setupAptPack("doxygen", undefined)
}
await setupAptPack("graphviz", undefined)
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
return installationInfo
}
default: {
@ -62,8 +60,14 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
}
function activateWinDoxygen() {
addPath("C:/Program Files/Graphviz/bin")
const binDir = "C:/Program Files/doxygen/bin"
addPath(binDir)
return binDir
switch (process.platform) {
case "win32": {
const binDir = "C:/Program Files/doxygen/bin"
addPath(binDir)
return binDir
}
default: {
throw new Error(`Unsupported platform`)
}
}
}

View File

@ -0,0 +1,22 @@
import { setupGraphviz } from "../graphviz"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { InstallationInfo } from "../../utils/setup/setupBin"
import { getVersion } from "../../default_versions"
jest.setTimeout(300000)
describe("setup-graphviz", () => {
let directory: string
beforeAll(async () => {
directory = await setupTmpDir("graphviz")
})
it("should setup graphviz", async () => {
const installInfo = await setupGraphviz(getVersion("graphviz", undefined), directory, process.arch)
await testBin("dot", ["-V"], (installInfo as InstallationInfo | undefined)?.binDir)
})
afterAll(async () => {
await cleanupTmpDir("graphviz")
}, 100000)
})

37
src/graphviz/graphviz.ts Normal file
View File

@ -0,0 +1,37 @@
import { addPath } from "../utils/path/addPath"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { InstallationInfo } from "../utils/setup/setupBin"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupGraphviz(version: string, _setupDir: string, _arch: string) {
switch (process.platform) {
case "win32": {
setupChocoPack("graphviz", version)
return activateGraphviz()
}
case "darwin": {
return setupBrewPack("graphviz", version)
}
case "linux": {
return setupAptPack("graphviz", version)
}
default: {
throw new Error(`Unsupported platform`)
}
}
}
function activateGraphviz(): InstallationInfo {
switch (process.platform) {
case "win32": {
const binDir = "C:/Program Files/Graphviz/bin"
addPath(binDir)
return { binDir }
}
default: {
throw new Error(`Unsupported platform`)
}
}
}

View File

@ -47,6 +47,7 @@ export async function setupKcov(version: string, setupDir: string, arch: string)
switch (process.platform) {
case "linux": {
const installationInfo = await setupBin("kcov", version, getKcovPackageInfo, setupDir, arch)
await setupAptPack("libbinutils")
return installationInfo
}
default: {

View File

@ -244,17 +244,27 @@ async function getLLVMPackageInfo(version: string, platform: NodeJS.Platform, _a
}
export async function setupLLVM(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
const installationInfo = await setupBin("llvm", version, getLLVMPackageInfo, setupDir, arch)
const installationInfo = await _setupLLVM(version, setupDir, arch)
await activateLLVM(installationInfo.installDir ?? setupDir, version)
return installationInfo
}
export async function activateLLVM(directory: string, versionGiven: string) {
if (process.platform === "linux") {
// install llvm build dependencies
await setupAptPack("build-essential") // TODO(question) llvm needs ld. But does it need all the build-essential?
let didInit = false
async function _setupLLVM(version: string, setupDir: string, arch: string) {
const installationInfo = await setupBin("llvm", version, getLLVMPackageInfo, setupDir, arch)
if (!didInit) {
if (process.platform === "linux") {
// install llvm build dependencies
await setupAptPack("build-essential") // TODO(question) llvm needs ld. But does it need all the build-essential?
await setupAptPack("libtinfo-dev")
}
// eslint-disable-next-line require-atomic-updates
didInit = true
}
return installationInfo
}
export async function activateLLVM(directory: string, versionGiven: string) {
const version = semverCoerceIfInvalid(versionGiven)
const lib = path.join(directory, "lib")
@ -295,7 +305,7 @@ export function setupClangTools(version: string, setupDir: string, arch: string)
if (isGitHubCI()) {
addLLVMLoggingMatcher()
}
return setupBin("llvm", version, getLLVMPackageInfo, setupDir, arch)
return _setupLLVM(version, setupDir, arch)
}
function addLLVMLoggingMatcher() {

View File

@ -31,6 +31,7 @@ import { setupKcov } from "./kcov/kcov"
import { addEnv } from "./utils/env/addEnv"
import { setupSevenZip } from "./sevenzip/sevenzip"
import { endGroup, startGroup } from "@actions/core"
import { setupGraphviz } from "./graphviz/graphviz"
/** The setup functions */
const setups = {
@ -48,6 +49,7 @@ const setups = {
brew: setupBrew,
ccache: setupCcache,
doxygen: setupDoxygen,
graphviz: setupGraphviz,
cppcheck: setupCppcheck,
clangtidy: setupClangTools,
clangformat: setupClangTools,
@ -73,6 +75,7 @@ const tools: Array<keyof typeof setups> = [
"opencppcoverage",
"ccache",
"doxygen",
"graphviz",
"cppcheck",
"clangtidy",
"clangformat",
@ -304,6 +307,7 @@ All the available tools:
--choco
--brew
--sevenzip
--graphviz
`)
}

View File

@ -29,6 +29,8 @@ export type InstallationInfo = {
binDir: string
}
let didInit: boolean = false
/**
* A function that:
*
@ -83,11 +85,15 @@ export async function setupBin(
if (!existsSync(binDir) || !existsSync(binFile)) {
info(`Download and extract ${name} ${version}`)
if (process.platform === "linux") {
// extraction dependencies
await setupAptPack("unzip")
await setupAptPack("tar")
await setupAptPack("xz-utils")
if (!didInit) {
if (process.platform === "linux") {
// extraction dependencies
await setupAptPack("unzip")
await setupAptPack("tar")
await setupAptPack("xz-utils")
}
// eslint-disable-next-line require-atomic-updates
didInit = true
}
try {

View File

@ -9,6 +9,7 @@ import { isBinUptoDate } from "./version"
import { join } from "path"
import { getVersion } from "../../default_versions"
import { InstallationInfo } from "./setupBin"
import { setupAptPack } from "./setupAptPack"
let python: string | undefined
let binDir: string | undefined
@ -35,10 +36,14 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
tried = true
return setupPipPack(name, version)
}
}
if (process.platform === "win32") {
// https://github.com/pypa/pip/issues/10875#issuecomment-1030293005
execa.sync(python, ["-m", "pip", "install", "-U", "pip==21.3.1"], { stdio: "inherit" })
if (process.platform === "win32") {
// downgrade pip on Windows
// https://github.com/pypa/pip/issues/10875#issuecomment-1030293005
execa.sync(python, ["-m", "pip", "install", "-U", "pip==21.3.1"], { stdio: "inherit" })
} else if (process.platform === "linux") {
// ensure that pip is installed on Linux (happens when python is found but pip not installed)
await setupAptPack("python3-pip")
}
}
execa.sync(python, ["-m", "pip", "install", version !== undefined && version !== "" ? `${name}==${version}` : name], {