mirror of https://github.com/aminya/setup-cpp
feat: add logging integration for msvc, gcc, python
This commit is contained in:
parent
2c73d7a2ac
commit
b3eda4ff33
|
@ -4,6 +4,8 @@ setup-cpp reused some code from the following projects:
|
||||||
- [install-cmake](https://github.com/Symbitic/install-cmake/blob/master/LICENSE.md): MIT
|
- [install-cmake](https://github.com/Symbitic/install-cmake/blob/master/LICENSE.md): MIT
|
||||||
- [get-cmake](https://github.com/lukka/get-cmake/blob/main/LICENSE.txt): MIT
|
- [get-cmake](https://github.com/lukka/get-cmake/blob/main/LICENSE.txt): MIT
|
||||||
- [gha-setup-ninja](https://github.com/seanmiddleditch/gha-setup-ninja): MIT
|
- [gha-setup-ninja](https://github.com/seanmiddleditch/gha-setup-ninja): MIT
|
||||||
|
- [msvc-problem-matcher](https://github.com/ammaraskar/msvc-problem-matcher): Apache-2.0
|
||||||
|
- [gcc-problem-matcher](https://github.com/ammaraskar/gcc-problem-matcher): Apache-2.0
|
||||||
|
|
||||||
This package also uses the depedencies listed in package.json. You can get the list of their licenses using the following command:
|
This package also uses the depedencies listed in package.json. You can get the list of their licenses using the following command:
|
||||||
```
|
```
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "gcc-problem-matcher",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"message": 5
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "msvc-problem-matcher",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"code": 5,
|
||||||
|
"message": 6
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -12,10 +12,11 @@
|
||||||
"setup_cpp": "./dist/setup_cpp.js"
|
"setup_cpp": "./dist/setup_cpp.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cross-env NODE_ENV=production parcel build --detailed-report",
|
"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 .",
|
"build.docker": "pnpm build && docker build -f ./building/docker/debian_node.dockerfile -t setup_cpp .",
|
||||||
"bump": "ncu -u -x execa",
|
"bump": "ncu -u -x execa",
|
||||||
"clean": "shx rm -rf dist exe",
|
"clean": "shx rm -rf 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/",
|
||||||
"dev": "cross-env NODE_ENV=development parcel watch",
|
"dev": "cross-env NODE_ENV=development parcel watch",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"lint": "eslint . --fix",
|
"lint": "eslint . --fix",
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { info } from "@actions/core"
|
|
||||||
import { addPath } from "../utils/path/addPath"
|
import { addPath } from "../utils/path/addPath"
|
||||||
import { existsSync } from "fs"
|
import { existsSync } from "fs"
|
||||||
import { setupAptPack } from "../utils/setup/setupAptPack"
|
import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||||
|
@ -8,6 +7,10 @@ import semverMajor from "semver/functions/major"
|
||||||
import semverCoerce from "semver/functions/coerce"
|
import semverCoerce from "semver/functions/coerce"
|
||||||
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
|
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
|
||||||
import { addEnv } from "../utils/env/addEnv"
|
import { addEnv } from "../utils/env/addEnv"
|
||||||
|
import path from "path"
|
||||||
|
import { warning } from "../utils/io/io"
|
||||||
|
import { isGitHubCI } from "../utils/env/isci"
|
||||||
|
import { info } from "@actions/core"
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export async function setupGcc(version: string, _setupDir: string, arch: string) {
|
export async function setupGcc(version: string, _setupDir: string, arch: string) {
|
||||||
|
@ -113,4 +116,16 @@ async function activateGcc(version: string, binDir: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
await setupMacOSSDK()
|
await setupMacOSSDK()
|
||||||
|
|
||||||
|
if (isGitHubCI()) {
|
||||||
|
addGccLoggingMatcher()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addGccLoggingMatcher() {
|
||||||
|
const matcherPath = path.join(__dirname, "gcc_matcher.json")
|
||||||
|
if (!existsSync(matcherPath)) {
|
||||||
|
return warning("the gcc_matcher.json file does not exist in the same folder as setup_cpp.js")
|
||||||
|
}
|
||||||
|
info(`::add-matcher::${matcherPath}`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "gcc-problem-matcher",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"message": 5
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,9 +1,13 @@
|
||||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import { error, info } from "@actions/core"
|
import { info } from "@actions/core"
|
||||||
import { setupVCVarsall } from "../vcvarsall/vcvarsall"
|
import { setupVCVarsall } from "../vcvarsall/vcvarsall"
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { vsversion_to_versionnumber, findVcvarsall } from "msvc-dev-cmd/lib.js"
|
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"
|
||||||
|
|
||||||
type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string
|
type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string
|
||||||
|
|
||||||
|
@ -24,9 +28,9 @@ export function setupMSVC(
|
||||||
info(`Checking if MSVC ${version} is already installed`)
|
info(`Checking if MSVC ${version} is already installed`)
|
||||||
let installed = false
|
let installed = false
|
||||||
try {
|
try {
|
||||||
const path = findVcvarsall(version) as string
|
const vcvarsall_path = findVcvarsall(version) as string
|
||||||
installed = true
|
installed = true
|
||||||
info(`Found the pre-installed version of MSVC at ${path}`)
|
info(`Found the pre-installed version of MSVC at ${vcvarsall_path}`)
|
||||||
} catch {
|
} catch {
|
||||||
// not installed, try installing
|
// not installed, try installing
|
||||||
}
|
}
|
||||||
|
@ -61,4 +65,16 @@ export function setupMSVC(
|
||||||
}
|
}
|
||||||
// run vcvarsall.bat environment variables
|
// run vcvarsall.bat environment variables
|
||||||
setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
|
||||||
|
|
||||||
|
if (isGitHubCI()) {
|
||||||
|
addMSVCLoggingMatcher()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addMSVCLoggingMatcher() {
|
||||||
|
const matcherPath = path.join(__dirname, "msvc_matcher.json")
|
||||||
|
if (!existsSync(matcherPath)) {
|
||||||
|
return warning("the msvc_matcher.json file does not exist in the same folder as setup_cpp.js")
|
||||||
|
}
|
||||||
|
info(`::add-matcher::${matcherPath}`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "msvc-problem-matcher",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"code": 5,
|
||||||
|
"message": 6
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,6 +1,10 @@
|
||||||
import * as core from "@actions/core"
|
|
||||||
import * as finder from "setup-python/src/find-python"
|
import * as finder from "setup-python/src/find-python"
|
||||||
import * as finderPyPy from "setup-python/src/find-pypy"
|
import * as finderPyPy from "setup-python/src/find-pypy"
|
||||||
|
import { existsSync } from "fs"
|
||||||
|
import { warning } from "../utils/io/io"
|
||||||
|
import { info } from "@actions/core"
|
||||||
|
import path from "path"
|
||||||
|
import { isGitHubCI } from "../utils/env/isci"
|
||||||
// import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
|
// import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
|
||||||
// import { isGhes } from "setup-python/src/utils"
|
// import { isGhes } from "setup-python/src/utils"
|
||||||
|
|
||||||
|
@ -23,13 +27,11 @@ export async function setupActionsPython(version: string, _setupDir: string, arc
|
||||||
if (isPyPyVersion(version)) {
|
if (isPyPyVersion(version)) {
|
||||||
const installed = await finderPyPy.findPyPyVersion(version, arch)
|
const installed = await finderPyPy.findPyPyVersion(version, arch)
|
||||||
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
|
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
|
||||||
core.info(
|
info(`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`)
|
||||||
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
const installed = await finder.findPythonVersion(version, arch)
|
const installed = await finder.findPythonVersion(version, arch)
|
||||||
pythonVersion = installed.version
|
pythonVersion = installed.version
|
||||||
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`)
|
info(`Successfully setup ${installed.impl} (${pythonVersion})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// const cache = core.getInput("cache")
|
// const cache = core.getInput("cache")
|
||||||
|
@ -37,10 +39,17 @@ export async function setupActionsPython(version: string, _setupDir: string, arc
|
||||||
// await cacheDependencies(cache, pythonVersion)
|
// await cacheDependencies(cache, pythonVersion)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// fails
|
if (isGitHubCI()) {
|
||||||
// const matchersPath = path.join(__dirname, '../..', '.github');
|
addPythonLoggingMatcher()
|
||||||
// core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
|
}
|
||||||
// core.info(`##[add-matcher]${path.join("./.github", "python.json")}`)
|
|
||||||
|
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addPythonLoggingMatcher() {
|
||||||
|
const matcherPath = path.join(__dirname, "python_matcher.json")
|
||||||
|
if (!existsSync(matcherPath)) {
|
||||||
|
return warning("the python_matcher.json file does not exist in the same folder as setup_cpp.js")
|
||||||
|
}
|
||||||
|
info(`::add-matcher::${matcherPath}`)
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "python",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^\\s*File\\s\\\"(.*)\\\",\\sline\\s(\\d+),\\sin\\s(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"regexp": "^\\s*raise\\s(.*)\\(\\'(.*)\\'\\)$",
|
||||||
|
"message": 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue