From d0347342efaf94489a60ab7b250c1ba88d5299eb Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 23 Jul 2024 19:05:25 +0200 Subject: [PATCH] ci: use problem matchers to tag lint warnings & errors --- .github/problem-matchers.json | 58 +++++++++++++++++++++++++++++++++++ .github/workflows/build.yml | 8 +++++ utils/lint.mk | 4 +-- 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 .github/problem-matchers.json diff --git a/.github/problem-matchers.json b/.github/problem-matchers.json new file mode 100644 index 000000000..5b28cd86b --- /dev/null +++ b/.github/problem-matchers.json @@ -0,0 +1,58 @@ +{ + "problemMatcher": [ + { + "owner": "clang-tidy", + "pattern": [ + { + "regexp": "^(?:\\x1b\\[[0-9;]+m)*(.+):(\\d+):(\\d+):\\s+(?:\\x1b\\[[0-9;]+m)*(warning|error):\\s+(?:\\x1b\\[[0-9;]+m)*(.*)\\s+\\[(.+)\\](?:\\x1b\\[[0-9;]+m)*$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5, + "code": 6 + } + ] + }, + { + "owner": "cppcheck", + "pattern": [ + { + "regexp": "^(?:\\x1b\\[[0-9;]+m)*(.+):([0-9;]+):(\\d+):\\s+(?:\\x1b\\[[0-9;]+m)*(warning|error):(?:\\x1b\\[[0-9;]+m)*\\s+(.+)\\s+\\[(.+)\\](?:\\x1b\\[[0-9;]+m)*$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5, + "code": 6 + } + ] + }, + { + "owner": "stylelint", + "pattern": [ + { + "regexp": "^(.+):(\\d+):(\\d+):\\s+(.+)\\s+\\((.+)\\)\\s+\\[(error)\\]$", + "file": 1, + "line": 2, + "column": 3, + "message": 4, + "code": 5, + "severity": 6 + } + ] + }, + { + "owner": "xmllint", + "pattern": [ + { + "regexp": "^(.+):(\\d+):\\s+parser (error)\\s+:\\s+(.+)$", + "file": 1, + "line": 2, + "severity": 3, + "message": 4 + } + ] + } + ] +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0248da707..f400591fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,5 +54,13 @@ jobs: npm init --yes npm install stylelint stylelint-config-standard + - name: Setup problem matchers + run: | + set -x + echo '::remove-matcher owner=eslint-compact::' + echo '::remove-matcher owner=eslint-stylish::' + echo '::remove-matcher owner=tsc::' + echo '::add-matcher::.github/problem-matchers.json' + - name: Lint run: ./utils/lint.sh 2>&1 diff --git a/utils/lint.mk b/utils/lint.mk index b00cbb19e..a3cea0745 100644 --- a/utils/lint.mk +++ b/utils/lint.mk @@ -153,17 +153,15 @@ endef ifneq (,$(GITHUB_ACTIONS)) ci_startgroup := printf '::group::' ci_endgroup := printf '::endgroup::\n' -ci_error = printf '%b\n::error::%s\n%b\n' '$(ANSI_RESET)' $1 '$(ANSI_RESET)' ci_time := time else ci_startgroup := : ci_endgroup := : -ci_error := : ci_time = endif define warn_on_error -if [ $1 -ne 0 ]; then $(call $(if $(GITHUB_ACTIONS),ci_error,trace_warn),$2); fi +if [ $1 -ne 0 ]; then $(call trace_warn,$2); fi endef # `$(call lint_rule,prefix,file,command)`