To make GitLab push the code changes to the runners, we need to create the.gitlab-ci.yml file. As I already mentioned in the last post, this file controls the behavior of runners. The following script automatically executes a PowerShell script after every commit to the master branch. Enter the gitlab-ci tags for this runner: It is an optional, if you want to start GitLab runner when specific tag is available in yml file. Enter the executor: There will be list of several executors, and type shell (as GitLab Runner will run our system) 7. After successful registration, start the GitLab Runner.
Latest versionReleased:
This project provides pylint formatters for a nice integration with GitLab CI.
Project description
This project provides pylint formatters for a nice integration with GitLab CI.
Formatter | Description |
---|---|
GitlabCodeClimateReporter | Maps the linting result in Code Climate format |
GitlabPagesHtmlReporter | Creates a table in an HTML page with linting results and links to source code. |
Usage
Install package pylint-gitlab
:
The pylint
package is a dependency of pylint-gitlab
so it will be installed automatically.
Now the formatters can be used by running pylint
command and setting custom output formats with parameter --output-format
.
Alternatively, you can load the pylint_gitlab
plugin and then use the shortened --output-format
names:
GitLab CI integration
Here is a minimalistic version for a .gitlab-ci.yml
file:
You can then use the published badge for linting results.
Release historyRelease notifications | RSS feed
0.3.0
0.2.0
0.1.0
0.0.1
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size pylint_gitlab-0.3.0-py3-none-any.whl (7.9 kB) | File type Wheel | Python version py3 | Upload date | Hashes |
Filename, size pylint-gitlab-0.3.0.tar.gz (7.2 kB) | File type Source | Python version None | Upload date | Hashes |
Hashes for pylint_gitlab-0.3.0-py3-none-any.whl
Algorithm | Hash digest |
---|---|
SHA256 | 66af89ccd59c3417aded0223a305ecdb178e9c78d2f921d7c8dee4e7060d02fa |
MD5 | 6608727d1af4b599e6b5db8b90726496 |
BLAKE2-256 | 4db20198ca9fb18ed446f673eeaa71ebf26886a3d9780182ac07faa01bf3e786 |
Hashes for pylint-gitlab-0.3.0.tar.gz
Algorithm | Hash digest |
---|---|
SHA256 | bce30ca1c15e84f7a43bc3abbbd449107425eac8708455e40e44cd34b9077684 |
MD5 | 08fb70d61d66ee33b51fa2d181369de9 |
BLAKE2-256 | 50af97d381d2efc5bda9c6a6868271d92c28aa41a376c6448ce9e0b4a1d4fd09 |
The Python template file python.yml
can be included via
This file provides the following job templates:
.python:cache
¶
Description¶
Configures caching of the pip
cache directory via the following variable:
Name | Default | Purpose |
---|---|---|
PIP_CACHE_DIR | ${CI_PROJECT_DIR}/.cache/pip | where to store downloaded pip packages |
Example usage¶
.python:base
¶
Extends:.python:cache
Description¶
The base Python job template. This template configures Pip caching, the PYTHON
environment variable, and a default docker image (python
).
Example usage¶
.python:build
¶
Extends:.python:base
Description¶
The .python:build
job template provides an end-to-end distribution build configuration, effectively running the following command to build a project:
The outputs are uploaded as job artifacts.
The following variables can be used to configure the build:
Name | Default | Purpose |
---|---|---|
PYTHON | python | the path of the python interpreter to use |
BUILD_REQUIRES | (empty) | extra packages to pip install before running python -m build (use '-r <file>' to install from a requirements file) |
BUILD_OPTIONS | (empty) | extra options to pass to python -m build |
SRCDIR | '.' | path of source directory for python -m build |
SDIST | true | if true , run sdist to generate a tarball, otherwise don't |
WHEEL | true | if true , run wheel to generate a wheel, otherwise don't |
Example usage¶
The default options are most likely enough for your project:
To disable the wheel
build:
.python:test
¶
Extends:.python:base
Description¶
A base template for Python test jobs. The template just configures printing and uploading of coverage reports from a test suite run.
For most projects it would probably make more sense to use one of the harness-specific templates for unittest
or pytest
below.
Example usage¶
.python:unittest
¶
Extends:.python:test
Description¶
This job runs a unittest
suite for a Python project.
Gitlab Ci Cd Example
With default options, this job approximately runs the following:
The job can be configured using the following variables:
Name | Default | Purpose |
---|---|---|
PYTHON | python | the path of the python interpreter to use |
PIP_OPTIONS | (empty) | options to pass to pip install |
TESTS_REQUIRE | (empty) | extra packages to pip install before running unittest (use '-r <file>' to install from a requirements file) |
INSTALL_TARGET | '.' | the path to pass to pip install to install the project |
UNITTEST_OPTIONS | 'discover' | extra options to pass to python -m unittest |
COVERAGE_TARGET | ${CI_PROJECT_NAME//-/_} | the path to pass to coverage --source={} to measure coverage |
Example usage¶
To run unittest
after installing the mylib-*.tar.gz
file created by the tarball
job:
.python:pytest
¶
Extends:.python:test
Description¶
This job installs a project and runs pytest
, uploading JUnit XML test and coverage reports.
With default options, this job approximately runs the following script:
The job can be configured using the following variables:
Name | Default | Purpose |
---|---|---|
PYTHON | python | the path of the python interpreter to use |
PIP_OPTIONS | (empty) | options to pass to pip install |
TESTS_REQUIRE | (empty) | extra packages to pip install before running pytest (use '-r <file>' to install from a requirements file) |
INSTALL_TARGET | '.' | the path to pass to pip install to install the project |
PYTEST_OPTIONS | (empty) | extra options to pass to pytest |
COVERAGE_TARGET | ${CI_PROJECT_NAME//-/_} | the path to pass to pytest --cov={} to measure coverage |
Example usage¶
For projects that include pytest configurations in the repository and don't need any plugins, you can just use the template without any additions:
To configure the template to install from a tarball, then run tests using pytest-xdist
with coverage measured from the installed library:
In this instance the job effectively runs this script:
.python:mkdocs
¶
Description¶
This job runs mkdocs build
, uploading the output site/
directory as a job artifact.
With default options, this job approximately runs the following script:
The template can be configured using the following variables:
Name | Default | Purpose |
---|---|---|
PYTHON | python | the path of the python interpreter to use |
REQUIREMENTS | (empty) | extra packages to pip install before running mkdocs (use '-r <file>' to install from a requirements file) |
MKDOCS_OPTIONS | (empty) | extra options to pass to mkdocs |
Example usage¶
Gitlab Api Python
(Including gitlab pages
job):
.python:sphinx
¶
Extends:.python:base
Description¶
This job runs sphinx
, uploading the HTML output directory html/
as a job artifact.
With default options, this job approximately runs the following script:
However, if docs/Makefile
isn't found, the following is run:
The template can be configured using the following variables:
Name | Default | Purpose |
---|---|---|
PYTHON | python | the path of the python interpreter to use |
REQUIREMENTS | (empty) | extra packages to pip install before running sphinx (use '-r <file>' to install from a requirements file) |
SPHINX_OPTIONS | (empty) | extra options to pass to sphinx |
SOURCEDIR | 'docs' | directory containing documentation sources |
Example usage¶
Example usage (including gitlab pages
job):
.python:flake8
¶
Extends:.python:base
Description¶
This template runs the flake8
linter over the project source, uploading a code quality report.
With default options, this job approximately runs the following script:
The template can be configured using the following variables:
Name | Default | Purpose |
---|---|---|
PYTHON | python | the path of the python interpreter to use |
FLAKE8_REQUIREMENTS | (empty) | other packages to pip install before running flake8 |
FLAKE8_TARGET | '.' | the path over which to run flake8 |
FLAKE8_OPTIONS | (empty) | extra options to pass to flake8 |