Skip to content
Snippets Groups Projects
Python.yaml 1.4 KiB
Newer Older
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Hidden template jobs to be used in `.gitlab-ci.yml`
#
# - `.python:black:check`: verify formatting of code with `black`
#
---
#
# .python:black:check
# ===================
#
# The Python code must match `black` standard.
#
# USAGE
# =====
#
# include:
#   - project: EOLE/Infra/ci-tools
#     ref: stable
#     file: /templates/Python.yaml
#
# stages:
#   - lint
#
# python:black: {extends: '.python:black:check'}
#
# REQUIREMENTS
# ============
#
# - a `lint` stage must be present in your pipeline or it must be
#   overriden by the extending job to feet your need
#
# - the `.not-on-stable` rules templates
#
# OPTIONAL VARIABLES
# ==================
#
# - `PYTHON_BLACK_OPTS`: additional options to pass to `black`
#
# - `PYTHON_SOURCE_DIR`: top level directory where to run `black`,
#   defaults to `.`
#
# - `PYTHON_BLACK_IMAGE`: name of the black docker image to use
#
.python:black:check:
  stage: lint
  extends: .not-on-stable
  image: "${PYTHON_BLACK_IMAGE}"
  variables:
    PYTHON_BLACK_IMAGE: "hub.eole.education/proxyhub/pyfound/black:latest_release"
    PYTHON_BLACK_OPTS: ''
    PYTHON_SOURCE_DIR: '.'
  script:
    - echo -e "\e[0Ksection_start:`date +%s`:python-black\r\e[0KExecute 'black --check ${PYTHON_BLACK_OPTS} ${PYTHON_SOURCE_DIR}'"
    - black --check ${PYTHON_BLACK_OPTS} ${PYTHON_SOURCE_DIR}
    - echo -e "\e[0Ksection_end:`date +%s`:python-black\r\e[0K"
...