Skip to content

Commit

Permalink
Merge pull request #18 from epics-containers/update-to-latest-template
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 5897150 + 718de45 commit d357675
Show file tree
Hide file tree
Showing 18 changed files with 183 additions and 192 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
45 changes: 0 additions & 45 deletions .github/workflows/build.sh

This file was deleted.

72 changes: 39 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,69 +11,75 @@ jobs:
permissions:
contents: read
packages: write
env:
CACHE: /tmp/.buildx-cache
strategy:
fail-fast: false
max-parallel: 1 # take advantage of caching
matrix:
target: [developer, runtime]
architecture: [linux]
include:
- architecture: linux
os: ubuntu-latest
platform: linux/amd64
- os: ubuntu-latest
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
with:
submodules: recursive

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: ${{ env.CACHE }}
key: ${{ runner.os }}-${{ matrix.architecture }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.architecture }}-buildx-
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup python
uses: actions/setup-python@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image
uses: docker/build-push-action@v5
with:
python-version: "3.10"
context: .
platforms: ${{ matrix.platforms }}
target: ${{ matrix.target }}
build-args: TARGET_ARCHITECTURE=${{ matrix.architecture }}
tags: ${{ env.TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
load: true

- name: Docker Build Script
env:
ARCH: ${{ matrix.architecture }}
PLATFORM: ${{ matrix.platform }}
TAG: ${{ github.ref_name }}
PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
CACHE: ${{ env.CACHE }}
run: .github/workflows/build.sh
- name: Test image
run: tests/run-tests.sh

- name: Upload schema as artifact
uses: actions/upload-artifact@v3
- name: Push image
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
uses: docker/build-push-action@v5
with:
name: ioc-schema
path: ibek.ioc.schema.json
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
needs: [build-push-images]
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
runs-on: ubuntu-latest

# this job runs in the (linux) developer container we just made
container:
image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-linux-developer:${{ github.ref_name }}

steps:
- uses: actions/download-artifact@v3
with:
name: ioc-schema
path: ./
- name: generate-schema
run: |
ibek ioc generate-schema --output ibek.ioc.schema.json
- name: Github Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
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
2 changes: 1 addition & 1 deletion ibek-support
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.

Loading

0 comments on commit d357675

Please sign in to comment.