From 4a1331620c66b34bd7fdc724b1301a69e90e88eb Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 18 Jun 2024 09:35:04 +0000 Subject: [PATCH] add generic ioc build tests --- .github/workflows/build.yml | 61 ++++++++++++++++++++++++++++--------- .gitmodules | 6 ++++ requirements.txt | 1 + tests/ioc_repos/bl45p | 1 + tests/ioc_repos/bl47p | 1 + tests/test_generate.sh | 14 +++++++++ tests/test_ioc_generate.sh | 19 ------------ 7 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 .gitmodules create mode 100644 requirements.txt create mode 160000 tests/ioc_repos/bl45p create mode 160000 tests/ioc_repos/bl47p create mode 100755 tests/test_generate.sh delete mode 100755 tests/test_ioc_generate.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ce388b..224784f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,16 +5,27 @@ on: pull_request: jobs: + check-schema: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + + - name: Run schema/ioc instance generation tests + run: | + python tests/test_generate.py + check-docker-build: # 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 - permissions: - contents: read - packages: write - env: - CACHE: /tmp/.buildx-cache strategy: fail-fast: false + max-parallel: 5 matrix: include: # rtems is cross compiled on ubuntu-latest @@ -25,8 +36,10 @@ jobs: # os: ubuntu-latest # platform: linux/amd64 - - architecture: linux + - repo: [ioc-adaravis, ioc-pmac, ioc-lakeshore340, ioc-tetramm, ioc-opcua, ioc-motorSim, ioc-adsimdetector] os: ubuntu-latest + epics-target: linux-x86_64 + extension: "" platform: linux/amd64 # enable below for MACOS native build on M1 macs @@ -52,13 +65,31 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker Test Build Script - env: - ARCH: ${{ matrix.architecture }} - PLATFORM: ${{ matrix.platform }} - CACHE: ${{ env.CACHE }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Setup + # before building the container set up to use this version of ibek-support + # and its associated version of ibek run: | - for test in tests/*.sh; do - echo "RUNNING TEST SCRIPT ${test}" - ${test} - done + git clone ${{matrix.repo}} -/tmp/generic_ioc + cp -r . /tmp/generic_ioc/ibek-support + cp ./requirements.txt /tmp/generic_ioc + + - name: Build image + uses: docker/build-push-action@v5 + with: + context: /tmp/generic_ioc + platforms: ${{ matrix.platform }} + target: runtime + build-args: | + IMAGE_EXT=${{ matrix.extension }} + cache-from: type=gha,scope=${{ matrix.epics-target }} + cache-to: type=gha,mode=max,scope=${{ matrix.epics-target }} + tags: ci_test + load: true + + - name: Test image + # can't test non native without some hardware to run on + if: ${{ matrix.epics-target == 'linux-x86_64' }} + run: /tmp/generic_ioc/tests/run-tests.sh ci_test diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5884bb7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "tests/beamlines/bl47p"] + path = tests/ioc_repos/bl47p + url = https://github.com/epics-containers/bl47p.git +[submodule "tests/beamlines/bl45p"] + path = tests/ioc_repos/bl45p + url = https://github.com/epics-containers/bl45p.git diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..df095c2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +ibek==2.0.2 \ No newline at end of file diff --git a/tests/ioc_repos/bl45p b/tests/ioc_repos/bl45p new file mode 160000 index 0000000..02d9b61 --- /dev/null +++ b/tests/ioc_repos/bl45p @@ -0,0 +1 @@ +Subproject commit 02d9b61eb452e74bdbbc06aefa4ea549500905fb diff --git a/tests/ioc_repos/bl47p b/tests/ioc_repos/bl47p new file mode 160000 index 0000000..3fff47b --- /dev/null +++ b/tests/ioc_repos/bl47p @@ -0,0 +1 @@ +Subproject commit 3fff47bdfeae5d0f357f41ce0dc81aca4e487917 diff --git a/tests/test_generate.sh b/tests/test_generate.sh new file mode 100755 index 0000000..325bf33 --- /dev/null +++ b/tests/test_generate.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -xe + +THIS_FOLDER=$(realpath $(dirname ${0})) +IBEK_SROOT=${THIS_FOLDER}/../ + +pip install --upgrade -r $IBEK_SROOT/requirements.txt + +# make a global ioc schema for all the support modules combined +# this validates all ibek.support.yaml files +echo generating all support schema +ibek ioc generate-schema ${IBEK_SROOT}*/*.ibek.support.yaml --no-ibek-defs --output /tmp/all.ibek.ioc.schema.json + diff --git a/tests/test_ioc_generate.sh b/tests/test_ioc_generate.sh deleted file mode 100755 index 2464f10..0000000 --- a/tests/test_ioc_generate.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -xe - -THIS_FOLDER=$(realpath $(dirname ${0})) -IBEK_SROOT=${THIS_FOLDER}/../ - -pip install --upgrade "ibek>=3.0.0b5" - -# make a global ioc schema for all the support modules combined -# this validates all ibek.support.yaml files -echo generating all support schema -ibek ioc generate-schema ${IBEK_SROOT}*/*.ibek.support.yaml --no-ibek-defs --output /tmp/all.ibek.ioc.schema.json - -# make ioc instance files for an ADAravis IOC instance using all the support modules -# echo generating ioc instance files -# ibek runtime generate ${THIS_FOLDER}/ioc.yaml ${IBEK_SROOT}*/*.ibek.support.yaml --out /tmp/st.cmd --db-out /tmp/ioc.db -# TODO this only works inside a container now (since PVI integration) - should it?? -# TODO propose we have a ec --epics-root ... to allow us to test this function outstide containers