From 964e8a063da3548a02a141d4e1aa2ecbe7f4a15d Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Tue, 20 Aug 2024 16:14:13 +0200 Subject: [PATCH 1/4] Add initial gitlab-ci workflow file --- template/.gitlab-ci.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 template/.gitlab-ci.yml diff --git a/template/.gitlab-ci.yml b/template/.gitlab-ci.yml new file mode 100644 index 00000000..a83c184d --- /dev/null +++ b/template/.gitlab-ci.yml @@ -0,0 +1,30 @@ +# Change pip's cache directory to be inside the project directory since we can +# only cache local items. +variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + +cache: + paths: + - .cache/pip + +test: + stage: test + image: "python:$VERSION" + rules: + # Run on a Merge Request to the default branch + - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH + # Run on new commits to the default branch + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + parallel: + matrix: + - VERSION: ['3.8', '3.9', '3.10', '3.11', '3.12'] + before_script: + # Python info + - which python + - python --version + # Install dependencies + - python -m pip install --upgrade pip setuptools + - python -m pip install --editable ".[dev]" + script: + # Run pytest + - python -m pytest -v --durations=0 From 39575cf0d5949cb5502c4ea122ee0522765a92b2 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Tue, 20 Aug 2024 16:42:20 +0200 Subject: [PATCH 2/4] Add cffconvert job to .gitlab-ci --- template/.gitlab-ci.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/template/.gitlab-ci.yml b/template/.gitlab-ci.yml index a83c184d..a4fd9b45 100644 --- a/template/.gitlab-ci.yml +++ b/template/.gitlab-ci.yml @@ -28,3 +28,19 @@ test: script: # Run pytest - python -m pytest -v --durations=0 + +cffconvert: + stage: test + image: + name: "citationcff/cffconvert:2.0.0" + entrypoint: [""] + rules: + # Run on a Merge Request to the default branch + - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH + # Run on new commits to the default branch + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + changes: + - CITATION.cff + script: + # Check whether the citation metadata from CITATION.cff is valid + - cffconvert --validate From 09e1b18f118321f0badcd7f0d3c7e96b441f66bf Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Tue, 20 Aug 2024 16:59:50 +0200 Subject: [PATCH 3/4] add markdown link checker job to gitlab-ci --- template/.gitlab-ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/template/.gitlab-ci.yml b/template/.gitlab-ci.yml index a4fd9b45..ba185287 100644 --- a/template/.gitlab-ci.yml +++ b/template/.gitlab-ci.yml @@ -44,3 +44,16 @@ cffconvert: script: # Check whether the citation metadata from CITATION.cff is valid - cffconvert --validate + +markdown-link-check: + stage: test + image: + name: "lycheeverse/lychee" + entrypoint: [""] + rules: + # Run on a Merge Request to the default branch + - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH + # Run on new commits to the default branch + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + script: + - lychee . From 1e72a2612fabe21c2a32e16b7c3ab623697bc1ca Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Wed, 21 Aug 2024 08:59:07 +0200 Subject: [PATCH 4/4] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8978bd94..0eca8348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Added +* Added `gitlab-ci.yml` file for GitLab alternative to GitHub Actions [#452](https://github.com/NLeSC/python-template/issues/452) * Added Python 3.12 support [#356](https://github.com/NLeSC/python-template/issues/356) * Template unit tests for documentation generation, linting and version bumping * Docstring for function