From d04d180f9b12b872d5259992a5ab3e6aa32dea78 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Tue, 11 Jun 2019 22:17:05 +0200 Subject: [PATCH] [enh] #149: Add CI/CD .gitlab-ci.yml - Use our built images - Checks: build, format - tests: Python v3.5, 3.6, 3.7, and 3.8 - #105: PyPi and PyPi test distributions - Coverage published to GitLab Pages - Use Black installed from Docker image v3.8 as black is only available on Buster --- .gitlab-ci.yml | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..ed3312d3 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,99 @@ +stages: + - checks + - tests + - publish + - coverage + +variables: + DOCKER_IMAGE: "registry.duniter.org/docker/python3/poetry" + PYTHON_VERSION: "3.7" + +image: $DOCKER_IMAGE/$PYTHON_VERSION:latest + +.code_changes: + only: + changes: + - bin/silkaj + - silkaj/*.py + - tests/*.py + +.changes: + extends: .code_changes + only: + changes: + - .gitlab-ci.yml + - pyproject.toml + - poetry.lock + +build: + extends: .changes + stage: checks + script: + - poetry install --no-dev + - poetry build + +format: + extends: .code_changes + stage: checks + image: $DOCKER_IMAGE/3.8:latest + script: + - black --check bin silkaj tests + +.tests: + extends: .changes + stage: tests + image: $DOCKER_IMAGE/$PYTHON_VERSION:latest + script: + - poetry install + - poetry run pytest + +tests-3.5: + extends: .tests + variables: + PYTHON_VERSION: "3.5" + +tests-3.6: + extends: .tests + variables: + PYTHON_VERSION: "3.6" + +tests-3.7: + extends: .tests + variables: + PYTHON_VERSION: "3.7" + script: + - poetry run pytest --cov silkaj --cov-report html:cov_html + artifacts: + paths: + - cov_html + +tests-3.8: + extends: .tests + variables: + PYTHON_VERSION: "3.8" + +pypi_test: + stage: publish + when: manual + script: + - poetry install --no-dev + - poetry config repositories.pypi_test https://test.pypi.org/legacy/ + - poetry publish --build --username $PYPI_TEST_LOGIN --password $PYPI_TEST_PASSWORD --repository pypi_test + +pypi: + stage: publish + only: + - tags + when: manual + script: + - poetry install --no-dev + - poetry publish --build --username $PYPI_LOGIN --password $PYPI_PASSWORD + +pages: + extends: .code_changes + stage: coverage + script: mv cov_html/ public/ + artifacts: + paths: + - public + expire_in: 2 days -- GitLab