0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 03:31:50 +02:00

ci: add job optional dependency check

This commit is contained in:
2024-06-14 08:31:31 +02:00
parent 69adadd6d7
commit 27426ce7a5

View File

@ -22,6 +22,13 @@ workflow:
include: include:
- template: Security/Secret-Detection.gitlab-ci.yml - template: Security/Secret-Detection.gitlab-ci.yml
- project: "bec/awi_utils"
file: "/templates/check-packages-job.yml"
inputs:
stage: test
path: "."
pytest_args: "-v --random-order tests/"
exclude_packages: ""
# different stages in the pipeline # different stages in the pipeline
stages: stages:
@ -32,21 +39,21 @@ stages:
- Deploy - Deploy
.install-qt-webengine-deps: &install-qt-webengine-deps .install-qt-webengine-deps: &install-qt-webengine-deps
- apt-get -y install libnss3 libxdamage1 libasound2 libatomic1 libxcursor1 - apt-get -y install libnss3 libxdamage1 libasound2 libatomic1 libxcursor1
- export QTWEBENGINE_DISABLE_SANDBOX=1 - export QTWEBENGINE_DISABLE_SANDBOX=1
.clone-repos: &clone-repos .clone-repos: &clone-repos
- git clone --branch $BEC_CORE_BRANCH https://gitlab.psi.ch/bec/bec.git - git clone --branch $BEC_CORE_BRANCH https://gitlab.psi.ch/bec/bec.git
- git clone --branch $OPHYD_DEVICES_BRANCH https://gitlab.psi.ch/bec/ophyd_devices.git - git clone --branch $OPHYD_DEVICES_BRANCH https://gitlab.psi.ch/bec/ophyd_devices.git
- export OHPYD_DEVICES_PATH=$PWD/ophyd_devices - export OHPYD_DEVICES_PATH=$PWD/ophyd_devices
.install-os-packages: &install-os-packages .install-os-packages: &install-os-packages
- apt-get update - apt-get update
- apt-get install -y libgl1-mesa-glx libegl1-mesa x11-utils libxkbcommon-x11-0 libdbus-1-3 - apt-get install -y libgl1-mesa-glx libegl1-mesa x11-utils libxkbcommon-x11-0 libdbus-1-3
- *install-qt-webengine-deps - *install-qt-webengine-deps
before_script: before_script:
- if [[ "$CI_PROJECT_PATH" != "bec/bec_widgets" ]]; then - if [[ "$CI_PROJECT_PATH" != "bec/bec_widgets" ]]; then
echo -e "\033[35;1m Using branch $CHILD_PIPELINE_BRANCH of BEC Widgets \033[0;m"; echo -e "\033[35;1m Using branch $CHILD_PIPELINE_BRANCH of BEC Widgets \033[0;m";
test -d bec_widgets || git clone --branch $CHILD_PIPELINE_BRANCH https://gitlab.psi.ch/bec/bec_widgets.git; cd bec_widgets; test -d bec_widgets || git clone --branch $CHILD_PIPELINE_BRANCH https://gitlab.psi.ch/bec/bec_widgets.git; cd bec_widgets;
fi fi
@ -92,10 +99,10 @@ pylint-check:
- git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
# Identify changed Python files # Identify changed Python files
- if [ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]; then - if [ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]; then
TARGET_BRANCH_COMMIT_SHA=$(git rev-parse origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME); TARGET_BRANCH_COMMIT_SHA=$(git rev-parse origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME);
CHANGED_FILES=$(git diff --name-only $TARGET_BRANCH_COMMIT_SHA HEAD | grep '\.py$' || true); CHANGED_FILES=$(git diff --name-only $TARGET_BRANCH_COMMIT_SHA HEAD | grep '\.py$' || true);
else else
CHANGED_FILES=$(git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA | grep '\.py$' || true); CHANGED_FILES=$(git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA | grep '\.py$' || true);
fi fi
- if [ -z "$CHANGED_FILES" ]; then echo "No Python files changed."; exit 0; fi - if [ -z "$CHANGED_FILES" ]; then echo "No Python files changed."; exit 0; fi
@ -120,7 +127,7 @@ tests:
stage: test stage: test
needs: [] needs: []
variables: variables:
QT_QPA_PLATFORM: "offscreen" QT_QPA_PLATFORM: "offscreen"
script: script:
- *clone-repos - *clone-repos
- *install-os-packages - *install-os-packages
@ -141,21 +148,21 @@ tests:
test-matrix: test-matrix:
parallel: parallel:
matrix: matrix:
- PYTHON_VERSION: - PYTHON_VERSION:
- "3.10" - "3.10"
- "3.11" - "3.11"
- "3.12" - "3.12"
QT_PCKG: QT_PCKG:
- "pyside6" - "pyside6"
- "pyqt5" - "pyqt5"
- "pyqt6" - "pyqt6"
stage: AdditionalTests stage: AdditionalTests
needs: [] needs: []
variables: variables:
QT_QPA_PLATFORM: "offscreen" QT_QPA_PLATFORM: "offscreen"
PYTHON_VERSION: "" PYTHON_VERSION: ""
QT_PCKG: "" QT_PCKG: ""
image: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/python:$PYTHON_VERSION image: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/python:$PYTHON_VERSION
script: script:
- *clone-repos - *clone-repos
@ -226,7 +233,7 @@ semver:
- pip install python-semantic-release==9.* wheel build twine - pip install python-semantic-release==9.* wheel build twine
- export GL_TOKEN=$CI_UPDATES - export GL_TOKEN=$CI_UPDATES
- semantic-release -vv version - semantic-release -vv version
# check if any artifacts were created # check if any artifacts were created
- if [ ! -d dist ]; then echo No release will be made; exit 0; fi - if [ ! -d dist ]; then echo No release will be made; exit 0; fi
- twine upload dist/* -u __token__ -p $CI_PYPI_TOKEN --skip-existing - twine upload dist/* -u __token__ -p $CI_PYPI_TOKEN --skip-existing
@ -242,7 +249,7 @@ pages:
variables: variables:
TARGET_BRANCH: $CI_COMMIT_REF_NAME TARGET_BRANCH: $CI_COMMIT_REF_NAME
rules: rules:
- if: '$CI_COMMIT_TAG != null' - if: "$CI_COMMIT_TAG != null"
variables: variables:
TARGET_BRANCH: $CI_COMMIT_TAG TARGET_BRANCH: $CI_COMMIT_TAG
- if: '$CI_COMMIT_REF_NAME == "main" && $CI_PROJECT_PATH == "bec/bec_widgets"' - if: '$CI_COMMIT_REF_NAME == "main" && $CI_PROJECT_PATH == "bec/bec_widgets"'