Skip to content

Commit

Permalink
Merge pull request #6 from epics-containers/dev
Browse files Browse the repository at this point in the history
Get CI working and tidy Read me
  • Loading branch information
gilesknap authored Oct 2, 2023
2 parents ae0d69d + 7fc659a commit 9331b52
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 56 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/buiild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ jobs:
PLATFORM: ${{ matrix.platform }}
CACHE: ${{ env.CACHE }}
run: |
# ioc folder is found in the super module usually so for testing
# on github we need to copy it above the root of the repo
cp -r ioc ..
for test in tests/test*.sh; do
for test in tests/*.sh; do
echo "RUNNING TEST SCRIPT ${test}"
${test}
done
tests/_test_support_build.sh
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ Each support module folder contains:-
support module. The script can contain any commands that are required
but would usually be a series of calls to `ibek support` functions.
For an example see
[install.sh](https://github.com/epics-containers/ibek-support/blob/main/asyn/install.sh)
for the Asyn support module.
[install.sh](https://github.com/epics-containers/ibek-support/blob/main/ADSimDetector/install.sh)
for the ADSimDetector support module.

- \<support module name\>.ibek.support.yaml:
- a definition file that describes how the support module is used by
an IOC instance. This file is read by ibek when building an IOC instance
and is used to generate the startup script and database file. For an
example see
[asyn.ibek.def.yaml](https://github.com/epics-containers/ibek-support/blob/main/asyn/asyn.ibek.support.yaml)
[ADSimDetector.ibek.support.yaml](https://github.com/epics-containers/ibek-support/blob/main/ADSimDetector/ADSimDetector.ibek.support.yaml)

- other:
- any other files that are required to build the support module in the
Expand All @@ -50,6 +50,13 @@ Each support module folder contains:-
files. But perhaps a patch file might be required to make a support module
build inside of a container for example.

- VERSIONING:- an important aspect of ibek-support is that it will
retain backward compatibility with older versions of support modules going
forward from inception in October 2023. The install.sh script will be told
which version of the support moduel to build and will be able to detect which
OS and EPICS base version it is being built upon. The install.sh script will
be able to use this information to adjust any configuration that is required
by the environment.


## How to use
Expand All @@ -65,6 +72,14 @@ For an example Dockerfile that demonstrates this see
For details of the ibek module support functions
[ibek's github page](https://github.com/epics-containers/ibek)

## How to contribute

TODO: mention here how to use submodule in your ioc-xxx repo and how to
merge changes into ibek-support, also how to add to the CI to keep verifying
that the head of the repo is not broken for any support module.
ALSO: TODO point at the main epics-containers docs once updated to this latest
framework.




19 changes: 7 additions & 12 deletions tests/Dockerfile.adsimdetector
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
##### build stage ##############################################################

ARG TARGET_ARCHITECTURE
ARG BASE=7.0.7+ec1
ARG BASE
ARG REGISTRY=ghcr.io/epics-containers

FROM ${REGISTRY}/epics-base-${TARGET_ARCHITECTURE}-developer:${BASE} AS developer

RUN pip install --upgrade ibek

# In a devcontainer this folder is mounted on the host's clone of ioc-adsimdetector
WORKDIR /workspaces/ioc-adsimdetector/ibek-support
WORKDIR /epics/ioc-adsimdetector/ibek-support

# copy the global ibek files
COPY ibek-support/_global/ _global
Expand All @@ -31,32 +33,25 @@ COPY ibek-support/ADSimDetector/ ADSimDetector/
RUN ADSimDetector/install.sh R2-10

# Make the IOC
RUN ibek ioc generate-makefile
RUN ibek ioc compile

##### runtime preparation stage ################################################

FROM developer AS runtime_prep

# get the products from the build stage and reduce to runtime assets only
WORKDIR /min_files
RUN bash /epics/scripts/minimize.sh ${IOC} $(ls -d ${SUPPORT}/*/)
RUN ibek ioc extract-runtime-assets /assets

##### runtime stage ############################################################

FROM ${REGISTRY}/epics-base-${TARGET_ARCHITECTURE}-runtime:${BASE} AS runtime

# get the virtual environment from the developer stage
COPY --from=developer /venv /venv
# add products from build stage
COPY --from=runtime_prep /min_files /
# get runtime assets from the preparation stage
COPY --from=runtime_prep /assets /

# install runtime system dependencies, collected from install.sh scripts
RUN ibek support apt-install --runtime

# add ioc sample startup scripts
COPY ioc ${IOC}

ENV TARGET_ARCHITECTURE ${TARGET_ARCHITECTURE}

ENTRYPOINT ["/bin/bash", "-c", "${IOC}/start.sh"]
17 changes: 6 additions & 11 deletions tests/Dockerfile.asyn
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ ARG TARGET_ARCHITECTURE

FROM ${REGISTRY}/epics-base-${TARGET_ARCHITECTURE}-developer:${BASE} AS developer

RUN pip install --upgrade ibek

# In a devcontainer this folder is mounted on the host's clone of ioc-adsimdetector
WORKDIR /workspaces/ioc-adsimdetector/ibek-support
WORKDIR /epics/ioc-adsimdetector/ibek-support

# copy the global ibek files
COPY ibek-support/_global/ _global
Expand All @@ -16,32 +18,25 @@ COPY ibek-support/asyn/ asyn/
RUN asyn/install.sh R4-42

# Make the IOC
RUN ibek ioc generate-makefile
RUN ibek ioc compile

##### runtime preparation stage ################################################

FROM developer AS runtime_prep

# get the products from the build stage and reduce to runtime assets only
WORKDIR /min_files
RUN bash /epics/scripts/minimize.sh ${IOC} $(ls -d ${SUPPORT}/*/)
RUN ibek ioc extract-runtime-assets /assets

##### runtime stage ############################################################

FROM ${REGISTRY}/epics-base-${TARGET_ARCHITECTURE}-runtime:${BASE} AS runtime

# get the virtual environment from the developer stage
COPY --from=developer /venv /venv
# add products from build stage
COPY --from=runtime_prep /min_files /
# get runtime assets from the preparation stage
COPY --from=runtime_prep /assets /

# install runtime system dependencies, collected from install.sh scripts
RUN ibek support apt-install --runtime

# add ioc sample startup scripts
COPY ioc ${IOC}

ENV TARGET_ARCHITECTURE ${TARGET_ARCHITECTURE}

ENTRYPOINT ["/bin/bash", "-c", "${IOC}/start.sh"]
17 changes: 6 additions & 11 deletions tests/Dockerfile.busy
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ ARG TARGET_ARCHITECTURE

FROM ${REGISTRY}/epics-base-${TARGET_ARCHITECTURE}-developer:${BASE} AS developer

RUN pip install --upgrade ibek

# In a devcontainer this folder is mounted on the host's clone of ioc-adsimdetector
WORKDIR /workspaces/ioc-adsimdetector/ibek-support
WORKDIR /epics/ioc-adsimdetector/ibek-support

# copy the global ibek files
COPY ibek-support/_global/ _global
Expand All @@ -22,32 +24,25 @@ COPY ibek-support/busy/ busy/
RUN busy/install.sh R1-7-3

# Make the IOC
RUN ibek ioc generate-makefile
RUN ibek ioc compile

##### runtime preparation stage ################################################

FROM developer AS runtime_prep

# get the products from the build stage and reduce to runtime assets only
WORKDIR /min_files
RUN bash /epics/scripts/minimize.sh ${IOC} $(ls -d ${SUPPORT}/*/)
RUN ibek ioc extract-runtime-assets /assets

##### runtime stage ############################################################

FROM ${REGISTRY}/epics-base-${TARGET_ARCHITECTURE}-runtime:${BASE} AS runtime

# get the virtual environment from the developer stage
COPY --from=developer /venv /venv
# add products from build stage
COPY --from=runtime_prep /min_files /
# get runtime assets from the preparation stage
COPY --from=runtime_prep /assets /

# install runtime system dependencies, collected from install.sh scripts
RUN ibek support apt-install --runtime

# add ioc sample startup scripts
COPY ioc ${IOC}

ENV TARGET_ARCHITECTURE ${TARGET_ARCHITECTURE}

ENTRYPOINT ["/bin/bash", "-c", "${IOC}/start.sh"]
18 changes: 6 additions & 12 deletions tests/_test_support_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,15 @@ for dockerfile in ${DOCKERFILES}; do
do_build ${ARCH} runtime ${dockerfile}

# launch the runtime IOC container
$docker run --name test_me --rm -dit test_image_only
$docker run --name test_me --rm test_image_only | \
grep "Generic IOC start script"

# verify that the IOC is running - but give it time to start
for retry in {1..10}; do
sleep 1
if $docker exec test_me ps aux | grep /epics/ioc/bin/linux-x86_64/ioc ; then
echo "IOC is running"
break
fi
done

$docker stop -t0 test_me
$docker rmi test_image_only

# The above check is sufficient to show that the generic IOC will load and
# run and that all the necessary runtime libraries are in place.

# TODO - we need a minimalist st.cmd to run in the container to check that
# the IOC is able to load runtime libraries.
done


3 changes: 1 addition & 2 deletions tests/ioc.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ioc-adaravis/releases/download/23.9.1/adaravis.ibek.ioc.schema.json
# yaml-language-server: $schema=https://github.com/epics-containers/ioc-adaravis/releases/download/23.9.4/ibek.ioc.schema.json

ioc_name: bl45p-ea-ioc-01
description: Sample and overview cameras IOC for BL45P
generic_ioc_image: ghcr.io/epics-containers/ioc-adaravis-linux-runtime:23.9.1

entities:
- type: epics.EpicsCaMaxArrayBytes
Expand Down
3 changes: 3 additions & 0 deletions tests/test_ioc_generate.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash

set -xe

THIS_FOLDER=$(realpath $(dirname ${0}))
IBEK_SROOT=${THIS_FOLDER}/../

pip install ibek

# make a global ioc schema for all the support modules combined
echo generating all support schema
Expand Down

0 comments on commit 9331b52

Please sign in to comment.