Commit 0cb0cd26 authored by Alexia Ognard's avatar Alexia Ognard Committed by Thibaud-Vdb
Browse files

feat(job): create python_tox job

parent fe6b3c1a
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
## Objective

Tox aims to automate and standardize testing in Python. It is part of a larger vision of easing the packaging, testing and release process of Python software.

## How to use it

1. Ensure that your project have
   [`tox.ini`](https://tox.wiki/en/latest/){:target="_blank"} 
   file
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/python_tox.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: `python_tox`
* Docker image:
[`vicamo/pyenv:slim-focal`](https://hub.docker.com/r/vicamo/pyenv)
* Default stage: `static_tests`
* When: `always`

### Variables

| Name | Description | Default |
| ---- | ----------- | ------- |
| `PROJECT_ROOT` <img width=100/> | Relative to root of your repository, it is the path to your python project <img width=175/>| `.` <img width=100/>|
| `PYTHON_ENV` | Restrict the test to run on a specific environnement of Python, if none is specified `Tox` will run the test on all environnement listed in the `tox.ini` file. | ` ` |
| `ADDITIONAL_OPTIONS` | [Additional options](https://tox.wiki/en/latest/config.html?result-json#tox) for tox command | ` ` |
+14 −0
Original line number Diff line number Diff line
name: python_tox
description: A ready-to-use Tox job to test your Python project
default_stage: static_tests
icon: 🐍
maintainer: alexiaognard
license: Apache-2.0
images:
  vicamo/pyenv:slim-focal
tools:
labels:
  - GitLab
  - Python
  - Testing
  - Tox
 No newline at end of file
+23 −0
Original line number Diff line number Diff line
# Job from R2Devops hub --> r2devops.io

stages:
  - static_tests

python_tox:
  image:
    name: vicamo/pyenv:slim-focal
    entrypoint: [""]

  stage: static_tests

  variables:
    PROJECT_ROOT: "."
    PYTHON_ENV: ""
    ADDITIONAL_OPTIONS: ""

  script:
    - cd $PROJECT_ROOT
        # Install tox
    - pip install tox
    - if [[ (${PYTHON_ENV} != "") ]]; then PYTHON_ENV="-e $PYTHON_ENV"; else PYTHON_ENV=""; fi
    - tox $PYTHON_ENV $ADDITIONAL_OPTIONS
+1 −0
Original line number Diff line number Diff line
* Initial version
 No newline at end of file