The 'Checkout BEC Plugin Repository' step pinned repository to bec/csaxs_bec with ref github.head_ref. For a pull request opened from a fork, head_ref is the fork's branch name, which does not exist in the base repo, so the checkout failed with 'git ... exit code 1' before any tests ran. Fall through to github.sha instead: on pull_request events that is the test-merge commit, which lives in the base repo, so the checkout succeeds for fork PRs and in-repo branches alike (and gates on the merged result). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
95 lines
3.4 KiB
YAML
95 lines
3.4 KiB
YAML
name: CI for csaxs_bec
|
|
on:
|
|
push:
|
|
pull_request:
|
|
workflow_dispatch:
|
|
inputs:
|
|
BEC_WIDGETS_BRANCH:
|
|
description: "Branch of BEC Widgets to install"
|
|
required: false
|
|
type: string
|
|
default: "main"
|
|
BEC_CORE_BRANCH:
|
|
description: "Branch of BEC Core to install"
|
|
required: false
|
|
type: string
|
|
default: "main"
|
|
OPHYD_DEVICES_BRANCH:
|
|
description: "Branch of Ophyd Devices to install"
|
|
required: false
|
|
type: string
|
|
default: "main"
|
|
BEC_PLUGIN_REPO_BRANCH:
|
|
description: "Branch of the BEC Plugin Repository to install"
|
|
required: false
|
|
type: string
|
|
default: "main"
|
|
PYTHON_VERSION:
|
|
description: "Python version to use"
|
|
required: false
|
|
type: string
|
|
default: "3.12"
|
|
|
|
permissions:
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
QTWEBENGINE_DISABLE_SANDBOX: 1
|
|
QT_QPA_PLATFORM: "offscreen"
|
|
|
|
steps:
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "${{ inputs.PYTHON_VERSION || '3.12' }}"
|
|
|
|
- name: Checkout BEC Plugin Repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: bec/csaxs_bec
|
|
# For pull_request events github.sha is the test-merge commit, which
|
|
# lives in the base repo, so this works for fork PRs too. Using
|
|
# github.head_ref here would try to fetch the fork's branch name from
|
|
# bec/csaxs_bec, where it does not exist -> checkout fails (exit 1).
|
|
ref: "${{ inputs.BEC_PLUGIN_REPO_BRANCH || github.sha }}"
|
|
path: ./csaxs_bec
|
|
|
|
- name: Lint for merge conflicts from template updates
|
|
shell: bash
|
|
# Find all Copier conflicts except this line
|
|
run: '! grep -r "<<<<<<< before updating" | grep -v "grep -r \"<<<<<<< before updating"'
|
|
|
|
- name: Checkout BEC Core
|
|
run: git clone --depth 1 --branch "${{ inputs.BEC_CORE_BRANCH || 'main' }}" https://github.com/bec-project/bec.git ./bec
|
|
|
|
- name: Checkout Ophyd Devices
|
|
run: git clone --depth 1 --branch "${{ inputs.OPHYD_DEVICES_BRANCH || 'main' }}" https://github.com/bec-project/ophyd_devices.git ./ophyd_devices
|
|
|
|
- name: Checkout BEC Widgets
|
|
run: git clone --depth 1 --branch "${{ inputs.BEC_WIDGETS_BRANCH || 'main' }}" https://github.com/bec-project/bec_widgets.git ./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
|
|
uv pip install --system -e ./ophyd_devices
|
|
uv pip install --system -e ./bec/bec_lib[dev]
|
|
uv pip install --system -e ./bec/bec_ipython_client
|
|
uv pip install --system -e ./bec/bec_server[dev]
|
|
uv pip install --system -e ./bec_widgets[dev,pyside6]
|
|
uv pip install --system -e ./csaxs_bec
|
|
|
|
- name: Run Pytest with Coverage
|
|
id: coverage
|
|
run: pytest --random-order --cov=./csaxs_bec --cov-config=./csaxs_bec/pyproject.toml --cov-branch --cov-report=xml --no-cov-on-fail ./csaxs_bec/tests/ || test $? -eq 5
|