Skip to content

Commit

Permalink
Merge pull request #67 from aminya/notice [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored May 3, 2022
2 parents 27b4144 + 455c907 commit 49248d2
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
- ubuntu-20.04
container:
- "ubuntu_node.dockerfile"
- "ubuntu_stable_node.dockerfile"
- "ubuntu_20.04_node.dockerfile"
node:
- 14
pnpm:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 "/"
Expand All @@ -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/
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dev/docker/ubuntu.dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#### Base Image
FROM ubuntu:devel AS base
FROM ubuntu:22.04 AS base

# add setup_cpp
WORKDIR "/"
Expand All @@ -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/
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions dev/docker/ubuntu_node.dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion dist/setup_cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/doxygen/doxygen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand Down
17 changes: 3 additions & 14 deletions src/gcc/gcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/llvm/llvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 6 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -290,15 +289,15 @@ 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 }
}
}
return { compiler, version: undefined }
}

function printHelp() {
core.info(`
info(`
setup_cpp [options]
setup_cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/make/make.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/msvc/msvc.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
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
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

Expand Down
7 changes: 3 additions & 4 deletions src/python/python.ts
Original file line number Diff line number Diff line change
@@ -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()) {
Expand All @@ -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)
}
}
Expand Down Expand Up @@ -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)
}
6 changes: 3 additions & 3 deletions src/utils/env/addEnv.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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.`)
}
}

Expand All @@ -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.`)
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/utils/io/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
5 changes: 3 additions & 2 deletions src/vcpkg/vcpkg.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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" })
Expand Down
2 changes: 1 addition & 1 deletion src/vcvarsall/vcvarsall.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit 49248d2

Please sign in to comment.