Skip to main content

Parse linter output and convert it to GitLab Code Quality report

Project description

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}

Options:

  • --output file_path:
    • Output to file_path.
  • --merge:
    • Merge output to existing JSON file (available if --output is specified).
  • --echo:
    • Echo linter output (available if --output is specified).

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 json is required and do not pass --output option.
  • pyright:
    • --outputjson is required.
  • mypy:
    • --output=json is 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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitlab_cq-0.2.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

gitlab_cq-0.2.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file gitlab_cq-0.2.0.tar.gz.

File metadata

  • Download URL: gitlab_cq-0.2.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for gitlab_cq-0.2.0.tar.gz
Algorithm Hash digest
SHA256 74043e055824154abc443032c0f7b9b25a79432b0325cdc25c23600d3898a590
MD5 d58f95e6f32122f34e7f244beaf88c8c
BLAKE2b-256 b09880a79dad1e620089d3ea20eaa4678f91ed79b34cb2265c37d7e55e0374a3

See more details on using hashes here.

File details

Details for the file gitlab_cq-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: gitlab_cq-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for gitlab_cq-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f629c861fb446d4e54c882c8d3d2f3cc19eaa266451054587802a7f7c26484e
MD5 92a66c8807e211e0d84603c3252224be
BLAKE2b-256 21f44c5a4608458d61adf019a409821a635a43b584899445484d8dbb824ad17a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page