From 1f51d5e017d8bd23acfc4adc7797531926c3c9b8 Mon Sep 17 00:00:00 2001 From: Benoit Seignovert Date: Fri, 23 Feb 2024 15:58:21 +0100 Subject: [PATCH] Add gitlab-ci config --- .gitlab-ci.yml | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 3 +++ 2 files changed, 68 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a43ebe1 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,65 @@ +image: python:3.10 + +stages: + - build + - linter + - tests + +variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + +# Trigger only if python file changes +.py_changes: &py_changes + only: + refs: + - merge_requests + - branches + - tags + changes: + - .gitlab-ci.yml + - "**/*.py" + +.poetry: &poetry + <<: *py_changes + before_script: + - python -m pip install poetry>=1.7 + - poetry config virtualenvs.in-project true + - poetry install + +# Build +Poetry install: + stage: build + <<: *poetry + script: + - poetry version + +# Linter +Ruff check: + stage: linter + <<: *poetry + script: + - poetry run ruff check . + +Ruff format: + stage: linter + <<: *poetry + script: + - poetry run ruff format + + +# Tests +Pytest: + stage: tests + <<: *poetry + script: + - poetry run pytest + --cov-report xml:coverage.xml + --junitxml=report.xml + coverage: '/^TOTAL\s+\d+\s+\d+\s+(\d+\%)$/' + artifacts: + expire_in: 1 day + reports: + junit: report.xml + coverage_report: + coverage_format: cobertura + path: coverage.xml diff --git a/README.md b/README.md index 3c03d68..4c069e2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ JupyterHub Batch Spawner for GLiCID =================================== +[![Gitlab CI](https://gitlab.univ-nantes.fr/glicid/jupyter/spawner/badges/main/pipeline.svg)](https://gitlab.univ-nantes.fr/glicid/jupyter/spawner/pipelines/main/latest) +[![Test coverage](https://gitlab.univ-nantes.fr/glicid/jupyter/spawner/badges/main/coverage.svg)](https://gitlab.univ-nantes.fr/glicid/jupyter/spawner/pipelines/main/latest) + ![Spawner form](img/spawner_form.png)