Skip to content

Commit 016b16a

Browse files
authored
Merge pull request #35 from aminya/problem-matchers [skip ci]
2 parents 2c73d7a + fa6c457 commit 016b16a

13 files changed

+147
-16
lines changed

LICENSE.dependencies.txt

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ setup-cpp reused some code from the following projects:
44
- [install-cmake](https://github.com/Symbitic/install-cmake/blob/master/LICENSE.md): MIT
55
- [get-cmake](https://github.com/lukka/get-cmake/blob/main/LICENSE.txt): MIT
66
- [gha-setup-ninja](https://github.com/seanmiddleditch/gha-setup-ninja): MIT
7+
- [msvc-problem-matcher](https://github.com/ammaraskar/msvc-problem-matcher): Apache-2.0
8+
- [gcc-problem-matcher](https://github.com/ammaraskar/gcc-problem-matcher): Apache-2.0
79

810
This package also uses the depedencies listed in package.json. You can get the list of their licenses using the following command:
911
```

dist/gcc_matcher.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "gcc",
5+
"pattern": [
6+
{
7+
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"severity": 4,
12+
"message": 5
13+
}
14+
]
15+
}
16+
]
17+
}

dist/msvc_matcher.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "msvc",
5+
"pattern": [
6+
{
7+
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"severity": 4,
12+
"code": 5,
13+
"message": 6
14+
}
15+
]
16+
}
17+
]
18+
}
File renamed without changes.

dist/setup_cpp.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
"setup_cpp": "./dist/setup_cpp.js"
1313
},
1414
"scripts": {
15-
"build": "cross-env NODE_ENV=production parcel build --detailed-report",
15+
"build": "cross-env NODE_ENV=production parcel build --detailed-report && npm run copy.matchers",
1616
"build.docker": "pnpm build && docker build -f ./building/docker/debian_node.dockerfile -t setup_cpp .",
1717
"bump": "ncu -u -x execa",
1818
"clean": "shx rm -rf dist exe",
19+
"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/",
1920
"dev": "cross-env NODE_ENV=development parcel watch",
2021
"format": "prettier --write .",
2122
"lint": "eslint . --fix",

src/gcc/gcc.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { info } from "@actions/core"
21
import { addPath } from "../utils/path/addPath"
32
import { existsSync } from "fs"
43
import { setupAptPack } from "../utils/setup/setupAptPack"
@@ -8,6 +7,10 @@ import semverMajor from "semver/functions/major"
87
import semverCoerce from "semver/functions/coerce"
98
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
109
import { addEnv } from "../utils/env/addEnv"
10+
import path from "path"
11+
import { warning } from "../utils/io/io"
12+
import { isGitHubCI } from "../utils/env/isci"
13+
import { info } from "@actions/core"
1114

1215
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1316
export async function setupGcc(version: string, _setupDir: string, arch: string) {
@@ -113,4 +116,16 @@ async function activateGcc(version: string, binDir: string) {
113116
}
114117

115118
await setupMacOSSDK()
119+
120+
if (isGitHubCI()) {
121+
addGccLoggingMatcher()
122+
}
123+
}
124+
125+
function addGccLoggingMatcher() {
126+
const matcherPath = path.join(__dirname, "gcc_matcher.json")
127+
if (!existsSync(matcherPath)) {
128+
return warning("the gcc_matcher.json file does not exist in the same folder as setup_cpp.js")
129+
}
130+
info(`::add-matcher::${matcherPath}`)
116131
}

src/gcc/gcc_matcher.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "gcc",
5+
"pattern": [
6+
{
7+
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"severity": 4,
12+
"message": 5
13+
}
14+
]
15+
}
16+
]
17+
}

src/msvc/msvc.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { setupChocoPack } from "../utils/setup/setupChocoPack"
2-
import { error, info } from "@actions/core"
2+
import { info } from "@actions/core"
33
import { setupVCVarsall } from "../vcvarsall/vcvarsall"
44
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
55
// @ts-ignore
66
import { vsversion_to_versionnumber, findVcvarsall } from "msvc-dev-cmd/lib.js"
7+
import { isGitHubCI } from "../utils/env/isci"
8+
import path from "path"
9+
import { existsSync } from "fs"
10+
import { error, warning } from "../utils/io/io"
711

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

@@ -24,9 +28,9 @@ export function setupMSVC(
2428
info(`Checking if MSVC ${version} is already installed`)
2529
let installed = false
2630
try {
27-
const path = findVcvarsall(version) as string
31+
const vcvarsall_path = findVcvarsall(version) as string
2832
installed = true
29-
info(`Found the pre-installed version of MSVC at ${path}`)
33+
info(`Found the pre-installed version of MSVC at ${vcvarsall_path}`)
3034
} catch {
3135
// not installed, try installing
3236
}
@@ -61,4 +65,16 @@ export function setupMSVC(
6165
}
6266
// run vcvarsall.bat environment variables
6367
setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)
68+
69+
if (isGitHubCI()) {
70+
addMSVCLoggingMatcher()
71+
}
72+
}
73+
74+
function addMSVCLoggingMatcher() {
75+
const matcherPath = path.join(__dirname, "msvc_matcher.json")
76+
if (!existsSync(matcherPath)) {
77+
return warning("the msvc_matcher.json file does not exist in the same folder as setup_cpp.js")
78+
}
79+
info(`::add-matcher::${matcherPath}`)
6480
}

src/msvc/msvc_matcher.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "msvc",
5+
"pattern": [
6+
{
7+
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"severity": 4,
12+
"code": 5,
13+
"message": 6
14+
}
15+
]
16+
}
17+
]
18+
}

src/python/actions_python.ts

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import * as core from "@actions/core"
21
import * as finder from "setup-python/src/find-python"
32
import * as finderPyPy from "setup-python/src/find-pypy"
3+
import { existsSync } from "fs"
4+
import { warning } from "../utils/io/io"
5+
import { info } from "@actions/core"
6+
import path from "path"
7+
import { isGitHubCI } from "../utils/env/isci"
48
// import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
59
// import { isGhes } from "setup-python/src/utils"
610

@@ -23,24 +27,29 @@ export async function setupActionsPython(version: string, _setupDir: string, arc
2327
if (isPyPyVersion(version)) {
2428
const installed = await finderPyPy.findPyPyVersion(version, arch)
2529
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
26-
core.info(
27-
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
28-
)
30+
info(`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`)
2931
} else {
3032
const installed = await finder.findPythonVersion(version, arch)
3133
pythonVersion = installed.version
32-
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`)
34+
info(`Successfully setup ${installed.impl} (${pythonVersion})`)
3335
}
3436

3537
// const cache = core.getInput("cache")
3638
// if (cache) {
3739
// await cacheDependencies(cache, pythonVersion)
3840
// }
3941

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

4546
return undefined
4647
}
48+
49+
function addPythonLoggingMatcher() {
50+
const matcherPath = path.join(__dirname, "python_matcher.json")
51+
if (!existsSync(matcherPath)) {
52+
return warning("the python_matcher.json file does not exist in the same folder as setup_cpp.js")
53+
}
54+
info(`::add-matcher::${matcherPath}`)
55+
}

src/python/python_matcher.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "python",
5+
"pattern": [
6+
{
7+
"regexp": "^\\s*File\\s\\\"(.*)\\\",\\sline\\s(\\d+),\\sin\\s(.*)$",
8+
"file": 1,
9+
"line": 2
10+
},
11+
{
12+
"regexp": "^\\s*raise\\s(.*)\\(\\'(.*)\\'\\)$",
13+
"message": 2
14+
}
15+
]
16+
}
17+
]
18+
}

0 commit comments

Comments
 (0)