ci: add a problem matcher support, to get error/warning/notice annotations in V CI jobs (#22790)

This commit is contained in:
Delyan Angelov 2024-11-07 20:59:19 +02:00 committed by GitHub
parent f3b1674ed9
commit 0eaa85725b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 42 additions and 1 deletions

View file

@ -0,0 +1,19 @@
// The task of this program, is to register all available .json files
// in this folder with Github Actions, so that it can make annotations
// for all found notices/warnings/errors produced by the V compiler
// while running the CI jobs.
// Those annotations provide a way to get a quick overview for failures,
// without having to scroll into the detailed logs produced by each job.
const github_job = getenv('GITHUB_JOB')
if github_job == '' {
exit(0)
}
dump(github_job)
chdir(@VEXEROOT)!
for f in walk_ext('.github/problem-matchers/', '.json').sorted() {
println('::add-matcher::${real_path(f)}')
println('registered matcher: `${f}`')
}

18
.github/problem-matchers/v.json vendored Normal file
View file

@ -0,0 +1,18 @@
{
"__comment": "Based on https://github.com/python/cpython/blob/main/.github/problem-matchers/gcc.json",
"problemMatcher": [
{
"owner": "v-problem-matcher",
"pattern": [
{
"regexp": "^(.*):(\\d+):(\\d+):\\s+(?:fatal\\s+)?(warning|error|notice):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}

View file

@ -118,6 +118,7 @@ endif
@$(VEXE) run cmd/tools/detect_tcc.v @$(VEXE) run cmd/tools/detect_tcc.v
@echo "V has been successfully built" @echo "V has been successfully built"
@$(VEXE) -version @$(VEXE) -version
@$(VEXE) run .github/problem-matchers/register_all.vsh
clean: clean:
rm -rf $(TMPTCC) rm -rf $(TMPTCC)

View file

@ -15,8 +15,10 @@ v:
./v1 -no-parallel -o v2 $(VFLAGS) cmd/v ./v1 -no-parallel -o v2 $(VFLAGS) cmd/v
./v2 -o v $(VFLAGS) cmd/v ./v2 -o v $(VFLAGS) cmd/v
rm -rf v1 v2 rm -rf v1 v2
@echo "V has been successfully built"
./v run ./cmd/tools/detect_tcc.v ./v run ./cmd/tools/detect_tcc.v
@echo "V has been successfully built"
./v version
./v run .github/problem-matchers/register_all.vsh
check: check:
./v test-all ./v test-all

View file

@ -260,6 +260,7 @@ echo ^> To add V to your PATH, run `%V_EXE% symlink`.
echo. echo.
echo | set /p="V version: " echo | set /p="V version: "
"%V_EXE%" version "%V_EXE%" version
"%V_EXE%" run .github/problem-matchers/register_all.vsh
goto :eof goto :eof
:usage :usage