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: | # Echo inputs for debugging echo "Running BEC Plugin Repo composite action" echo "BEC_PLUGIN_REPO_URL: ${{ inputs.BEC_PLUGIN_REPO_URL }}" # Create log directory OUTPUT_DIR="$PWD/outputs" # absolute path LOG_FILE="${OUTPUT_DIR}/checkout.log" mkdir -p "$OUTPUT_DIR" # Create a temporary directory for the plugin repository mkdir -p ./_plugin_checkout_/ cd ./_plugin_checkout_/ echo "Cloning repository: ${{ inputs.BEC_PLUGIN_REPO_URL }}" | tee -a "$LOG_FILE" echo "Using branch: ${{ inputs.BEC_PLUGIN_REPO_BRANCH }}" | tee -a "$LOG_FILE" # Clone the repository with fallback for branch if git clone --depth 1 --branch "${{ inputs.BEC_PLUGIN_REPO_BRANCH }}" "${{ inputs.BEC_PLUGIN_REPO_URL }}" | tee -a "$LOG_FILE"; then rc=${PIPESTATUS[0]} echo "Successfully cloned with branch ${{ inputs.BEC_PLUGIN_REPO_BRANCH }}" | tee -a "$LOG_FILE" else echo "Failed to clone with branch ${{ inputs.BEC_PLUGIN_REPO_BRANCH }}, trying without specific branch" | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} git clone --depth 1 "${{ inputs.BEC_PLUGIN_REPO_URL }}" | tee -a "$LOG_FILE" 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" echo "Completed BEC Plugin Repo checkout" echo "Exit Code: $rc" >> $LOG_FILE - name: Checkout BEC Core shell: bash id: bec_core_checkout run: | # Echo inputs for debugging echo "Running BEC Core checkout" echo "BEC_CORE_BRANCH: ${{ inputs.BEC_CORE_BRANCH }}" # Create log directory OUTPUT_DIR="$PWD/outputs" # absolute path LOG_FILE="${OUTPUT_DIR}/checkout_bec_core.log" echo "Cloning BEC Core repository" | tee -a "$LOG_FILE" echo "Using branch: ${{ inputs.BEC_CORE_BRANCH }}" | tee -a "$LOG_FILE" # 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 | tee -a "$LOG_FILE"; then rc=${PIPESTATUS[0]} echo "Successfully cloned with branch ${{ inputs.BEC_CORE_BRANCH }}" | tee -a "$LOG_FILE" else echo "Failed to clone with branch ${{ inputs.BEC_CORE_BRANCH }}, trying without specific branch" | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} git clone --depth 1 https://github.com/bec-project/bec.git | tee -a "$LOG_FILE" fi echo "Completed BEC Core checkout" echo "Exit Code: $rc" >> $LOG_FILE cd ../ - name: Checkout Ophyd Devices shell: bash id: ophyd_devices_checkout run: | # Echo inputs for debugging echo "Running Ophyd Devices checkout" echo "OPHYD_DEVICES_BRANCH: ${{ inputs.OPHYD_DEVICES_BRANCH }}" # Create log directory OUTPUT_DIR="$PWD/outputs" # absolute path LOG_FILE="${OUTPUT_DIR}/checkout_ophyd_devices.log" # Create a temporary directory for the plugin repository mkdir -p ./_ophyd_devices_checkout_/ cd ./_ophyd_devices_checkout_/ echo "Cloning Ophyd Devices repository" | tee -a "$LOG_FILE" echo "Using branch: ${{ inputs.OPHYD_DEVICES_BRANCH }}" | tee -a "$LOG_FILE" # 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 | tee -a "$LOG_FILE"; then rc=${PIPESTATUS[0]} echo "Successfully cloned with branch ${{ inputs.OPHYD_DEVICES_BRANCH }}" | tee -a "$LOG_FILE" else echo "Failed to clone with branch ${{ inputs.OPHYD_DEVICES_BRANCH }}, trying without specific branch" | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} git clone --depth 1 https://github.com/bec-project/ophyd_devices.git | tee -a "$LOG_FILE" fi echo "Completed Ophyd Devices checkout" echo "Exit Code: $rc" >> $LOG_FILE cd ../ - name: Checkout BEC Widgets shell: bash id: bec_widgets_checkout run: | # Echo inputs for debugging echo "Running BEC Widgets checkout" echo "BEC_WIDGETS_BRANCH: ${{ inputs.BEC_WIDGETS_BRANCH }}" # Create log directory OUTPUT_DIR="$PWD/outputs" # absolute path LOG_FILE="${OUTPUT_DIR}/checkout_bec_widgets.log" # Create a temporary directory for the plugin repository mkdir -p ./_bec_widgets_checkout_/ cd ./_bec_widgets_checkout_/ echo "Cloning BEC Widgets repository" | tee -a "$LOG_FILE" echo "Using branch: ${{ inputs.BEC_WIDGETS_BRANCH }}" | tee -a "$LOG_FILE" # 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 | tee -a "$LOG_FILE"; then rc=${PIPESTATUS[0]} echo "Successfully cloned with branch ${{ inputs.BEC_WIDGETS_BRANCH }}" | tee -a "$LOG_FILE" else echo "Failed to clone with branch ${{ inputs.BEC_WIDGETS_BRANCH }}, trying without specific branch" | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} git clone --depth 1 https://github.com/bec-project/bec_widgets.git | tee -a "$LOG_FILE" fi echo "Completed BEC Widgets checkout" echo "Exit Code: $rc" >> $LOG_FILE cd ../ - name: Install APT_PACKAGES if: ${{ inputs.APT_PACKAGES != '' }} shell: bash run: | # Echo inputs for debugging echo "Installing APT packages" echo "APT_PACKAGES: ${{ inputs.APT_PACKAGES }}" # Create log directory OUTPUT_DIR="$PWD/outputs" # absolute path LOG_FILE="${OUTPUT_DIR}/install_apt_packages.log" echo "Installing additional APT packages: ${{ inputs.APT_PACKAGES }}" | tee -a "$LOG_FILE" sudo apt-get update | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} if [ $rc -ne 0 ]; then echo "Exit Code: $rc" >> $LOG_FILE exit $rc fi sudo apt-get install -y ${{ inputs.APT_PACKAGES }} | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} echo "Completed APT package installation" echo "Exit Code: $rc" >> $LOG_FILE - name: Setup Python uses: actions/setup-python@v4 with: python-version: ${{ inputs.PYTHON_VERSION }} - name: Install Python dependencies shell: bash run: | # Echo inputs for debugging echo "Running Python dependencies installation" echo "PYTHON_VERSION: ${{ inputs.PYTHON_VERSION }}" # Create log directory OUTPUT_DIR="$PWD/outputs" # absolute path LOG_FILE="${OUTPUT_DIR}/install_python_dependencies.log" echo "Installing Python dependencies" | tee -a "$LOG_FILE" echo "Using Python version: $(python --version)" | tee -a "$LOG_FILE" python -m pip install --upgrade pip | tee -a "$LOG_FILE" # Install Core dependencies pip install uv | tee -a "$LOG_FILE" uv pip install --system -e ./_bec_checkout_/bec/bec_lib/[dev] | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} if [ $rc -ne 0 ]; then echo "Exit Code: $rc" >> $LOG_FILE exit $rc fi uv pip install --system -e ./_bec_checkout_/bec/bec_ipython_client | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} if [ $rc -ne 0 ]; then echo "Exit Code: $rc" >> $LOG_FILE exit $rc fi uv pip install --system -e ./_bec_checkout_/bec/bec_server[dev] | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} if [ $rc -ne 0 ]; then echo "Exit Code: $rc" >> $LOG_FILE exit $rc fi uv pip install --system -e ./_bec_widgets_checkout_/bec_widgets[dev,pyside6] | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} if [ $rc -ne 0 ]; then echo "Exit Code: $rc" >> $LOG_FILE exit $rc fi uv pip install --system -e ./_ophyd_devices_checkout_/ophyd_devices[dev] | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} if [ $rc -ne 0 ]; then echo "Exit Code: $rc" >> $LOG_FILE exit $rc fi # plugin repo name was stored earlier source $GITHUB_ENV pip install -e "./_plugin_checkout_/${PLUGIN_REPO_NAME}[dev]" | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} echo "Exit Code: $rc" >> $LOG_FILE echo "Completed Python dependencies installation" - name: Run pytest for Plugin shell: bash run: | # Echo inputs for debugging echo "Running pytest for plugin repository" echo "PLUGIN_REPO_NAME: $PLUGIN_REPO_NAME" # Create log directory OUTPUT_DIR="$PWD/outputs" # absolute path LOG_FILE="${OUTPUT_DIR}/pytest_plugin.log" echo "Running pytest for plugin repository" | tee -a "$LOG_FILE" source $GITHUB_ENV cd "./_plugin_checkout_/${PLUGIN_REPO_NAME}" # run pytest and capture its exit code pytest --random-order --cov=. --cov-config=./pyproject.toml \ --cov-branch --cov-report=xml --no-cov-on-fail ./tests/ \ 2>&1 | tee -a "$LOG_FILE" rc=${PIPESTATUS[0]} # exit code of pytest in a pipe if [ "$rc" -eq 0 ] || [ "$rc" -eq 5 ]; then echo "Exit Code: 0" >> $LOG_FILE else echo "Exit Code: $rc" >> $LOG_FILE fi echo "Completed pytest for plugin repository"