Skip to content

Commit

Permalink
Merge pull request #4 from epics-containers/update-2
Browse files Browse the repository at this point in the history
update to latest ioc-template
  • Loading branch information
gilesknap authored Jan 28, 2024
2 parents 00231a4 + 26302d7 commit 9d99465
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 159 deletions.
5 changes: 2 additions & 3 deletions .devcontainer/postCreateCommand
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

if [[ $USER != "root" ]] ; then
# make sure the non-root user can build iocs and (mounted in) support modules
sudo chown -R ${USER}:${USER} /epics/links /venv
sudo chown -h ${USER}:${USER} /epics /epics/ioc
sudo chown -R ${USER}:${USER} /epics/ibek-defs /epics/pvi-defs /epics/support/configure /venv
sudo chown -h ${USER}:${USER} /epics /epics/ioc /epics/support

# also give non-root user access to the same bash config we use in podman
sudo chmod a+rx /root
Expand All @@ -23,7 +23,6 @@ fi
# all epics-containers devcontainers
################################################################################


# add user's custom profile container creation script
if [ -f ~/.bashprofile_dev_container ]; then
. ~/.bashprofile_dev_container
Expand Down
27 changes: 20 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ jobs:
architecture: [linux]
include:
- os: ubuntu-latest
platform: linux/amd64
platforms: linux/amd64

runs-on: ${{ matrix.os }}
env:
TAG: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-${{ matrix.architecture }}-${{ matrix.target }}:${{ github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -42,14 +44,27 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
platform: ${{ matrix.platform }}
platforms: ${{ matrix.platforms }}
target: ${{ matrix.target }}
build-args: TARGET_ARCHITECTURE=${{ matrix.architecture }}
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-${{ matrix.architecture }}-${{ matrix.target }}:${{ github.ref_name }}
tags: ${{ env.TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
load: true

- name: Test image
run: tests/run-tests.sh

- name: Push image
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platforms }}
target: ${{ matrix.target }}
build-args: TARGET_ARCHITECTURE=${{ matrix.architecture }}
tags: ${{ env.TAG }}
push: true

release:
# Release on tag push - publish ioc schema
Expand All @@ -66,8 +81,6 @@ jobs:
run: |
ibek ioc generate-schema --output ibek.ioc.schema.json
# TODO add back in some tests that run INSIDE the container

- name: Github Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ ibek

# config folder is there to be replaced there is just a dummy with Readme.
ioc/config

# podman may leave this around in aborted builds
.build.swp
18 changes: 12 additions & 6 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@
# generic local build script for epics-containers ioc repositories #
################################################################################

# pass rtems as first argument to build RTEMS on cross-compiler
TARGET_ARCHITECTURE=${1:-linux}
# set TARGET_ARCHITECTURE to rtems for RTEMS based targets
T_A=${TARGET_ARCHITECTURE:-linux}
# set TARGET to runtime for runtime images
TARGET=${TARGET:-developer}
# set TAG to override the default tag
TAG=${TAG:-ec_test}

# log commands and stop on erros
set -xe

cd $(dirname ${0})

# use docker if available else use podman
if ! docker version &>/dev/null; then alias docker=podman; fi

# make sure new repos get their submodule ibek-support
git submodule update --init

# build runtime and developer images
ec dev build --arch ${TARGET_ARCHITECTURE}
# build and developer images
docker build -t ${TAG} --build-arg TARGET_ARCHITECTURE=$T_A --target $TARGET .

# get the schema file from the developer container and save it locally
ec dev launch-local --execute 'ibek ioc generate-schema' > ibek.ioc.schema.json
27 changes: 0 additions & 27 deletions ioc-examples/bl16i-ea-ioc-07/config/bl16i-ea-ioc-07.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions ioc-examples/bl16i-ea-ioc-07/xml/bl16i-ea-ioc-07.xml

This file was deleted.

28 changes: 16 additions & 12 deletions ioc/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,17 @@ description='
function ibek_error {
echo "${1}"

# Wait indefinitely so the container does not exit and restart continually.
while true; do
sleep 1000
done
# Wait for a bit so the container does not exit and restart continually
sleep 10
}

# environment setup ************************************************************

set -x -e
# log commands and stop on errors
set -xe

export TOP=$(realpath $(dirname $0))
cd ${TOP}
CONFIG_DIR=${TOP}/config
cd ${IOC}
CONFIG_DIR=${IOC}/config

# add module paths to environment for use in ioc startup script
if [[ -f ${SUPPORT}/configure/RELEASE.shell ]]; then
Expand All @@ -99,6 +97,14 @@ epics_db=${RUNTIME_DIR}/ioc.db
# in case there are multiple YAML, pick the first one in the glob
ibek_src=${ibek_yamls[0]}

if [ -d ${CONFIG_DIR} ]; then
echo "checking config folder ${CONFIG_DIR}"
ls -al ${CONFIG_DIR}
else
echo "ERROR: No config folder found."
ibek_error "${description}"
fi

# 1. start.sh override script **************************************************
if [ -f ${override} ]; then
exec bash ${override}
Expand Down Expand Up @@ -132,11 +138,9 @@ elif [ -f ${ioc_startup} ] ; then
msi ${includes} -I${RUNTIME_DIR} -S ${CONFIG_DIR}/ioc.subst -o ${epics_db}
fi
final_ioc_startup=${ioc_startup}
# 4. empty config folder ***************************************************
# 4. incorrect config folder ***************************************************
else
echo "No startup assets found in ${CONFIG_DIR}"
echo

echo "ERROR: No startup assets found in ${CONFIG_DIR}"
ibek_error "${description}"
fi

Expand Down
3 changes: 0 additions & 3 deletions requirements_ec.txt

This file was deleted.

29 changes: 29 additions & 0 deletions tests/config/bl00i-ea-test-ioc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ioc-template/releases/download/2024.1.1/ibek.ioc.schema.json

ioc_name: "{{ ioc_yaml_file_name }}"

description: Very generic instance for testing generic IOCs

entities:
- type: epics.EpicsEnvSet
name: EPICS_TZ
value: "GMT0BST"

- type: devIocStats.iocAdminSoft
IOC: "{{ ioc_name | upper }}"

- type: epics.StartupCommand
command: dbLoadRecords("/epics/ioc/config/ioc.db")

- type: epics.dbpf
pv: EXAMPLE:IBEK:A
value: "2.54"

- type: epics.dbpf
pv: EXAMPLE:IBEK:B
value: "2.61"

- type: epics.PostStartupCommand
command: |
dbgf EXAMPLE:IBEK:SUM
dbgf BL00I-EA-TEST-IOC:ST_SCRIPT1
File renamed without changes.
26 changes: 0 additions & 26 deletions tests/example-config/calc.db

This file was deleted.

16 changes: 0 additions & 16 deletions tests/example-config/ioc.substitutions

This file was deleted.

12 changes: 0 additions & 12 deletions tests/example-config/st.cmd

This file was deleted.

9 changes: 0 additions & 9 deletions tests/example-ibek-config/ioc.yaml

This file was deleted.

51 changes: 25 additions & 26 deletions tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,35 @@
# all present and correct and that mounting IOC config or ibek config
# works as expected.

THIS_DIR=$(realpath $(dirname $0))
ROOT=$(realpath ${THIS_DIR}/..)
THIS=$(realpath $(dirname $0))
ROOT=$(realpath ${THIS}/..)
CONF=/epics/ioc/config

# log commands and stop on errorsr
set -ex

# use docker if available else use podman
if ! docker version &>/dev/null; then alias docker=podman; fi

cd ${ROOT}
# Build the container (inherit arguments from CI workflow if set) ##############
ec dev build ${EC_TAG}

# try out an ibek config IOC instance with the generic IOC #####################
ec dev launch-local tests/example-config --args '-dit' ${EC_TAG}
ec dev wait-pv EXAMPLE2:A --attempts 20
ec dev exec 'caput EXAMPLE2:A 1.3'
ec dev exec 'caput EXAMPLE2:B 1.2'
ec dev exec 'caget EXAMPLE2:SUM' | grep '2.5'

# Test an ibek IOC #############################################################
ec dev launch-local tests/example-ibek-config --args '-dit' ${EC_TAG}
ec dev wait-pv EXAMPLE:IBEK:A --attempts 20
ec dev exec 'caput EXAMPLE:IBEK:A 1.3'
ec dev exec 'caput EXAMPLE:IBEK:B 1.2'
ec dev exec 'caget EXAMPLE:IBEK:SUM' | grep '2.5'
ec dev exec 'caget test-ibek-ioc:EPICS_VERS' | grep 'R7.0.7'

# Stop the test IOC ############################################################
ec dev stop

# Done #########################################################################
echo
echo "All tests passed!"

# if a tag was passed in this implies it was already built
export TAG=${TAG:-ec_test}
if [[ ${TAG} == "ec_test" ]] ; then TARGET=runtime ./build; fi

# try out a test ibek config IOC instance with the generic IOC
result=$(docker run --rm -v ${THIS}/config:${CONF} ${TAG} /epics/ioc/start.sh 2>&1)

# check that the IOC output expected results
if echo "${result}" | grep -i error; then
echo "ERROR: errors in IOC startup"
exit 1
elif [[ ! ${result} =~ "5.15" || ! ${result} =~ "/epics/runtime/st.cmd" ]]; then
echo "ERROR: dbgf output not as expected"
exit 1
fi

echo "Tests passed!"



6 changes: 3 additions & 3 deletions user_examples/.bashprofile_dev_container
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
# This will run inside the devcontainer after creation #
################################################################################

apt-get update
apt-get -y --no-install-recommends install vimdiff
# apt-get update
# apt-get -y --no-install-recommends install vimdiff
# apt-get install what you like

# add some completion
# add command line completion to the ibek tool
ibek --install-completion bash

2 changes: 1 addition & 1 deletion user_examples/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
User Customization Examples
===========================

Users can customize their epics-containers developer containers by creating
Users can customize their epics-containers developer containers by copying
the files in this folder into their home directory and customizing them as
required.

Expand Down

0 comments on commit 9d99465

Please sign in to comment.