Parse linter output and convert it to GitLab Code Quality report.
Pull Requests for additional linter support are welcome.
$ python -m pip install -U gitlab-cqOr use pipx:
$ pipx install gitlab-cqThere are two ways to use GitLab-CQ: run linter command via. GitLab-CQ or parse linter output from stdin.
Run linter command via. GitLab-CQ:
$ gitlab-cq [--output file_path] [--merge] [--echo] CMD [Arguments]Parse linter output from stdin:
$ CMD [Arguments] | gitlab-cq [--output file_path] [--merge] [--echo] LINTERArguments:
CMD:- Command to run linter.
Arguments:- Arguments for linter command.
LINTER:- Linter name to parse:
{ruff, pyright, mypy, gcc, clang-tidy, clang}
- Linter name to parse:
Options:
--output file_path:- Output to file_path.
--merge:- Merge output to existing JSON file (available if
--outputis specified).
- Merge output to existing JSON file (available if
--echo:- Echo linter output (available if
--outputis specified).
- Echo linter output (available if
The following options are required for linters when parsing from stdin.
(No need to add the following when the linter runs via. GitLab-CQ, since these options are automatically added.)
ruff:--output-format jsonis required and do not pass--outputoption.
pyright:--outputjsonis required.
mypy:--output=jsonis required.
Integration to GitLab CI and save an GitLab CQ artifact:
code quality:
stage: test
script:
# Run linters via. GitLab-CQ and merge output to gl-code-quality-report.json
- pipx install gitlab-cq
- gitlab-cq --output gl-code-quality-report.json ruff check .
- gitlab-cq --output gl-code-quality-report.json --merge pyright .
- gitlab-cq --output gl-code-quality-report.json --merge mypy .
# Parse linter/compiler output and merge to gl-code-quality-report.json
- gcc -Wall -Wextra -o /dev/null -c main.c 2>&1 | gitlab-cq --output gl-code-quality-report.json --merge gcc
- clang-tidy -format-style=file -p . --quiet main.c | gitlab-cq --output gl-code-quality-report.json --merge clang-tidy
artifacts:
reports:
codequality: gl-code-quality-report.jsonYoshiki Matsuda (@yosh-matsuda)