Commit 369c3aa7 authored by Thomas Boni's avatar Thomas Boni
Browse files

Merge branch '470-new-job-pylint' into 'latest'

feat:[new job] pylint

See merge request r2devops/hub!291
parents fe6b3c1a 1ae78a70
Loading
Loading
Loading
Loading

jobs/pylint/README.md

0 → 100644
+32 −0
Original line number Diff line number Diff line
## Objective

This job will use the tool [pylint](https://pylint.pycqa.org/en/latest/intro.html) that checks for errors in your Python code, tries to enforce a coding standard and looks for code smells.

## How to use it

1. Make sure that your project has [`__init__.py`](https://docs.python.org/3/tutorial/modules.html){:target="_blank"} 
1. You can use a pylintrc file on your project or use [environment variable](https://pylint.pycqa.org/en/latest/user_guide/run.html), to specify options for `pylint`.
1. Add this job URL inside the `include` list of your `.gitlab-ci.yml` file (see the [quick setup](/use-the-hub/#quick-setup)). You can specify [a fixed version](#changelog) instead of `latest`.
    ```yaml
      - remote: 'https://jobs.r2devops.io/latest/pylint.yml'
    ```
1. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
   customization](/use-the-hub/#jobs-customization)
1. Well done, your job is ready to work ! 😀

## Job details

* Job name: `pylint`
* Docker image:
[`python:3.10-buster`](https://hub.docker.com/r/_/python)
* Default stage: `static_tests`
* When: `always`

### Variables

| Name | Description | Default |
| ---- | ----------- | ------- |
| `PROJECT_ROOT` | Path to the directory containing `package.json`  | `.` |
| `PYLINT_OPTIONS` | [Additional options](https://pylint.pycqa.org/en/latest/user_guide/run.html) for `pylint` | `` |
| `PYLINT_OUTPUT` | Output file | `report_pylint.xml` |
| `PYLINT_EXIT_ZERO` | Returns a non-zero status code. If the option is specified, and Pylint runs successfully, it will exit with 0 regardless of the number of lint issues detected. | `true` |
 No newline at end of file

jobs/pylint/job.yml

0 → 100644
+14 −0
Original line number Diff line number Diff line
name: pylint
description: A ready-to-use linter, to help validate the quality of your source code in python project.
default_stage: static_tests
icon: 🐍
maintainer: alexiaognard
license: Apache-2.0
images:
  python:3.10-buster
tools:
labels:
  - GitLab
  - Linter
  - Quality
  - Python

jobs/pylint/pylint.yml

0 → 100644
+25 −0
Original line number Diff line number Diff line
# Job from R2Devops hub --> r2devops.io

stages:
  - static_tests

pylint:
  image: python:3.10-buster
  stage: static_tests
  variables:
    PROJECT_ROOT: "."
    PYLINT_OPTIONS: ""
    PYLINT_OUTPUT: "report_pylint.xml"
    PYLINT_EXIT_ZERO: "true"
  script:
    - cd $PROJECT_ROOT
    - pip install pylint pylint_junit
    - options="--output-format=pylint_junit.JUnitReporter --output=$PYLINT_OUTPUT"
    - $([ ${PYLINT_EXIT_ZERO} == "true" ]) && options="${options} --exit-zero"
    - pylint ${options} $PYLINT_OPTIONS $(find -type f -name "*.py" ! -path "**/.venv/**")
  artifacts:
      when: always
      paths:
        - ${PROJECT_ROOT}/${PYLINT_OUTPUT}
      reports:
        junit: ${PROJECT_ROOT}/${PYLINT_OUTPUT}
 No newline at end of file
+0 −0

Empty file added.

+1 −0
Original line number Diff line number Diff line
* Initial version
 No newline at end of file