mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-13 19:21:50 +02:00
ci: add github workflows
This commit is contained in:
15
.github/workflows/ci.yml
vendored
Normal file
15
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
name: Full CI
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
formatter:
|
||||||
|
uses: ./.github/workflows/formatter.yml
|
||||||
|
|
||||||
|
unit-test:
|
||||||
|
uses: ./.github/workflows/pytest.yml
|
||||||
|
|
||||||
|
unit-test-matrix:
|
||||||
|
uses: ./.github/workflows/pytest-matrix.yml
|
||||||
|
|
||||||
|
end2end-test:
|
||||||
|
uses: ./.github/workflows/end2end-conda.yml
|
48
.github/workflows/end2end-conda.yml
vendored
Normal file
48
.github/workflows/end2end-conda.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
name: Run Pytest with Coverage
|
||||||
|
on: [workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pytest:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash -el {0}
|
||||||
|
|
||||||
|
env:
|
||||||
|
CHILD_PIPELINE_BRANCH: main # Set the branch you want for ophyd_devices
|
||||||
|
BEC_CORE_BRANCH: main # Set the branch you want for bec
|
||||||
|
OPHYD_DEVICES_BRANCH: main # Set the branch you want for ophyd_devices
|
||||||
|
PROJECT_PATH: ${{ github.repository }}
|
||||||
|
QTWEBENGINE_DISABLE_SANDBOX: 1
|
||||||
|
QT_QPA_PLATFORM: "offscreen"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Conda
|
||||||
|
uses: conda-incubator/setup-miniconda@v3
|
||||||
|
with:
|
||||||
|
auto-update-conda: true
|
||||||
|
auto-activate-base: true
|
||||||
|
python-version: '3.11'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libgl1 libegl1 x11-utils libxkbcommon-x11-0 libdbus-1-3 xvfb
|
||||||
|
sudo apt-get -y install libnss3 libxdamage1 libasound2t64 libatomic1 libxcursor1
|
||||||
|
|
||||||
|
- name: Conda install and run pytest
|
||||||
|
run: |
|
||||||
|
echo -e "\033[35;1m Using branch $BEC_CORE_BRANCH of BEC CORE \033[0;m";
|
||||||
|
git clone --branch $BEC_CORE_BRANCH https://gitlab.psi.ch/bec/bec.git
|
||||||
|
echo -e "\033[35;1m Using branch $OPHYD_DEVICES_BRANCH of OPHYD_DEVICES \033[0;m";
|
||||||
|
git clone --branch $OPHYD_DEVICES_BRANCH https://gitlab.psi.ch/bec/ophyd_devices.git
|
||||||
|
export OHPYD_DEVICES_PATH=$PWD/ophyd_devices
|
||||||
|
cd ./bec
|
||||||
|
conda create -q -n test-environment python=3.11
|
||||||
|
source ./bin/install_bec_dev.sh -t
|
||||||
|
cd ../
|
||||||
|
pip install -e ./ophyd_devices
|
||||||
|
pip install -e .[dev,pyside6]
|
||||||
|
pytest -v --files-path ./ --start-servers --random-order ./tests/end-2-end
|
61
.github/workflows/formatter.yml
vendored
Normal file
61
.github/workflows/formatter.yml
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
name: Formatter and Pylint jobs
|
||||||
|
on: [workflow_call]
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
Formatter:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.13'
|
||||||
|
|
||||||
|
- name: Run black and isort
|
||||||
|
run: |
|
||||||
|
pip install black isort
|
||||||
|
pip install -e .[dev]
|
||||||
|
black --check --diff --color .
|
||||||
|
isort --check --diff ./
|
||||||
|
Pylint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.13'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install pylint pylint-exit anybadge
|
||||||
|
|
||||||
|
- name: Run Pylint
|
||||||
|
run: |
|
||||||
|
mkdir -p ./pylint
|
||||||
|
set +e
|
||||||
|
pylint ./${{ github.event.repository.name }} --output-format=text > ./pylint/pylint.log
|
||||||
|
pylint-exit $?
|
||||||
|
set -e
|
||||||
|
|
||||||
|
- name: Extract Pylint Score
|
||||||
|
id: score
|
||||||
|
run: |
|
||||||
|
SCORE=$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' ./pylint/pylint.log)
|
||||||
|
echo "score=$SCORE" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create Badge
|
||||||
|
run: |
|
||||||
|
anybadge --label=Pylint --file=./pylint/pylint.svg --value="${{ steps.score.outputs.score }}" 2=red 4=orange 8=yellow 10=green
|
||||||
|
|
||||||
|
- name: Upload Artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: pylint-artifacts
|
||||||
|
path: |
|
||||||
|
# ./pylint/pylint.log # not sure why this isn't working
|
||||||
|
./pylint/pylint.svg
|
48
.github/workflows/pytest-matrix.yml
vendored
Normal file
48
.github/workflows/pytest-matrix.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
name: Run Pytest with different Python versions
|
||||||
|
on: [workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pytest-matrix:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.10", "3.11", "3.12"]
|
||||||
|
|
||||||
|
env:
|
||||||
|
CHILD_PIPELINE_BRANCH: main # Set the branch you want for ophyd_devices
|
||||||
|
BEC_CORE_BRANCH: main # Set the branch you want for bec
|
||||||
|
OPHYD_DEVICES_BRANCH: main # Set the branch you want for ophyd_devices
|
||||||
|
PROJECT_PATH: ${{ github.repository }}
|
||||||
|
QTWEBENGINE_DISABLE_SANDBOX: 1
|
||||||
|
QT_QPA_PLATFORM: "offscreen"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libgl1 libegl1 x11-utils libxkbcommon-x11-0 libdbus-1-3 xvfb
|
||||||
|
sudo apt-get -y install libnss3 libxdamage1 libasound2t64 libatomic1 libxcursor1
|
||||||
|
|
||||||
|
- name: Clone and install dependencies
|
||||||
|
run: |
|
||||||
|
echo -e "\033[35;1m Using branch $BEC_CORE_BRANCH of BEC CORE \033[0;m";
|
||||||
|
git clone --branch $BEC_CORE_BRANCH https://gitlab.psi.ch/bec/bec.git
|
||||||
|
echo -e "\033[35;1m Using branch $OPHYD_DEVICES_BRANCH of OPHYD_DEVICES \033[0;m";
|
||||||
|
git clone --branch $OPHYD_DEVICES_BRANCH https://gitlab.psi.ch/bec/ophyd_devices.git
|
||||||
|
export OHPYD_DEVICES_PATH=$PWD/ophyd_devices
|
||||||
|
pip install -e ./ophyd_devices
|
||||||
|
pip install -e ./bec/bec_lib[dev]
|
||||||
|
pip install -e ./bec/bec_ipython_client
|
||||||
|
pip install -e .[dev,pyside6]
|
||||||
|
|
||||||
|
- name: Run Pytest
|
||||||
|
run: |
|
||||||
|
pip install pytest pytest-random-order
|
||||||
|
pytest -v --maxfail=2 --junitxml=report.xml --random-order ./tests/unit_tests
|
47
.github/workflows/pytest.yml
vendored
Normal file
47
.github/workflows/pytest.yml
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
name: Run Pytest with Coverage
|
||||||
|
on: [workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pytest:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
env:
|
||||||
|
CHILD_PIPELINE_BRANCH: main # Set the branch you want for ophyd_devices
|
||||||
|
BEC_CORE_BRANCH: main # Set the branch you want for bec
|
||||||
|
OPHYD_DEVICES_BRANCH: main # Set the branch you want for ophyd_devices
|
||||||
|
PROJECT_PATH: ${{ github.repository }}
|
||||||
|
QTWEBENGINE_DISABLE_SANDBOX: 1
|
||||||
|
QT_QPA_PLATFORM: "offscreen"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libgl1 libegl1 x11-utils libxkbcommon-x11-0 libdbus-1-3 xvfb
|
||||||
|
sudo apt-get -y install libnss3 libxdamage1 libasound2t64 libatomic1 libxcursor1
|
||||||
|
|
||||||
|
- name: Clone and install dependencies
|
||||||
|
run: |
|
||||||
|
echo -e "\033[35;1m Using branch $BEC_CORE_BRANCH of BEC CORE \033[0;m";
|
||||||
|
git clone --branch $BEC_CORE_BRANCH https://gitlab.psi.ch/bec/bec.git
|
||||||
|
echo -e "\033[35;1m Using branch $OPHYD_DEVICES_BRANCH of OPHYD_DEVICES \033[0;m";
|
||||||
|
git clone --branch $OPHYD_DEVICES_BRANCH https://gitlab.psi.ch/bec/ophyd_devices.git
|
||||||
|
export OHPYD_DEVICES_PATH=$PWD/ophyd_devices
|
||||||
|
pip install -e ./ophyd_devices
|
||||||
|
pip install -e ./bec/bec_lib[dev]
|
||||||
|
pip install -e ./bec/bec_ipython_client
|
||||||
|
pip install -e .[dev,pyside6]
|
||||||
|
|
||||||
|
- name: Run Pytest with Coverage
|
||||||
|
run: |
|
||||||
|
pip install coverage pytest pytest-random-order
|
||||||
|
coverage run --source=./bec_widgets -m pytest -v --junitxml=report.xml --maxfail=2 --random-order --full-trace ./tests/unit_tests
|
||||||
|
coverage report
|
||||||
|
coverage xml
|
Reference in New Issue
Block a user