From a78d5ecc607dd3367b5322feb5b85932cd75af01 Mon Sep 17 00:00:00 2001 From: Stepland <10530295-Buggyroom@users.noreply.gitlab.com> Date: Tue, 8 Mar 2022 21:18:08 +0000 Subject: [PATCH] Setup Gitlab CI --- .flake8 | 1 + .gitlab-ci.yml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.flake8 b/.flake8 index d26e936..79e2cb5 100644 --- a/.flake8 +++ b/.flake8 @@ -20,6 +20,7 @@ exclude = .hypothesis .mypy_cache .pytest_cache + .venv # For the CI pipeline : don't check the local dependency cache .vscode __pycache__ docs diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d66206b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,44 @@ +image: python:latest + +workflow: + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +stages: + - test + - deploy + +# Move pip's and poetry's caches to somewhere gitlab can cache +# https://pip.pypa.io/en/stable/topics/configuration/#environment-variables +# https://python-poetry.org/docs/configuration/#using-environment-variables +variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + POETRY_VIRTUALENVS_PATH: "$CI_PROJECT_DIR/.cache/poetry" + +cache: + paths: + - .cache/pip + - .cache/poetry + - .mypy_cache + +before_script: + - pip install poetry + - poetry install + +test: + stage: test + script: + - poetry run isort --check-only + - poetry run black --check jubeatools + - poetry run flake8 + - poetry run mypy jubeatools + - poetry run pytest jubeatools + +build and publish: + stage: deploy + when: manual + rules: + - if: '$CI_COMMIT_TAG =~ /v.+/' + script: + - poetry publish --build \ No newline at end of file