Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
.gitlab-ci.yml 3.23 KiB
# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python
image: python:latest

# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
#services:
#  - mysql:latest
#  - postgres:latest

#variables:
#  POSTGRES_DB: database_name

# This folder is cached between builds
# http://docs.gitlab.com/ee/ci/yaml/README.html#cache
cache:
  paths:
    - ~/.cache/pip/

# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
  - python -V  # Print out python version for debugging
  # Uncomment next line if your Django app needs a JS runtime:
  # - apt-get update -q && apt-get install nodejs -yqq
  - pip install -r requirements.txt

# To get Django tests to work you may need to create a settings file using
# the following DATABASES:
#
# DATABASES = {
#     'default': {
#        'ENGINE': 'django.db.backends.postgresql_psycopg2',
#        'NAME': 'ci',
#        'USER': 'postgres',
#        'PASSWORD': 'postgres',
#        'HOST': 'postgres',
#        'PORT': '5432',
#    },
# }
#
# and then adding `--settings app.settings.ci` (or similar) to the test command

#SOURCE: https://stephen-olabode.medium.com/running-black-formatter-to-lint-a-python-file-in-gitlab-ci-cd-ae80111ab363
black:
  image: python:latest
  before_script:
    - pip install black
  script:
    - black --check .

#SOURCE: https://pypi.org/project/pylint-gitlab/
pylint:
  image: python:latest
  stage: test
  before_script:
    - python -V
    - mkdir -p public/badges public/lint
    - echo undefined > public/badges/$CI_JOB_NAME.score
    - pip install pylint-django
    - pip install -r requirements.txt
  script:
    #Due to Problems with Pylint, Ignored Files need to be presented here for now.
     - ./custom_linter.sh
#    - pylint  --exit-zero --output-format=text $(find -type f -name "*.py" ! -path "**/.venv/**") | tee /tmp/pylint.txt
#    - sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' /tmp/pylint.txt > public/badges/$CI_JOB_NAME.score
#    - pylint  --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter $(find -type f -name "*.py" ! -path "**/.venv/**") > codeclimate.json
#    - pylint  --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter $(find -type f -name "*.py" ! -path "**/.venv/**") > public/lint/index.html