Skip to content

Commit

Permalink
Merge pull request #35 from aminya/problem-matchers [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Feb 12, 2022
2 parents 2c73d7a + fa6c457 commit 016b16a
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 16 deletions.
2 changes: 2 additions & 0 deletions LICENSE.dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
- [get-cmake](https://github.com/lukka/get-cmake/blob/main/LICENSE.txt): 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:
```
Expand Down
17 changes: 17 additions & 0 deletions dist/gcc_matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "gcc",
"pattern": [
{
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}
18 changes: 18 additions & 0 deletions dist/msvc_matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "msvc",
"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 renamed without changes.
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.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
"setup_cpp": "./dist/setup_cpp.js"
},
"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 .",
"bump": "ncu -u -x execa",
"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",
"format": "prettier --write .",
"lint": "eslint . --fix",
Expand Down
17 changes: 16 additions & 1 deletion src/gcc/gcc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { info } from "@actions/core"
import { addPath } from "../utils/path/addPath"
import { existsSync } from "fs"
import { setupAptPack } from "../utils/setup/setupAptPack"
Expand All @@ -8,6 +7,10 @@ import semverMajor from "semver/functions/major"
import semverCoerce from "semver/functions/coerce"
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
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
export async function setupGcc(version: string, _setupDir: string, arch: string) {
Expand Down Expand Up @@ -113,4 +116,16 @@ async function activateGcc(version: string, binDir: string) {
}

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}`)
}
17 changes: 17 additions & 0 deletions src/gcc/gcc_matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "gcc",
"pattern": [
{
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}
22 changes: 19 additions & 3 deletions src/msvc/msvc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { error, info } from "@actions/core"
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"

type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string

Expand All @@ -24,9 +28,9 @@ export function setupMSVC(
info(`Checking if MSVC ${version} is already installed`)
let installed = false
try {
const path = findVcvarsall(version) as string
const vcvarsall_path = findVcvarsall(version) as string
installed = true
info(`Found the pre-installed version of MSVC at ${path}`)
info(`Found the pre-installed version of MSVC at ${vcvarsall_path}`)
} catch {
// not installed, try installing
}
Expand Down Expand Up @@ -61,4 +65,16 @@ export function setupMSVC(
}
// run vcvarsall.bat environment variables
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}`)
}
18 changes: 18 additions & 0 deletions src/msvc/msvc_matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "msvc",
"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
}
]
}
]
}
27 changes: 18 additions & 9 deletions src/python/actions_python.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import * as core from "@actions/core"
import * as finder from "setup-python/src/find-python"
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 { isGhes } from "setup-python/src/utils"

Expand All @@ -23,24 +27,29 @@ export async function setupActionsPython(version: string, _setupDir: string, arc
if (isPyPyVersion(version)) {
const installed = await finderPyPy.findPyPyVersion(version, arch)
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
core.info(
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
)
info(`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`)
} else {
const installed = await finder.findPythonVersion(version, arch)
pythonVersion = installed.version
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`)
info(`Successfully setup ${installed.impl} (${pythonVersion})`)
}

// const cache = core.getInput("cache")
// if (cache) {
// await cacheDependencies(cache, pythonVersion)
// }

// fails
// const matchersPath = path.join(__dirname, '../..', '.github');
// core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
// core.info(`##[add-matcher]${path.join("./.github", "python.json")}`)
if (isGitHubCI()) {
addPythonLoggingMatcher()
}

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}`)
}
18 changes: 18 additions & 0 deletions src/python/python_matcher.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}

0 comments on commit 016b16a

Please sign in to comment.