Skip to content

Commit

Permalink
add runtime test capability
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Sep 22, 2023
1 parent a58654c commit be4b148
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/buiild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
if: runner.os == 'macos'
uses: docker-practice/actions-setup-docker@fd7ecdac7caf8e2c541a48c9bcc280aae59a8461

# Dockerfiles expect the repo to be in a subdirectory as its normally a submodule
- name: Move Repo
run: mv ./* ./.submodule

- name: Log in to GitHub Docker Registry
uses: docker/login-action@v1
with:
Expand All @@ -57,4 +61,4 @@ jobs:
ARCH: ${{ matrix.architecture }}
PLATFORM: ${{ matrix.platform }}
CACHE: ${{ env.CACHE }}
run: tests/_test_support_build.sh
run: .submodule/tests/_test_support_build.sh
3 changes: 3 additions & 0 deletions tests/Verify.asyn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "HELLO WORLD"
3 changes: 3 additions & 0 deletions tests/Verify.busy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo TODO add tests for busy support module
40 changes: 35 additions & 5 deletions tests/_test_support_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,39 @@
# CACHE: the directory to use for caching
# PLATFORM: the platform to build for (linux/amd64 or linux/arm64)

THIS_FOLDER=$(dirname $(readlink -f $0))
set -xe

# this script can be run locally but only if it is run as a submodule of
# and ioc-xxx generic IOC repository. This is because the Docker Context
# is the parent folder of the ibek-support folder and might cause trouble
# if run from elsewhere.

function is_on_github_actions {
if [[ "CI" != "" || "GITHUB_RUN_ID" != "" ]] ; then
return False
else
return True
fi
}

if is_on_github_actions ; then
echo "running on github where we explicitly move the repo to a subfolder"
else
if [[ -f .git && $(grep .git/modules/ibek-support .git) != "" ]] ; then
echo "running locally as a submodule"
else
echo "ERROR: this script must be run as a submodule of an ioc-xxx repository"
exit 1
fi
fi


THIS_FOLDER=$(dirname ${0})
# ibek-support is normally a submodule of the Docker Context so we need to
# pass the container context as the folder above the ibek-support folder
mkdir -p ${THIS_FOLDER}/my_context
CONTEXT=$(realpath ${THIS_FOLDER}/../..)

set -xe

BASE_VERSION="23.9.2"

ARCH=${ARCH:-linux}
Expand Down Expand Up @@ -61,7 +87,7 @@ do_build() {
--build-arg BASE=${BASE_VERSION}
--build-arg REGISTRY=ghcr.io/epics-containers
--target ${TARGET}
--layers
--load
-t test_image_only
-f ${DOCKERFILE}
"
Expand Down Expand Up @@ -100,8 +126,12 @@ for dockerfile in ${THIS_FOLDER}/Dockerfile*; do
# 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.
#
# for more detailed testing add a Verify.xxx script where xxx is the
# for more detailed testing add a Verify.xxx.sh script where xxx is the
# the same as the suffix on the Dockerfile. See Verify.asyn for an example.
VERIFY=Verify."${dockerfile#*.}"
if [[ -f ${THIS_FOLDER}/${VERIFY} ]] ; then
$THIS_FOLDER/${VERIFY} test_me
fi

$docker stop -t0 test_me

Expand Down

0 comments on commit be4b148

Please sign in to comment.