diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..86de785 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,23 @@ +variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + +cache: + paths: + - .cache/pip + - /var/venv/ + +lint: + image: python:3.8-slim + stage: test + except: + - /^wip-.*$/ + - /^old-.*$/ + - pitchme + script: + - python -V + - apt-get update -qq && apt-get -qq -y install make python3-venv + - python3 -m venv /var/venv/ + - source /var/venv/bin/activate + - pip install -r requirements-dev.txt + - make --no-print-directory --quiet lint + - make --no-print-directory --quiet test diff --git a/Makefile b/Makefile index a051a75..88b68fa 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,11 @@ lint: # Lint code open_all: # Open all projects files ${EDITOR} ${VBIN}/activate - ${EDITOR} main.py Makefile pyproject.toml README.md requirements-dev.txt requirements.txt + ${EDITOR} .gitlab-ci.yml main.py Makefile pyproject.toml README.md requirements-dev.txt requirements.txt ${EDITOR} .git/hooks/p*-commit pre_commit: # Run the pre-commit hook bash .git/hooks/pre-commit + +test: # Run the code tests + ./main.py -h 1> /dev/null && echo ✅ || echo 🚨 diff --git a/main.py b/main.py index 1e51466..0b7b426 100755 --- a/main.py +++ b/main.py @@ -12,6 +12,7 @@ This file is part of [``]() """ import argparse +from os import environ import sys from pprint import pprint as pp @@ -123,5 +124,6 @@ def main(): if __name__ == "__main__": import doctest - doctest.testmod() + # When running on GitLab CI, a doctest error raised an error + doctest.testmod(raise_on_error=environ.get("CI", False)) sys.exit(main())