From fca94bcdd73f16fc2b84448fa05b02c63ccbf502 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Feb 2026 19:11:44 +0800 Subject: [PATCH] Hide `add-matcher` and `remove-matcher` from actions job logs (#36520) Hides `::add-matcher::`, `##[add-matcher]` and `::remove-matcher` in job step logs. These are used to configure regex matchers to detect lines that should trigger annotation comments on the UI, currently unsupported by Gitea and these have no relevance to the user. --------- Signed-off-by: silverwind Signed-off-by: wxiaoguang --- web_src/js/components/RepoActionView.test.ts | 22 ++++++++++++++++++++ web_src/js/components/RepoActionView.vue | 17 ++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 web_src/js/components/RepoActionView.test.ts diff --git a/web_src/js/components/RepoActionView.test.ts b/web_src/js/components/RepoActionView.test.ts new file mode 100644 index 0000000000..d7b9a7de2a --- /dev/null +++ b/web_src/js/components/RepoActionView.test.ts @@ -0,0 +1,22 @@ +import {shouldHideLine, type LogLine} from './RepoActionView.vue'; + +test('shouldHideLine', () => { + expect(([ + {index: 1, message: 'Starting build process', timestamp: 1000}, + {index: 2, message: '::add-matcher::/home/runner/go/pkg/mod/example.com/tool/matcher.json', timestamp: 1001}, + {index: 3, message: 'Running tests...', timestamp: 1002}, + {index: 4, message: '##[add-matcher]/opt/hostedtoolcache/go/1.25.7/x64/matchers.json', timestamp: 1003}, + {index: 5, message: 'Test suite started', timestamp: 1004}, + {index: 7, message: 'All tests passed', timestamp: 1006}, + {index: 8, message: '::remove-matcher owner=go::', timestamp: 1007}, + {index: 9, message: 'Build complete', timestamp: 1008}, + ] as Array).filter((line) => !shouldHideLine(line)).map((line) => line.message)).toMatchInlineSnapshot(` + [ + "Starting build process", + "Running tests...", + "Test suite started", + "All tests passed", + "Build complete", + ] + `); +}); diff --git a/web_src/js/components/RepoActionView.vue b/web_src/js/components/RepoActionView.vue index 69579d3687..cf1ed80ffc 100644 --- a/web_src/js/components/RepoActionView.vue +++ b/web_src/js/components/RepoActionView.vue @@ -15,14 +15,19 @@ type RunStatus = 'unknown' | 'waiting' | 'running' | 'success' | 'failure' | 'ca type StepContainerElement = HTMLElement & {_stepLogsActiveContainer?: HTMLElement} -type LogLine = { +export type LogLine = { index: number; timestamp: number; message: string; }; +// `##[group]` is from Azure Pipelines, just supported by the way. https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands const LogLinePrefixesGroup = ['::group::', '##[group]']; const LogLinePrefixesEndGroup = ['::endgroup::', '##[endgroup]']; +// https://github.com/actions/toolkit/blob/master/docs/commands.md +// https://github.com/actions/runner/blob/main/docs/adrs/0276-problem-matchers.md#registration +// Although there should be no `##[add-matcher]` syntax, there are still such outputs when using act-runner +const LogLinePrefixesHidden = ['::add-matcher::', '##[add-matcher]', '::remove-matcher']; type LogLineCommand = { name: 'group' | 'endgroup', @@ -63,6 +68,15 @@ function parseLineCommand(line: LogLine): LogLineCommand | null { return null; } +export function shouldHideLine(line: LogLine): boolean { + for (const prefix of LogLinePrefixesHidden) { + if (line.message.startsWith(prefix)) { + return true; + } + } + return false; +} + function isLogElementInViewport(el: Element, {extraViewPortHeight}={extraViewPortHeight: 0}): boolean { const rect = el.getBoundingClientRect(); // only check whether bottom is in viewport, because the log element can be a log group which is usually tall @@ -315,6 +329,7 @@ export default defineComponent({ appendLogs(stepIndex: number, startTime: number, logLines: LogLine[]) { for (const line of logLines) { + if (shouldHideLine(line)) continue; const el = this.getActiveLogsContainer(stepIndex); const cmd = parseLineCommand(line); if (cmd?.name === 'group') {