Skip to content

Commit

Permalink
Add the OCaml problem matcher
Browse files Browse the repository at this point in the history
Signed-off-by: Sora Morimoto <[email protected]>
Co-authored-by: Yuzuki Aida <[email protected]>
  • Loading branch information
smorimoto and nzws committed Sep 16, 2023
1 parent 53b4999 commit 582494d
Show file tree
Hide file tree
Showing 11 changed files with 282 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to

## [unreleased]

### Added

- Add the OCaml problem matcher.

## [2.0.20]

### Changed
Expand Down
13 changes: 9 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions matchers/ocaml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"problemMatcher": [
{
"owner": "ocaml",
"pattern": [
{
"regexp": "^File\\s\"(.+)\",\\sline\\s(\\d+),\\scharacters\\s(\\d+)-(\\d+):$",
"file": 1,
"line": 2,
"column": 3
},
{
"regexp": "^(Error|Warning)\\s*(.*):\\s.*$",
"severity": 1,
"message": 2
}
]
}
]
}
3 changes: 2 additions & 1 deletion monorepo.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
{ "name": "lint-doc", "path": "lint-doc" },
{ "name": "lint-fmt", "path": "lint-fmt" },
{ "name": "lint-opam", "path": "lint-opam" },
{ "name": "matchers", "path": "matchers" },
{ "name": "eslint-config-ocaml", "path": "packages/eslint-config-ocaml" },
{ "name": "packages/lint-doc", "path": "packages/lint-doc" },
{ "name": "packages/lint-fmt", "path": "packages/lint-fmt" },
{ "name": "packages/lint-opam", "path": "packages/lint-opam" },
{ "name": "packages/setup-ocaml", "path": "packages/setup-ocaml" },
{ "name": "eslint-config-ocaml", "path": "packages/eslint-config-ocaml" },
{ "name": "root", "path": "." }
],
"settings": {
Expand Down
2 changes: 2 additions & 0 deletions packages/lint-doc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@ocaml/lint-doc",
"scripts": {
"clean": "shx rm -rf ../../lint-doc/dist",
"build": "ncc build src/index.ts --license=LICENSE.txt --out ../../lint-doc/dist",
"format": "prettier . --write",
"format:check": "prettier . --check",
Expand All @@ -19,6 +20,7 @@
"@vercel/ncc": "0.38.0",
"eslint": "8.49.0",
"prettier": "3.0.3",
"shx": "0.3.4",
"typescript": "5.2.2"
},
"private": true
Expand Down
2 changes: 2 additions & 0 deletions packages/lint-fmt/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@ocaml/lint-fmt",
"scripts": {
"clean": "shx rm -rf ../../lint-fmt/dist",
"build": "ncc build src/index.ts --license=LICENSE.txt --out ../../lint-fmt/dist",
"format": "prettier . --write",
"format:check": "prettier . --check",
Expand All @@ -19,6 +20,7 @@
"@vercel/ncc": "0.38.0",
"eslint": "8.49.0",
"prettier": "3.0.3",
"shx": "0.3.4",
"typescript": "5.2.2"
},
"private": true
Expand Down
2 changes: 2 additions & 0 deletions packages/lint-opam/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@ocaml/lint-opam",
"scripts": {
"clean": "shx rm -rf ../../lint-opam/dist",
"build": "ncc build src/index.ts --license=LICENSE.txt --out ../../lint-opam/dist",
"format": "prettier . --write",
"format:check": "prettier . --check",
Expand All @@ -19,6 +20,7 @@
"@vercel/ncc": "0.38.0",
"eslint": "8.49.0",
"prettier": "3.0.3",
"shx": "0.3.4",
"typescript": "5.2.2"
},
"private": true
Expand Down
5 changes: 4 additions & 1 deletion packages/setup-ocaml/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@ocaml/setup-ocaml",
"scripts": {
"clean": "shx rm -rf ../../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": "npm-run-all -p build:main build:post",
"format": "prettier . --write",
"format:check": "prettier . --check",
"lint": "TIMING=1 eslint .",
Expand Down Expand Up @@ -31,7 +32,9 @@
"@types/semver": "7.5.1",
"@vercel/ncc": "0.38.0",
"eslint": "8.49.0",
"npm-run-all": "4.1.5",
"prettier": "3.0.3",
"shx": "0.3.4",
"typescript": "5.2.2"
},
"private": true
Expand Down
18 changes: 14 additions & 4 deletions packages/setup-ocaml/src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -35,17 +36,18 @@ import { resolveCompiler } from "./version";

export async function installer() {
const platform = getPlatform();
const numberOfProcessors = os.cpus().length;
const isDebug = core.isDebug();
core.exportVariable("OPAMCLI", "2.0");
core.exportVariable("OPAMCOLOR", "always");
core.exportVariable("OPAMERRLOGLEN", 0);
core.exportVariable("OPAMJOBS", numberOfProcessors);
core.exportVariable("OPAMJOBS", os.cpus().length);
core.exportVariable("OPAMPRECISETRACKING", 1);
// [todo] remove this line once we unlock opam 2.2
// https://github.com/ocaml/opam/issues/3447
core.exportVariable("OPAMSOLVERTIMEOUT", 1000);
core.exportVariable("OPAMVERBOSE", isDebug);
core.exportVariable(
"OPAMVERBOSE",
core.isDebug() ? Number.POSITIVE_INFINITY : 0,
);
core.exportVariable("OPAMYES", 1);
if (platform === Platform.Win32) {
const opamRoot = path.join("D:", ".opam");
Expand Down Expand Up @@ -112,6 +114,14 @@ export async function installer() {
}
}
}
const ocamlMatcherPath = path.join(
// eslint-disable-next-line unicorn/prefer-module
__dirname,
"..",
"matchers",
"ocaml.json",
);
issueCommand("add-matcher", {}, ocamlMatcherPath);
await exec("opam", ["--version"]);
if (OPAM_DEPEXT) {
await exec("opam", ["depext", "--version"]);
Expand Down
5 changes: 4 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"dependsOn": ["^build"]
"dependsOn": ["clean", "^build"]
},
"clean": {
"cache": false
},
"format": {},
"format:check": {},
Expand Down
Loading

0 comments on commit 582494d

Please sign in to comment.