From 35619fdbcce3c55c7939baf350abe00727f17b2c Mon Sep 17 00:00:00 2001 From: Kevin Stillhammer Date: Sun, 8 Dec 2024 12:17:50 +0100 Subject: [PATCH] Add problem matchers (#26) Closes: #12 --- .github/matchers/check.json | 17 +++++++++++++++++ .github/matchers/format.json | 14 ++++++++++++++ dist/ruff-action/index.js | 6 ++++++ src/ruff-action.ts | 12 ++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 .github/matchers/check.json create mode 100644 .github/matchers/format.json diff --git a/.github/matchers/check.json b/.github/matchers/check.json new file mode 100644 index 0000000..73bc49a --- /dev/null +++ b/.github/matchers/check.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "ruff-check", + "pattern": [ + { + "regexp": "^Error: (.*):(\\d+):(\\d+): (\\w+) (.*)$", + "file": 1, + "line": 2, + "column": 3, + "code": 4, + "message": 5 + } + ] + } + ] +} diff --git a/.github/matchers/format.json b/.github/matchers/format.json new file mode 100644 index 0000000..23bddd1 --- /dev/null +++ b/.github/matchers/format.json @@ -0,0 +1,14 @@ +{ + "problemMatcher": [ + { + "owner": "ruff-format", + "pattern": [ + { + "regexp": "^(Would reformat):\\s*(.+)$", + "message": 1, + "file": 2 + } + ] + } + ] +} diff --git a/dist/ruff-action/index.js b/dist/ruff-action/index.js index caf4fec..9f31d51 100644 --- a/dist/ruff-action/index.js +++ b/dist/ruff-action/index.js @@ -34614,6 +34614,7 @@ function run() { const setupResult = yield setupRuff(platform, arch, inputs_1.version, inputs_1.checkSum, inputs_1.githubToken); addRuffToPath(setupResult.ruffDir); setOutputFormat(); + addMatchers(); core.setOutput("ruff-version", setupResult.version); core.info(`Successfully installed ruff version ${setupResult.version}`); yield runRuff(path.join(setupResult.ruffDir, "ruff"), inputs_1.args.split(" "), inputs_1.src.split(" ")); @@ -34650,6 +34651,11 @@ function setOutputFormat() { core.exportVariable("RUFF_OUTPUT_FORMAT", "github"); core.info("Set RUFF_OUTPUT_FORMAT to github"); } +function addMatchers() { + const matchersPath = path.join(__dirname, `..${path.sep}..`, ".github", "matchers"); + core.info(`##[add-matcher]${path.join(matchersPath, "check.json")}`); + core.info(`##[add-matcher]${path.join(matchersPath, "format.json")}`); +} function runRuff(ruffExecutablePath, args, src) { return __awaiter(this, void 0, void 0, function* () { const execArgs = [...args, ...src]; diff --git a/src/ruff-action.ts b/src/ruff-action.ts index ae28828..38424f0 100644 --- a/src/ruff-action.ts +++ b/src/ruff-action.ts @@ -36,6 +36,7 @@ async function run(): Promise { addRuffToPath(setupResult.ruffDir); setOutputFormat(); + addMatchers(); core.setOutput("ruff-version", setupResult.version); core.info(`Successfully installed ruff version ${setupResult.version}`); @@ -92,6 +93,17 @@ function setOutputFormat() { core.info("Set RUFF_OUTPUT_FORMAT to github"); } +function addMatchers(): void { + const matchersPath = path.join( + __dirname, + `..${path.sep}..`, + ".github", + "matchers", + ); + core.info(`##[add-matcher]${path.join(matchersPath, "check.json")}`); + core.info(`##[add-matcher]${path.join(matchersPath, "format.json")}`); +} + async function runRuff( ruffExecutablePath: string, args: string[],