From b71f25c2560a6929af2274c9692e37366e233435 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Wed, 13 Sep 2023 11:08:15 +0900 Subject: [PATCH] Add the OCaml problem matcher Signed-off-by: Sora Morimoto Co-authored-by: Yuzuki Aida --- CHANGELOG.md | 4 ++ dist/index.js | 9 ++++ dist/matchers/ocaml.json | 21 ++++++++ packages/setup-ocaml/package.json | 4 +- packages/setup-ocaml/src/installer.ts | 10 ++++ packages/setup-ocaml/src/matchers/ocaml.json | 20 ++++++++ yarn.lock | 50 ++++++++++++++++++-- 7 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 dist/matchers/ocaml.json create mode 100644 packages/setup-ocaml/src/matchers/ocaml.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 58941fa5..6d44b8d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to ## [unreleased] +### Added + +- Add the OCaml problem matcher. + ## [2.0.20] ### Changed diff --git a/dist/index.js b/dist/index.js index 829e39ec..8f9a6d6b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -102565,6 +102565,8 @@ const external_node_os_namespaceObject = require("node:os"); const external_node_path_namespaceObject = require("node:path"); ;// CONCATENATED MODULE: external "node:process" const external_node_process_namespaceObject = require("node:process"); +// EXTERNAL MODULE: ../../node_modules/@actions/core/lib/command.js +var command = __nccwpck_require__(29548); // EXTERNAL MODULE: ../../node_modules/@actions/exec/lib/exec.js var lib_exec = __nccwpck_require__(66473); // EXTERNAL MODULE: ../../node_modules/@actions/cache/lib/cache.js @@ -120781,6 +120783,7 @@ async function getOpamLocalPackages() { + async function installer() { const platform = getPlatform(); const numberOfProcessors = external_node_os_namespaceObject.cpus().length; @@ -120859,6 +120862,12 @@ async function installer() { } } } + lib_core.startGroup("Add the OCaml problem matcher"); + const ocamlMatcherPath = external_node_path_namespaceObject.join( + // eslint-disable-next-line unicorn/prefer-module + __dirname, "matchers", "ocaml.json"); + (0,command.issueCommand)("add-matcher", {}, ocamlMatcherPath); + lib_core.endGroup(); await (0,lib_exec.exec)("opam", ["--version"]); if (OPAM_DEPEXT) { await (0,lib_exec.exec)("opam", ["depext", "--version"]); diff --git a/dist/matchers/ocaml.json b/dist/matchers/ocaml.json new file mode 100644 index 00000000..8b0e4f06 --- /dev/null +++ b/dist/matchers/ocaml.json @@ -0,0 +1,21 @@ +{ + "problemMatcher": [ + { + "owner": "ocaml", + "pattern": [ + { + "regexp": "^File\\s\"(.+)\",\\sline\\s(\\d+),\\scharacters\\s(\\d+)-(\\d+):\\n((.|\\n)+?)(Error|Warning)\\s*(.*):\\s((.|\\n)+)$", + "kind": "location", + "file": 1, + "line": 2, + "column": 3, + "endLine": 2, + "endColumn": 4, + "severity": 7, + "code": 5, + "message": 10 + } + ] + } + ] +} diff --git a/packages/setup-ocaml/package.json b/packages/setup-ocaml/package.json index fc95e42d..45ff4403 100644 --- a/packages/setup-ocaml/package.json +++ b/packages/setup-ocaml/package.json @@ -1,9 +1,10 @@ { "name": "@ocaml/setup-ocaml", "scripts": { + "copy:matchers": "shx cp -r src/matchers ../../dist", "build:main": "ncc build src/index.ts --license=LICENSE.txt --out ../../dist", "build:post": "ncc build src/post.ts --license=LICENSE.txt --out ../../dist/post", - "build": "yarn build:main & yarn build:post", + "build": "yarn copy:matchers & yarn build:main & yarn build:post", "format": "prettier . --write", "format:check": "prettier . --check", "lint": "TIMING=1 eslint .", @@ -32,6 +33,7 @@ "@vercel/ncc": "0.38.0", "eslint": "8.49.0", "prettier": "3.0.3", + "shx": "0.3.4", "typescript": "5.2.2" }, "private": true diff --git a/packages/setup-ocaml/src/installer.ts b/packages/setup-ocaml/src/installer.ts index 446f2007..1734db61 100644 --- a/packages/setup-ocaml/src/installer.ts +++ b/packages/setup-ocaml/src/installer.ts @@ -3,6 +3,7 @@ import * as path from "node:path"; import * as process from "node:process"; import * as core from "@actions/core"; +import { issueCommand } from "@actions/core/lib/command"; import { exec } from "@actions/exec"; import { @@ -112,6 +113,15 @@ export async function installer() { } } } + core.startGroup("Add the OCaml problem matcher"); + const ocamlMatcherPath = path.join( + // eslint-disable-next-line unicorn/prefer-module + __dirname, + "matchers", + "ocaml.json", + ); + issueCommand("add-matcher", {}, ocamlMatcherPath); + core.endGroup(); await exec("opam", ["--version"]); if (OPAM_DEPEXT) { await exec("opam", ["depext", "--version"]); diff --git a/packages/setup-ocaml/src/matchers/ocaml.json b/packages/setup-ocaml/src/matchers/ocaml.json new file mode 100644 index 00000000..4347f522 --- /dev/null +++ b/packages/setup-ocaml/src/matchers/ocaml.json @@ -0,0 +1,20 @@ +{ + "problemMatcher": [ + { + "owner": "ocaml", + "pattern": [ + { + "regexp": "^File\\s\"(.+)\",\\sline\\s(\\d+),\\scharacters\\s(\\d+)-(\\d+):\\n((.|\\n)+?)(Error|Warning)\\s*(.*):\\s((.|\\n)+?(?=(File\\s\".+\",\\sline\\s\\d+,\\scharacters\\s\\d+-\\d+:))|(.|\\n)+)", + "file": 1, + "line": 2, + "endLine": 2, + "column": 3, + "endColumn": 4, + "code": 5, + "severity": 7, + "message": 9 + } + ] + } + ] +} diff --git a/yarn.lock b/yarn.lock index 91f1fce3..19c0c638 100644 --- a/yarn.lock +++ b/yarn.lock @@ -484,6 +484,7 @@ __metadata: eslint: 8.49.0 prettier: 3.0.3 semver: 7.5.4 + shx: 0.3.4 typescript: 5.2.2 yaml: 2.3.2 languageName: unknown @@ -2303,7 +2304,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^7.1.3, glob@npm:^7.1.4": +"glob@npm:^7.0.0, glob@npm:^7.1.3, glob@npm:^7.1.4": version: 7.2.3 resolution: "glob@npm:7.2.3" dependencies: @@ -2579,6 +2580,13 @@ __metadata: languageName: node linkType: hard +"interpret@npm:^1.0.0": + version: 1.4.0 + resolution: "interpret@npm:1.4.0" + checksum: 2e5f51268b5941e4a17e4ef0575bc91ed0ab5f8515e3cf77486f7c14d13f3010df9c0959f37063dcc96e78d12dc6b0bb1b9e111cdfe69771f4656d2993d36155 + languageName: node + linkType: hard + "ip@npm:^2.0.0": version: 2.0.0 resolution: "ip@npm:2.0.0" @@ -3114,7 +3122,7 @@ __metadata: languageName: node linkType: hard -"minimist@npm:^1.2.6": +"minimist@npm:^1.2.3, minimist@npm:^1.2.6": version: 1.2.8 resolution: "minimist@npm:1.2.8" checksum: 75a6d645fb122dad29c06a7597bddea977258957ed88d7a6df59b5cd3fe4a527e253e9bbf2e783e4b73657f9098b96a5fe96ab8a113655d4109108577ecf85b0 @@ -3707,6 +3715,15 @@ __metadata: languageName: node linkType: hard +"rechoir@npm:^0.6.2": + version: 0.6.2 + resolution: "rechoir@npm:0.6.2" + dependencies: + resolve: ^1.1.6 + checksum: fe76bf9c21875ac16e235defedd7cbd34f333c02a92546142b7911a0f7c7059d2e16f441fe6fb9ae203f459c05a31b2bcf26202896d89e390eda7514d5d2702b + languageName: node + linkType: hard + "regenerator-runtime@npm:^0.14.0": version: 0.14.0 resolution: "regenerator-runtime@npm:0.14.0" @@ -3759,7 +3776,7 @@ __metadata: languageName: node linkType: hard -"resolve@npm:^1.10.0, resolve@npm:^1.22.4": +"resolve@npm:^1.1.6, resolve@npm:^1.10.0, resolve@npm:^1.22.4": version: 1.22.4 resolution: "resolve@npm:1.22.4" dependencies: @@ -3772,7 +3789,7 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@^1.10.0#~builtin, resolve@patch:resolve@^1.22.4#~builtin": +"resolve@patch:resolve@^1.1.6#~builtin, resolve@patch:resolve@^1.10.0#~builtin, resolve@patch:resolve@^1.22.4#~builtin": version: 1.22.4 resolution: "resolve@patch:resolve@npm%3A1.22.4#~builtin::version=1.22.4&hash=c3c19d" dependencies: @@ -3933,6 +3950,31 @@ __metadata: languageName: node linkType: hard +"shelljs@npm:^0.8.5": + version: 0.8.5 + resolution: "shelljs@npm:0.8.5" + dependencies: + glob: ^7.0.0 + interpret: ^1.0.0 + rechoir: ^0.6.2 + bin: + shjs: bin/shjs + checksum: 7babc46f732a98f4c054ec1f048b55b9149b98aa2da32f6cf9844c434b43c6251efebd6eec120937bd0999e13811ebd45efe17410edb3ca938f82f9381302748 + languageName: node + linkType: hard + +"shx@npm:0.3.4": + version: 0.3.4 + resolution: "shx@npm:0.3.4" + dependencies: + minimist: ^1.2.3 + shelljs: ^0.8.5 + bin: + shx: lib/cli.js + checksum: 0aa168bfddc11e3fe8943cce2e0d2d8514a560bd58cf2b835b4351ba03f46068f7d88286c2627f4b85604e81952154c43746369fb3f0d60df0e3b511f465e5b8 + languageName: node + linkType: hard + "side-channel@npm:^1.0.4": version: 1.0.4 resolution: "side-channel@npm:1.0.4"