Files
bec_shared_actions/action.yml
2025-09-23 18:02:36 -05:00

200 lines
7.4 KiB
YAML

name: "BEC Plugin Repo Tests"
description: "Install and test a BEC plugin repository"
inputs:
BEC_PLUGIN_REPO_URL:
description: "URL of the BEC Plugin Repository to install"
required: true
default: ""
BEC_PLUGIN_REPO_BRANCH:
description: "Branch of the BEC Plugin Repository to install"
required: false
default: "main"
BEC_WIDGETS_BRANCH:
description: "Branch of BEC Widgets to install"
required: false
default: "main"
BEC_CORE_BRANCH:
description: "Branch of BEC Core to install"
required: false
default: "main"
OPHYD_DEVICES_BRANCH:
description: "Branch of Ophyd Devices to install"
required: false
default: "main"
PYTHON_VERSION:
description: "Python version to use"
required: false
default: "3.11"
APT_PACKAGES:
description: "List of system packages to install via apt-get"
required: false
default: ""
runs:
using: "composite"
steps:
- name: Checkout BEC Plugin Repository
shell: bash
id: plugin_checkout
run: |
# Create a temporary directory for the plugin repository
mkdir -p ./_plugin_checkout_/
cd ./_plugin_checkout_/
# Clone the repository with fallback for branch
if git clone --depth 1 --branch "${{ inputs.BEC_PLUGIN_REPO_BRANCH }}" "${{ inputs.BEC_PLUGIN_REPO_URL }}"; then
echo "Successfully cloned with branch ${{ inputs.BEC_PLUGIN_REPO_BRANCH }}"
else
echo "Failed to clone with branch ${{ inputs.BEC_PLUGIN_REPO_BRANCH }}, trying without specific branch"
git clone --depth 1 "${{ inputs.BEC_PLUGIN_REPO_URL }}"
fi
cd ../
# get the plugin repository name from the installed directory
PLUGIN_REPO_NAME=$(basename "${{ inputs.BEC_PLUGIN_REPO_URL }}" .git)
echo "PLUGIN_REPO_NAME=${PLUGIN_REPO_NAME}" >> $GITHUB_ENV #$GITEA_ENV
echo "Plugin repository name: $PLUGIN_REPO_NAME"
- name: Checkout BEC Core
shell: bash
id: bec_core_checkout
run: |
# Create a temporary directory for the plugin repository
mkdir -p ./_bec_checkout_/
cd ./_bec_checkout_/
# Clone the repository with fallback for branch
if git clone --depth 1 --branch "${{ inputs.BEC_CORE_BRANCH }}" https://github.com/bec-project/bec.git; then
echo "Successfully cloned with branch ${{ inputs.BEC_CORE_BRANCH }}"
else
echo "Failed to clone with branch ${{ inputs.BEC_CORE_BRANCH }}, trying without specific branch"
git clone --depth 1 https://github.com/bec-project/bec.git
fi
cd ../
- name: Install Ophyd Devices
shell: bash
id: ophyd_devices_checkout
run: |
# Create a temporary directory for the plugin repository
mkdir -p ./_ophyd_devices_checkout_/
cd ./_ophyd_devices_checkout_/
# Clone the repository with fallback for branch
if git clone --depth 1 --branch "${{ inputs.OPHYD_DEVICES_BRANCH }}" https://github.com/bec-project/ophyd_devices.git; then
echo "Successfully cloned with branch ${{ inputs.OPHYD_DEVICES_BRANCH }}"
else
echo "Failed to clone with branch ${{ inputs.OPHYD_DEVICES_BRANCH }}, trying without specific branch"
git clone --depth 1 https://github.com/bec-project/ophyd_devices.git
fi
cd ../
- name: Install BEC Widgets
shell: bash
id: bec_widgets_checkout
run: |
# Create a temporary directory for the plugin repository
mkdir -p ./_bec_widgets_checkout_/
cd ./_bec_widgets_checkout_/
# Clone the repository with fallback for branch
if git clone --depth 1 --branch "${{ inputs.BEC_WIDGETS_BRANCH }}" https://github.com/bec-project/bec_widgets.git; then
echo "Successfully cloned with branch ${{ inputs.BEC_WIDGETS_BRANCH }}"
else
echo "Failed to clone with branch ${{ inputs.BEC_WIDGETS_BRANCH }}, trying without specific branch"
git clone --depth 1 https://github.com/bec-project/bec_widgets.git
fi
cd ../
- name: Install APT_PACKAGES
if: ${{ inputs.APT_PACKAGES != '' }}
shell: bash
run: |
echo "Installing additional APT packages: ${{ inputs.APT_PACKAGES }}"
sudo apt-get update
sudo apt-get install -y ${{ inputs.APT_PACKAGES }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.PYTHON_VERSION }}
- name: Install Python dependencies
shell: bash
run: |
python -m pip install --upgrade pip
# Install Core dependencies
pip install uv
uv pip install --system -e ./_bec_checkout_/bec/bec_lib/[dev]
uv pip install --system -e ./_bec_checkout_/bec/bec_ipython_client
uv pip install --system -e ./_bec_checkout_/bec/bec_server[dev]
uv pip install --system -e ./_bec_widgets_checkout_/bec_widgets[dev,pyside6]
uv pip install --system -e ./_ophyd_devices_checkout_/ophyd_devices[dev]
# plugin repo name was stored earlier
source $GITHUB_ENV
pip install -e "./_plugin_checkout_/${PLUGIN_REPO_NAME}[dev]"
- name: Run pytest for Plugin
shell: bash
run: |
source $GITHUB_ENV
cd "./_plugin_checkout_/${PLUGIN_REPO_NAME}"
pytest --random-order --cov=./"${PLUGIN_REPO_NAME}" --cov-config=./"${PLUGIN_REPO_NAME}"/pyproject.toml --cov-branch --cov-report=xml --no-cov-on-fail ./"${PLUGIN_REPO_NAME}"/tests/ || test $? -eq 5
# - name: Checkout BEC Core
# uses: actions/checkout@v4
# with:
# repository: bec/bec
# ref: ${{ inputs.BEC_CORE_BRANCH }}
# path: ./_checkout_/bec
# - name: Checkout Ophyd Devices
# uses: actions/checkout@v4
# with:
# repository: bec/ophyd_devices
# ref: ${{ inputs.OPHYD_DEVICES_BRANCH }}
# path: ./_checkout_/ophyd_devices
# - name: Checkout BEC Widgets
# uses: actions/checkout@v4
# with:
# repository: bec/bec_widgets
# ref: ${{ inputs.BEC_WIDGETS_BRANCH }}
# path: ./_checkout_/bec_widgets
# - name: Install dependencies
# shell: bash
# 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: Install Python dependencies
# shell: bash
# run: |
# pip install uv
# # print the current directory to verify the structure
# echo "Current directory: $(pwd)"
# echo "Available directories: $(ls _checkout_)"
# PLUGIN_REPO_NAME=$(basename "${{ inputs.BEC_PLUGIN_REPO_URL }}" .git)
# echo "Plugin repository name: $PLUGIN_REPO_NAME"
# uv pip install --system -e ./_checkout_/ophyd_devices[dev]
# uv pip install --system -e ./_checkout_/bec/bec_lib[dev]
# uv pip install --system -e ./_checkout_/bec/bec_ipython_client[dev]
# uv pip install --system -e ./_checkout_/bec/bec_server[dev]
# uv pip install --system -e ./_checkout_/bec_widgets[dev]
# uv pip install --system -e ./_checkout_/${PLUGIN_REPO_NAME}[dev]
# - name: Run Pytest
# shell: bash
# run: |
# PLUGIN_REPO_NAME=$(basename "${{ inputs.BEC_PLUGIN_REPO_URL }}" .git)
# echo "Running tests for: $PLUGIN_REPO_NAME"
# cd ./_checkout_/${PLUGIN_REPO_NAME}
# pytest -v --maxfail=2 --random-order ./tests