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 diff --git a/template/.gitlab-ci.yml b/template/.gitlab-ci.yml new file mode 100644 index 00000000..ba185287 --- /dev/null +++ b/template/.gitlab-ci.yml @@ -0,0 +1,59 @@ +# 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 + +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 + +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 .