feat: refactor shared action
This commit was merged in pull request #1.
This commit is contained in:
133
action.yml
133
action.yml
@@ -1,29 +1,34 @@
|
|||||||
name: "BEC Plugin Repo Tests"
|
name: "BEC Plugin Repo Tests"
|
||||||
description: "Install and test a BEC plugin repository"
|
description: "Install and test a BEC plugin repository"
|
||||||
inputs:
|
inputs:
|
||||||
BEC_CORE_BRANCH: # id of input
|
BEC_PLUGIN_REPO_URL:
|
||||||
required: false
|
description: "URL of the BEC Plugin Repository to install"
|
||||||
default: "main"
|
|
||||||
description: "Branch of BEC Core to install"
|
|
||||||
OPHYD_DEVICES_BRANCH: # id of input
|
|
||||||
required: false
|
|
||||||
default: "main"
|
|
||||||
description: "Branch of Ophyd Devices to install"
|
|
||||||
BEC_WIDGETS_BRANCH: # id of input
|
|
||||||
required: false
|
|
||||||
default: "main"
|
|
||||||
description: "Branch of BEC Widgets to install"
|
|
||||||
BEC_PLUGIN_REPO_URL: # id of input
|
|
||||||
required: true
|
required: true
|
||||||
description: "URL of the BEC plugin repository to install"
|
default: ""
|
||||||
BEC_PLUGIN_REPO_BRANCH: # id of input
|
BEC_PLUGIN_REPO_BRANCH:
|
||||||
|
description: "Branch of the BEC Plugin Repository to install"
|
||||||
required: false
|
required: false
|
||||||
default: "main"
|
default: "main"
|
||||||
description: "Branch of the BEC plugin repository to install"
|
BEC_WIDGETS_BRANCH:
|
||||||
PYTHON_VERSION: # id of input
|
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
|
required: false
|
||||||
default: "3.11"
|
default: "3.11"
|
||||||
description: "Python version to use"
|
APT_PACKAGES:
|
||||||
|
description: "List of system packages to install via apt-get"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
@@ -33,8 +38,8 @@ runs:
|
|||||||
id: plugin_checkout
|
id: plugin_checkout
|
||||||
run: |
|
run: |
|
||||||
# Create a temporary directory for the plugin repository
|
# Create a temporary directory for the plugin repository
|
||||||
mkdir -p ./_checkout_/
|
mkdir -p ./_plugin_checkout_/
|
||||||
cd ./_checkout_/
|
cd ./_plugin_checkout_/
|
||||||
|
|
||||||
# Clone the repository with fallback for branch
|
# Clone the repository with fallback for branch
|
||||||
if git clone --depth 1 --branch "${{ inputs.BEC_PLUGIN_REPO_BRANCH }}" "${{ inputs.BEC_PLUGIN_REPO_URL }}"; then
|
if git clone --depth 1 --branch "${{ inputs.BEC_PLUGIN_REPO_BRANCH }}" "${{ inputs.BEC_PLUGIN_REPO_URL }}"; then
|
||||||
@@ -47,14 +52,100 @@ runs:
|
|||||||
cd ../
|
cd ../
|
||||||
# get the plugin repository name from the installed directory
|
# get the plugin repository name from the installed directory
|
||||||
PLUGIN_REPO_NAME=$(basename "${{ inputs.BEC_PLUGIN_REPO_URL }}" .git)
|
PLUGIN_REPO_NAME=$(basename "${{ inputs.BEC_PLUGIN_REPO_URL }}" .git)
|
||||||
echo "PLUGIN_REPO_NAME=${PLUGIN_REPO_NAME}" >> $GITEA_ENV
|
echo "PLUGIN_REPO_NAME=${PLUGIN_REPO_NAME}" >> $GITHUB_ENV #$GITEA_ENV
|
||||||
echo "Plugin repository name: $PLUGIN_REPO_NAME"
|
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
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ inputs.PYTHON_VERSION }}
|
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
|
# - name: Checkout BEC Core
|
||||||
# uses: actions/checkout@v4
|
# uses: actions/checkout@v4
|
||||||
# with:
|
# with:
|
||||||
|
|||||||
Reference in New Issue
Block a user