Skip to content
Snippets Groups Projects
Commit 46a06cef authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[ci] Implement a test-CI based on pixi only

parent 5d34ee75
No related branches found
No related tags found
1 merge request!33Full dev environment based on pixi-only
Pipeline #86255 failed
......@@ -2,27 +2,166 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
include:
- project: biosignal/software/dev-profile
file: /gitlab/python.yml
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "web"'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- if: $CI_COMMIT_TAG
variables:
XDG_CONFIG_HOME: $CI_PROJECT_DIR/tests/data
PYTHONUNBUFFERED: "1"
OMP_NUM_THREADS: 1 # for pytorch CI tests on docker platform
GIT_SUBMODULE_STRATEGY: normal
GIT_SUBMODULE_DEPTH: 1
XDG_CACHE_HOME: "${CI_PROJECT_DIR}/_cache"
XDG_CONFIG_HOME: "${CI_PROJECT_DIR}/_config"
PIXI_FROZEN: true
documentation:
default:
tags:
- bob
- docker
image: ghcr.io/prefix-dev/pixi:latest
cache:
paths:
- _cache/pixi
before_script:
# for opencv-python dependence
- if [[ "$CI_RUNNER_TAGS" =~ "docker" ]]; then apt-get update && apt-get install -y libgl1-mesa-glx > /dev/null; fi
- !reference [.snippets, doc-prepare]
- mkdir -p ${XDG_CACHE_HOME}/pixi
- mkdir -p ${XDG_CONFIG_HOME}/pixi
- |
# global configuration for pixi
# https://pixi.sh/latest/advanced/global_configuration/#reference
cat << 'EOF' > ${XDG_CONFIG_HOME}/pixi/config.toml
change_ps1 = false
tls_no_verify = true
[mirrors]
"https://conda.anaconda.org/conda-forge" = [ "http://bobconda.lab.idiap.ch:8080/conda-forge" ]
EOF
stages:
- qa
- test
- doc
- dist
- deploy
quality:
stage: qa
rules:
- exists:
- .pre-commit-config.yaml
cache:
key: pre-commit-cache
paths:
- _cache/pre-commit
- _cache/pixi
extends: .quality
script:
- pixi install -e qa-only
- pixi run -e qa-only qa-verbose
tests:
before_script:
# for opencv-python dependence
- if [[ "$CI_RUNNER_TAGS" =~ "docker" ]]; then apt-get update && apt-get install -y libgl1-mesa-glx > /dev/null; fi
- !reference [.snippets, test-prepare]
stage: test
parallel:
matrix:
- PYTHON: ["3.11", "3.12"]
TAG: ["docker", "macos-arm"]
tags:
- bob
- ${TAG}
needs:
- job: quality
optional: true
cache:
key: test-cache-${TAG}-${PYTHON}
script:
- pixi install -e test-only-${PYTHON//\./}
- pixi run -e test-only-${PYTHON//\./} test-full
coverage: '/(?:TOTAL|total|Total).*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
paths:
- html
reports:
junit: junit-coverage.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
conda-package:
documentation:
stage: doc
rules:
- exists:
- doc/conf.py
needs:
- job: quality
optional: true
cache:
key: doc-cache
script:
- pixi install -e doc-only
- pixi run -e doc-only doc
- pixi run -e doc-only doctest
artifacts:
paths:
- html
python-package:
stage: dist
needs:
- tests
cache:
key: build-cache
script:
- pixi install -e build-only
- pixi run -e build-only build
- pixi run -e build-only check
artifacts:
paths:
- dist
docker-image:
image: docker:latest
services:
- docker:dind
rules:
# conditions:
# - the variable $CI_REGISTRY must be defined (package has a container
# image registry)
# - a file named "Dockerfile" exists on the root of the repository
- if: ($CI_REGISTRY != null)
exists:
- Dockerfile
before_script:
# for opencv-python dependence
- if [[ "$CI_RUNNER_TAGS" =~ "docker" ]]; then apt-get update && apt-get install -y libgl1-mesa-glx > /dev/null; fi
- !reference [.snippets, conda-prepare]
- docker info
script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- docker build -t ${CI_REGISTRY_IMAGE}:latest .
- >
# upload image to registry if on main dev branch or tag
if [ "${CI_COMMIT_BRANCH}" == "${CI_DEFAULT_BRANCH}" ]; then \
docker push ${CI_REGISTRY_IMAGE}:latest; \
if [ -n "${CI_COMMIT_TAG}" ]; then \
docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG} .; \
docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}; \
fi \
fi
pypi:
stage: deploy
needs:
- python-package
cache:
key: build-cache
rules:
# conditions:
# - only for tags in PEP-440 style (on any branch)
# - only for public packages
# - the variable $PYPI_TOKEN must be defined
- if: ($CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+([abc]\d*)?$/ && $CI_PROJECT_VISIBILITY == "public" && $PYPI_TOKEN != null)
variables:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: "${PYPI_TOKEN}"
script:
- pixi install -e build-only
- pixi run -e build-only upload
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -115,6 +115,7 @@ reuse = "*"
[tool.pixi.feature.qa.tasks]
qa-install = "pre-commit install"
qa = "pre-commit run --all-files"
qa-verbose = "pre-commit run --all-files --show-diff-on-failure --verbose"
[tool.pixi.feature.doc.dependencies]
sphinx = "*"
......@@ -126,7 +127,9 @@ sphinx-inline-tabs = "*"
sphinx-click = "*"
[tool.pixi.feature.doc.tasks]
doc = "rm -rf doc/api && rm -rf html && sphinx-build -aEW doc html"
doc-clean = "rm -rf doc/api && rm -rf html"
doc = "sphinx-build -aEW doc html"
doctest = "sphinx-build -aEb doctest doc html/doctest"
[tool.pixi.feature.test.dependencies]
pytest = "*"
......@@ -134,11 +137,26 @@ pytest-cov = "*"
[tool.pixi.feature.test.tasks]
test = "pytest -sv tests/"
test-ci = "pytest -sv --cov-report 'html:html/coverage' --cov-report 'xml:coverage.xml' --junitxml 'junit-coverage.xml' --ignore '.profile' tests/"
test-cov = "pytest -sv --cov-report 'html:html/coverage' tests/"
test-full = "pytest -sv --cov-report 'html:html/coverage' --cov-report 'xml:coverage.xml' --junitxml 'junit-coverage.xml' --ignore '.profile' tests/"
[tool.pixi.feature.build.dependencies]
hatch = "*"
versioningit = "*"
twine = "*"
[tool.pixi.feature.build.tasks]
build = "hatch build"
check = "twine check dist/*"
upload = "twine upload dist/*"
[tool.pixi.environments]
default = { features = [ "qa", "doc", "test", "py312", "dev" ], solve-group = "prod-group" }
previous = { features = ["test", "py311", "self"] }
qa-only = { features = ["qa", "py312"], solve-group = "prod-group" }
doc-only = { features = ["doc", "py312"], solve-group = "prod-group" }
test-only-312 = { features = ["test", "py312"], solve-group = "prod-group" }
test-only-311 = { features = ["test", "py311"] }
build-only = { features = ["build", "py312"], solve-group = "prod-group" }
prod = { features = ["py312", "self"], solve-group = "prod-group" }
[tool.hatch.version]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment