GitLab-CQ
Parse linter output and convert it to GitLab Code Quality report.
Supported Linters
Pull Requests for additional linter support are welcome.
Installation
$ python -m pip install -U gitlab-cq
Or use pipx:
$ pipx install gitlab-cq
Usage
There 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] LINTER
Arguments:
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
Required options for linters
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.
Example
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.json
Author
Yoshiki Matsuda (@yosh-matsuda)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file gitlab_cq-0.2.2.tar.gz.
File metadata
- Download URL: gitlab_cq-0.2.2.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d688c2aea85cdbb2293cbff3d074bdf26c4ea30c8b02cff23384011dac26c791
|
|
| MD5 |
061a576909849434f8fc94b13257f992
|
|
| BLAKE2b-256 |
447b28d62ca9cec9eececb1efb58e98c0cbd108d8939c30d76df06317e4e4901
|