Skip to content

Commit 945f7eb

Browse files
committed
CI: enable GHA testing
1 parent 0a3f785 commit 945f7eb

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

.ci/drop-in.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
detselect(pilatus2M)
55

66
pilatus2M.cam.num_images.put(1)
7+
8+
RE(bp.count([pilatus2M], num=3))

.github/workflows/testing.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
run_tests:
10+
# pull requests are a duplicate of a branch push if within the same repo.
11+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
12+
13+
name: Test IPython startup files
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
conda-env-version: ["2024-3.0"]
18+
zenodo-id: ["14019710"]
19+
md5-checksum: ["0ec1899a4f5989292e07380f96b97498"]
20+
python-version: ["3.10"] # , "3.11", "3.12"]
21+
fail-fast: false
22+
env:
23+
TZ: America/New_York
24+
25+
defaults:
26+
run:
27+
shell: bash -l {0}
28+
29+
steps:
30+
- name: Set env vars
31+
run: |
32+
export REPOSITORY_NAME=${GITHUB_REPOSITORY#*/} # just the repo, as opposed to org/repo
33+
echo "REPOSITORY_NAME=${REPOSITORY_NAME}" >> $GITHUB_ENV
34+
35+
export PYTHONVER=$(echo ${{ matrix.python-version }} | sed 's/\.//g')
36+
echo "PYTHONVER=${PYTHONVER}" >> $GITHUB_ENV
37+
38+
export CONDA_ENV_NAME="${{ matrix.conda-env-version }}-py${PYTHONVER}-tiled"
39+
echo "CONDA_ENV_NAME=${CONDA_ENV_NAME}" >> $GITHUB_ENV
40+
41+
- name: Checkout the code
42+
uses: actions/checkout@v4
43+
44+
- name: Setup umamba
45+
uses: mamba-org/setup-micromamba@v1
46+
47+
- name: Setup umamba
48+
run: |
49+
set -vxeo pipefail
50+
url="https://zenodo.org/record/${{ matrix.zenodo-id }}/files/${CONDA_ENV_NAME}.tar.gz?download=1"
51+
wget --progress=dot:giga ${url} -O ${CONDA_ENV_NAME}.tar.gz
52+
status=$?
53+
if [ $status -gt 0 ]; then
54+
echo "Cannot download from ${url}. Exit code: ${status}"
55+
exit $status
56+
fi
57+
echo "${{ matrix.md5-checksum }} ${CONDA_ENV_NAME}.tar.gz" > checksum.txt
58+
md5sum --check checksum.txt
59+
mkdir -p $HOME/${CONDA_ENV_NAME}
60+
tar -xf ${CONDA_ENV_NAME}.tar.gz -C $HOME/${CONDA_ENV_NAME}
61+
conda activate $HOME/${CONDA_ENV_NAME}
62+
conda unpack
63+
64+
- name: Start MongoDB
65+
uses: supercharge/mongodb-github-action@1.6.0
66+
67+
- name: Prepare databroker config
68+
run: |
69+
set -vxeuo pipefail
70+
mkdir -v -p $HOME/.config/databroker/
71+
cp -v configs/databroker/local.yml $HOME/.config/databroker/
72+
73+
- name: Start epics-containers
74+
run: |
75+
set -vxeuo pipefail
76+
git clone --depth 1 --branch CMS-IOCs https://github.com/NSLS2/cms-epics-containers.git ~/cms-epics-containers
77+
source ~/cms-epics-containers/environment.sh
78+
cd ~/cms-epics-containers
79+
docker-compose up -d
80+
sleep 20
81+
82+
- name: Start caproto IOC
83+
run: |
84+
set -vxeuo pipefail
85+
source ~/cms-epics-containers/environment.sh
86+
echo "\n" | python iocs/spoof_beamline.py --list-pvs
87+
sleep 20
88+
89+
- name: Test the code
90+
run: |
91+
set -vxeuo pipefail
92+
# This is what IPython does internally to load the startup files:
93+
command="
94+
import os
95+
import glob
96+
ip = get_ipython()
97+
startup_files = sorted(glob.glob(os.path.join(os.getcwd(), 'startup/*.py')))
98+
if os.path.isfile('.ci/drop-in.py'):
99+
startup_files.append('.ci/drop-in.py')
100+
if not startup_files:
101+
raise SystemExit(f'Cannot find any startup files in {os.getcwd()}')
102+
for f in startup_files:
103+
if not os.path.isfile(f):
104+
raise FileNotFoundError(f'File {f} cannot be found.')
105+
print(f'Executing {f} in CI')
106+
ip.parent._exec_file(f)"
107+
108+
ipython --profile=test -c "$command"

0 commit comments

Comments
 (0)