Add baseline configuration & Sirepo/MAD-X updates #100
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
run_tests: | |
# pull requests are a duplicate of a branch push if within the same repo. | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository | |
name: Test IPython startup files | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.9"] | |
pylon-version: ["5.2.0.13457-deb0_amd64"] | |
fail-fast: false | |
env: | |
TZ: America/New_York | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- name: Set env vars | |
run: | | |
export REPOSITORY_NAME=${GITHUB_REPOSITORY#*/} # just the repo, as opposed to org/repo | |
echo "REPOSITORY_NAME=${REPOSITORY_NAME}" >> $GITHUB_ENV | |
export ATF_OPEN_CONN_ONCE="yes" | |
echo "ATF_OPEN_CONN_ONCE=${ATF_OPEN_CONN_ONCE}" >> $GITHUB_ENV | |
export ATF_SOCKET_HOST="localhost" | |
echo "ATF_SOCKET_HOST=${ATF_SOCKET_HOST}" >> $GITHUB_ENV | |
export ATF_SOCKET_PORT=5000 | |
echo "ATF_SOCKET_PORT=${ATF_SOCKET_PORT}" >> $GITHUB_ENV | |
export ATF_SIREPO_URL="http://localhost:8000" | |
echo "ATF_SIREPO_URL=${ATF_SIREPO_URL}" >> $GITHUB_ENV | |
export PYLON_CAMEMU=10 | |
echo "PYLON_CAMEMU=${PYLON_CAMEMU}" >> $GITHUB_ENV | |
export PYLON_CAM_PIXEL_FORMAT="Mono16" | |
echo "PYLON_CAM_PIXEL_FORMAT=${PYLON_CAM_PIXEL_FORMAT}" >> $GITHUB_ENV | |
export PYLON_ROOT="/opt/pylon5" | |
echo "PYLON_ROOT=${PYLON_ROOT}" >> $GITHUB_ENV | |
- name: Checkout the code | |
uses: actions/checkout@v3 | |
- name: Install Pylon .deb package | |
run: | | |
# For reference: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html. | |
set -vxeuo pipefail | |
wget --progress=dot:mega ${{ secrets.PYLON_DOWNLOAD_URL_BASE }}/pylon_${{ matrix.pylon-version }}.deb -O pylon.deb | |
sudo dpkg -i pylon.deb | |
- name: Set up Python ${{ matrix.python-version }} with conda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
activate-environment: ${{ env.REPOSITORY_NAME }}-py${{ matrix.python-version }} | |
auto-update-conda: true | |
miniconda-version: "latest" | |
python-version: ${{ matrix.python-version }} | |
mamba-version: "*" | |
channels: conda-forge | |
- name: Install the package and its dependencies | |
run: | | |
# set -vxeuo pipefail | |
# Do not check for unbound variables (the '-u' flag) as it fails on | |
# conda deactivate command: | |
# /usr/share/miniconda3/envs/sirepo-bluesky-py3.9/etc/conda/deactivate.d/glib_deactivate.sh: | |
# line 1: GSETTINGS_SCHEMA_DIR_CONDA_BACKUP: unbound variable | |
set -vxeo pipefail | |
conda env list | |
# mamba install -c conda-forge -y numpy matplotlib ipython ophyd bluesky databroker sirepo-bluesky | |
pip install numpy matplotlib ipython ophyd bluesky databroker sirepo-bluesky "ophyd-basler>=0.2.1" "atfdb>=0.2.0" | |
# Those lines are to install dev version of the packages. Update the branches as needed. | |
# pip install -v git+https://github.com/BNL-ATF/ophyd-basler@main | |
# pip install -v git+https://github.com/BNL-ATF/atfdb@main | |
pip list | |
conda list | |
- name: Start MongoDB | |
uses: supercharge/mongodb-github-action@1.6.0 | |
- name: Start Sirepo Docker container | |
uses: NSLS-II/start-sirepo-action@v2 | |
with: | |
docker-binary: docker | |
- name: Start fake socket server | |
run: | | |
set -vxeuo pipefail | |
nohup test-socket-server > /tmp/socket.log 2>&1 & | |
- name: Prepare databroker config | |
run: | | |
set -vxeuo pipefail | |
mkdir -v -p $HOME/.config/databroker/ | |
cp -v configs/databroker/local.yml $HOME/.config/databroker/ | |
- name: Test the code | |
run: | | |
set -vxeuo pipefail | |
# This is what IPython does internally to load the startup files: | |
command=" | |
import os | |
import glob | |
ip = get_ipython() | |
startup_files = sorted(glob.glob(os.path.join(os.getcwd(), 'startup/*.py'))) | |
if os.path.isfile('.ci/drop-in.py'): | |
startup_files.append('.ci/drop-in.py') | |
if not startup_files: | |
raise SystemExit(f'Cannot find any startup files in {os.getcwd()}') | |
for f in startup_files: | |
if not os.path.isfile(f): | |
raise FileNotFoundError(f'File {f} cannot be found.') | |
print(f'Executing {f} in CI') | |
ip.parent._exec_file(f)" | |
ipython --profile=test -c "$command" | |
status=$? | |
export ATF_PROFILE_TEST_STATUS="${status}" | |
echo "ATF_PROFILE_TEST_STATUS=${ATF_PROFILE_TEST_STATUS}" >> $GITHUB_ENV | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: basler-custom-images | |
path: | | |
# raw input files passed to Pylon | |
/tmp/wandering_gaussian_beam/*.png | |
# HDF5 file(s) generated after bluesky scan(s) | |
~/mnt/atfsim_sirepo/data/ | |
# MPL grid plot of the images obtained via 'hdr.data(...)' | |
/tmp/test_emulated_basler_camera.png | |
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` | |
- name: Check socket server logs | |
run: | | |
set -vxeuo pipefail | |
cat /tmp/socket.log | |
- name: Check Sirepo server logs | |
run: | | |
set -vxeuo pipefail | |
docker ps -a | |
echo "Sirepo docker container id: ${SIREPO_DOCKER_CONTAINER_ID}" | |
docker logs ${SIREPO_DOCKER_CONTAINER_ID} | |
if [ ${ATF_PROFILE_TEST_STATUS} -gt 0 ]; then | |
exit ${ATF_PROFILE_TEST_STATUS} | |
fi |