Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Released on August 15, 2024

### 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
Expand Down
126 changes: 126 additions & 0 deletions template/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.

stages:
- lint # Fastest check first
- test # Then test
- build # build package and documentation when verified correct

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: lint
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: lint
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 .

lint:
stage: lint
image: "python:3.12"
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
before_script:
# Python info
- which python
- python --version
# Install dependencies
- python -m pip install ruff
script:
# Run pytest
- ruff check
- ruff format --check

build:
stage: build
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 .[publishing]
script:
# Run pytest
- python -m build

documentation:
stage: build
image: "python:3.12"
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
before_script:
# Python info
- which python
- python --version
# Install dependencies
- python -m pip install .[docs]
- sudo apt install pandoc
script:
# Run pytest
- cd docs
- make coverage doctest html
Loading