Merge pull request #67 from aminya/notice [skip ci]

This commit is contained in:
Amin Yahyaabadi 2022-05-02 22:46:59 -07:00 committed by GitHub
commit 49248d2ce6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 42 additions and 51 deletions

View File

@ -89,7 +89,7 @@ jobs:
- ubuntu-20.04
container:
- "ubuntu_node.dockerfile"
- "ubuntu_stable_node.dockerfile"
- "ubuntu_20.04_node.dockerfile"
node:
- 14
pnpm:

View File

@ -180,7 +180,7 @@ Here is an example for using setup_cpp to make a builder image that has the Cpp
```dockerfile
#### Base Image
FROM ubuntu:devel AS base
FROM ubuntu:22.04 AS base
# add setup_cpp
WORKDIR "/"
@ -203,7 +203,7 @@ RUN bash -c 'source ~/.cpprc \
&& make build'
### Running environment
# use a distroless image or ubuntu:devel if you wish
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
@ -258,7 +258,7 @@ The following gives an example for setting up a C++ environment inside GitLab pi
.gitlab-ci.yaml
```yaml
image: ubuntu:devel
image: ubuntu:22.04
stages:
- test

View File

@ -1,5 +1,5 @@
#### Base Image
FROM ubuntu:devel AS base
FROM ubuntu:22.04 AS base
# add setup_cpp
WORKDIR "/"
@ -22,7 +22,7 @@ RUN bash -c 'source ~/.cpprc \
&& make build'
### Running environment
# use a distroless image or ubuntu:devel if you wish
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/

View File

@ -1,4 +1,4 @@
FROM ubuntu:devel AS base
FROM ubuntu:22.04 AS base
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends nodejs
@ -21,7 +21,7 @@ RUN bash -c 'source ~/.cpprc \
&& make build'
### Running environment
# use a distroless image or ubuntu:devel if you wish
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/

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

@ -12,12 +12,12 @@
"setup_cpp": "./dist/setup_cpp.js"
},
"scripts": {
"build": "run-p test.tsc build.parcel copy.matchers",
"build": "shx rm -rf dist/ && shx mkdir ./dist && run-p test.tsc build.parcel copy.matchers",
"build.docker": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp .",
"build.parcel": "shx rm -rf ./dist/*.js ./dist/*.js.map && cross-env NODE_ENV=production parcel build --detailed-report",
"build.parcel": "cross-env NODE_ENV=production parcel build --detailed-report",
"bump": "ncu -u -x execa && pnpm update",
"clean": "shx rm -rf .parcel-cache dist exe",
"copy.matchers": "shx rm -rf ./dist/*.json && 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/ ",
"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 .",
"lint": "eslint . --fix",

View File

@ -5,7 +5,7 @@ import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { addBinExtension } from "../utils/extension/extension"
import { extractTar } from "../utils/setup/extract"
import { info } from "../utils/io/io"
import { notice } from "../utils/io/io"
import { setupGraphviz } from "../graphviz/graphviz"
import { getVersion } from "../default_versions"
@ -47,7 +47,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
} catch (err) {
info(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
installationInfo = setupAptPack("doxygen", undefined)
}
await setupGraphviz(getVersion("graphviz", undefined), "", arch)

View File

@ -7,9 +7,8 @@ import semverMajor from "semver/functions/major"
import semverCoerce from "semver/functions/coerce"
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
import path from "path"
import { warning } from "../utils/io/io"
import { warning, info } from "../utils/io/io"
import { isGitHubCI } from "../utils/env/isci"
import { info } from "@actions/core"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupGcc(version: string, _setupDir: string, arch: string) {
@ -37,19 +36,11 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
}
case "linux": {
if (arch === "x64") {
setupAptPack("gcc", version, [
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial main",
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe",
"ppa:ubuntu-toolchain-r/test",
])
setupAptPack("gcc", version, ["ppa:ubuntu-toolchain-r/test"])
binDir = setupAptPack("g++", version, []).binDir
} else {
info(`Install g++-multilib because gcc for ${arch} was requested`)
setupAptPack("gcc-multilib", version, [
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial main",
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe",
"ppa:ubuntu-toolchain-r/test",
])
setupAptPack("gcc-multilib", version, ["ppa:ubuntu-toolchain-r/test"])
binDir = setupAptPack("g++-multilib", version, []).binDir
}
break
@ -59,8 +50,6 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
// case "none": {
// if (arch === "arm" || arch === "arm64") {
// return setupAptPack("gcc-arm-none-eabi", version, [
// "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main",
// "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe",
// "ppa:ubuntu-toolchain-r/test",
// ])
// } else {

View File

@ -8,9 +8,9 @@ import { getSpecificVersionAndUrl, getVersions, semverCoerceIfInvalid } from "..
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
import { addBinExtension } from "../utils/extension/extension"
import { addEnv } from "../utils/env/addEnv"
import { info, setOutput } from "@actions/core"
import { setOutput } from "@actions/core"
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
import { warning } from "../utils/io/io"
import { info, warning } from "../utils/io/io"
import { existsSync } from "fs"
import { isGitHubCI } from "../utils/env/isci"
import { setupGcc } from "../gcc/gcc"

View File

@ -1,4 +1,4 @@
import * as core from "@actions/core"
import { getInput, endGroup, startGroup, notice } from "@actions/core"
import { setupBrew } from "./brew/brew"
import { setupCcache } from "./ccache/ccache"
import { setupMake } from "./make/make"
@ -40,7 +40,6 @@ import { setupVCVarsall } from "./vcvarsall/vcvarsall"
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 */
@ -218,7 +217,7 @@ export async function main(args: string[]): Promise<number> {
}
case "appleclang":
case "applellvm": {
core.info("Assuming apple-clang is already installed")
notice("Assuming apple-clang is already installed")
addEnv("CC", "clang")
addEnv("CXX", "clang++")
successMessages.push(getSuccessMessage("apple-clang", undefined))
@ -249,7 +248,7 @@ export async function main(args: string[]): Promise<number> {
successMessages.forEach((tool) => success(tool))
errorMessages.forEach((tool) => error(tool))
core.info("setup_cpp finished")
info("setup_cpp finished")
if (!isGitHubCI()) {
switch (process.platform) {
@ -290,7 +289,7 @@ export function getCompilerInfo(maybeCompiler: string) {
if (semverValid(maybeVersion) !== null) {
return { compiler, version: maybeVersion }
} else {
core.info(`Invalid semver version ${maybeVersion} used for the compiler.`)
notice(`Invalid semver version ${maybeVersion} used for the compiler.`)
return { compiler, version: maybeVersion }
}
}
@ -298,7 +297,7 @@ export function getCompilerInfo(maybeCompiler: string) {
}
function printHelp() {
core.info(`
info(`
setup_cpp [options]
setup_cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
@ -340,7 +339,7 @@ All the available tools:
/** Get an object from github actions */
function maybeGetInput(key: string) {
const value = core.getInput(key.toLowerCase())
const value = getInput(key.toLowerCase())
if (value !== "false" && value !== "") {
return value
}

View File

@ -1,4 +1,4 @@
import { addPath } from "@actions/core"
import { addPath } from "../utils/env/addEnv"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"

View File

@ -1,5 +1,4 @@
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { info } from "@actions/core"
import { setupVCVarsall } from "../vcvarsall/vcvarsall"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
@ -7,7 +6,7 @@ import { vsversion_to_versionnumber, findVcvarsall } from "msvc-dev-cmd/lib.js"
import { isGitHubCI } from "../utils/env/isci"
import path from "path"
import { existsSync } from "fs"
import { error, warning } from "../utils/io/io"
import { error, info, warning } from "../utils/io/io"
type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string

View File

@ -1,10 +1,9 @@
import * as core from "@actions/core"
import { addPath } from "../utils/env/addEnv"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { isGitHubCI } from "../utils/env/isci"
import { warning } from "@actions/core"
import { warning, info } from "../utils/io/io"
export async function setupPython(version: string, setupDir: string, arch: string) {
if (!isGitHubCI()) {
@ -15,7 +14,7 @@ export async function setupPython(version: string, setupDir: string, arch: strin
const { setupActionsPython } = await import("./actions_python")
return setupActionsPython(version, setupDir, arch)
} catch (err) {
warning(err as Error)
warning((err as Error).toString())
return setupPythonViaSystem(version, setupDir, arch)
}
}
@ -50,6 +49,6 @@ export function setupPythonViaSystem(version: string, setupDir: string, _arch: s
}
function activateWinPython(binDir: string) {
core.info(`Add ${binDir} to PATH`)
info(`Add ${binDir} to PATH`)
addPath(binDir)
}

View File

@ -1,4 +1,4 @@
import { exportVariable, addPath as ghAddPath, info } from "@actions/core"
import { exportVariable, addPath as ghAddPath, info, setFailed } from "@actions/core"
import { isGitHubCI } from "./isci"
import { untildify_user as untildify } from "../path/untildify"
import { appendFileSync, existsSync, readFileSync } from "fs"
@ -21,7 +21,7 @@ export function addEnv(name: string, val: string | undefined) {
} catch (err2) {
error(err2 as Error)
}
error(`Failed to export environment variable ${name}=${val}. You should add it manually.`)
setFailed(`Failed to export environment variable ${name}=${val}. You should add it manually.`)
}
}
@ -41,7 +41,7 @@ export function addPath(path: string) {
} catch (err2) {
error(err2 as Error)
}
error(`Failed to add ${path} to the percistent PATH. You should add it manually.`)
setFailed(`Failed to add ${path} to the percistent PATH. You should add it manually.`)
}
}

View File

@ -13,6 +13,10 @@ export function warning(msg: string) {
return isGitHubCI() ? core.warning(msg) : console.log(`\x1b[33m${msg}\x1b[0m`)
}
export function notice(msg: string) {
return isGitHubCI() ? core.notice(msg) : console.log(`\x1b[94m${msg}\x1b[0m`)
}
export function info(msg: string) {
return isGitHubCI() ? core.info(msg) : console.log(msg)
}

View File

@ -1,11 +1,12 @@
import { addPath, warning } from "@actions/core"
import execa from "execa"
import { existsSync } from "fs"
import { dirname, join } from "path"
import which from "which"
import { addPath } from "../utils/env/addEnv"
import { isRoot } from "../utils/env/sudo"
import { execSudo } from "../utils/exec/sudo"
import { addShellExtension, addShellHere } from "../utils/extension/extension"
import { notice } from "../utils/io/io"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { InstallationInfo } from "../utils/setup/setupBin"
@ -27,7 +28,7 @@ export function setupVcpkg(_version: string, setupDir: string, _arch: string): I
if (!existsSync(join(setupDir, addShellExtension("bootstrap-vcpkg")))) {
execa.sync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir), stdio: "inherit" })
} else {
warning(`Vcpkg folder already exists at ${setupDir}`)
notice(`Vcpkg folder already exists at ${setupDir}. This might mean that ~/vcpkg is restored from the cache.`)
}
execa.sync(addShellExtension(addShellHere("bootstrap-vcpkg")), { cwd: setupDir, shell: true, stdio: "inherit" })

View File

@ -1,9 +1,9 @@
import { info } from "@actions/core"
import { existsSync } from "fs"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { setupMSVCDevCmd } from "msvc-dev-cmd/lib.js"
import { addEnv } from "../utils/env/addEnv"
import { info } from "../utils/io/io"
function getArch(arch: string): string {
switch (arch) {