Skip to content

Commit

Permalink
update to latest ioc-template (#1)
Browse files Browse the repository at this point in the history
* update to latest ioc-template
  • Loading branch information
gilesknap authored Nov 8, 2023
1 parent c5d04b6 commit 4e729a7
Show file tree
Hide file tree
Showing 12 changed files with 267 additions and 44 deletions.
84 changes: 84 additions & 0 deletions .devcontainer/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
################################################################################
# epics-containers developer shell configuration.
# This is a standard ubuntu .bashrc plus a PS1 prompt with container name
# and a call to .bashrc_dev_container in the user's home directory on the
# host machine.
################################################################################

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

# make a useful prompt, including current container name
EC_PROJECT=${EC_PROJECT:-container}
PS1="\[\e[32m\]\$(parse_git_branch)\[\e[m\][\[\e[34m\]\[\e[m\]\W]\$ "
export PS1="[\[\e[31m\]${EC_PROJECT#'ioc-'}\[\e[m\]]${PS1}"

# ibek cli completion
source <(ibek --show-completion bash)

# add user's custom .bashrc_dev_container
if [ -f ~/.bashrc_dev_container ]; then
. ~/.bashrc_dev_container
fi



70 changes: 70 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// For format details, see https://containers.dev/implementors/json_reference/
{
"name": "epics-containers IOC devcontainer",
"build": {
"dockerfile": "../Dockerfile",
"target": "developer",
"args": {
"TARGET_ARCHITECTURE": "linux"
}
},
"remoteEnv": {
// allows X11 apps to run inside the container
"DISPLAY": "${localEnv:DISPLAY}",
// provides a name for epics-containers to use in bash prompt etc.
"EC_PROJECT": "${localWorkspaceFolderBasename}"
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": false,
"installOhMyZsh": false,
"installOhMyZshConfig": false,
"upgradePackages": false
}
},
// IMPORTANT for this devcontainer to work with docker EC_REMOTE_USER must be
// set to vscode. For podman it should be left blank.
"remoteUser": "${localEnv:EC_REMOTE_USER}",
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.vscode-pylance",
"tamasfe.even-better-toml",
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters",
"epicsdeb.vscode-epics",
"ms-python.black-formatter"
]
}
},
// Make sure the files we are mapping into the container exist on the host
// You can place any other outside of the container before-launch commands here
"initializeCommand": "bash .devcontainer/initializeCommand ${devcontainerId}",
// Hooks the global .bashprofile_dev_container but also can add any other commands
// to run in the container at creation in here
"postCreateCommand": "bash .devcontainer/postCreateCommand ${devcontainerId}",
"runArgs": [
// Allow the container to access the host X11 display and EPICS CA
"--net=host",
// Make sure SELinux does not disable with access to host filesystems like tmp
"--security-opt=label=disable"
],
"workspaceMount": "source=${localWorkspaceFolder},target=/epics/${localWorkspaceFolderBasename},type=bind",
"workspaceFolder": "/epics/${localWorkspaceFolderBasename}",
"mounts": [
// Mount some useful local files from the user's home directory
// By mounting the parent of the workspace we can work on multiple peer projects
"source=${localWorkspaceFolder}/../,target=/repos,type=bind",
// this provides eternal bash history in and out of the container
"source=${localEnv:HOME}/.bash_eternal_history,target=/root/.bash_eternal_history,type=bind",
// this bashrc hooks up the .bashrc_dev_container in the following mount
"source=${localWorkspaceFolder}/.devcontainer/.bashrc,target=/root/.bashrc,type=bind",
// provides a place for you to put your shell customizations for all your dev containers
"source=${localEnv:HOME}/.bashrc_dev_container,target=/root/.bashrc_dev_container,type=bind",
// provides a place to install any packages you want to have across all your dev containers
"source=${localEnv:HOME}/.bashprofile_dev_container,target=/root/.bashprofile_dev_container,type=bind",
// provides the same command line editing experience as your host
"source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind"
]
}
15 changes: 15 additions & 0 deletions .devcontainer/initializeCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# make sure all the files we mount into the container exist
for i in \
.bash_eternal_history \
.bashrc_dev_container \
.bashprofile_dev_container \
.inputrc
do
if [ ! -f $HOME/$i ] ; then
touch $HOME/$i;
fi
done

echo "devcontainerID ${1}"
30 changes: 30 additions & 0 deletions .devcontainer/postCreateCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

################################################################################
# When using docker we will not be root inside the container
# the following steps are then required
################################################################################

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

# also give non-root user access to the same bash config we use in podman
sudo chmod a+rx /root
for f in .inputrc .bash_eternal_history .bashrc .bashrc_dev_container; do
sudo chmod a+rw /root/$f
ln -sf /root/$f $HOME/$f
done
fi

################################################################################
# Custom install script for each developer to add whatever they like to
# all epics-containers devcontainers
################################################################################


# add user's custom profile container creation script
if [ -f ~/.bashprofile_dev_container ]; then
. ~/.bashprofile_dev_container
fi
5 changes: 2 additions & 3 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
export EC_TAG="--tag ${TAG:-latest}"
export EC_PLATFORM="--platform ${PLATFORM:-linux/amd64}"
export EC_CACHE="${CACHE:-/tmp/ec-cache}"
export EC_DEBUG=true
if [[ "${PUSH}" == 'true' ]] ; then EC_PUSH='--push' ; fi

THIS=$(dirname ${0})
Expand All @@ -35,11 +34,11 @@ export EC_CARGS="
# ec dev build --arch rtems ... for RTEMS cross compile

# build runtime and developer images
ec dev build --buildx ${EC_TAG} ${EC_PLATFORM} ${EC_PUSH} ${EC_CARGS}
ec -v dev build ${EC_TAG} ${EC_PLATFORM} ${EC_PUSH} ${EC_CARGS}

# extract the ioc schema from the runtime image
ec dev launch-local ${EC_TAG} --execute \
'ibek ioc generate-schema /epics/links/ibek/*.ibek.support.yaml' > ibek.ioc.schema.json
'ibek ioc generate-schema /epics/ibek/*.ibek.support.yaml' > ibek.ioc.schema.json

# run acceptance tests
shopt -s nullglob # expand to nothing if no tests are found
Expand Down
42 changes: 30 additions & 12 deletions .github/workflows/buiild.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jobs:
build-push-images:
# 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
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
Expand All @@ -17,9 +16,12 @@ jobs:
strategy:
fail-fast: false
matrix:
# TODO add rtems
architecture: ["linux"]
include:
- architecture: linux
os: ubuntu-latest
platform: linux/amd64

runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -41,25 +43,41 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Docker Build Script
env:
REGISTRY: ghcr.io
ARCH: ${{ matrix.architecture }}
REPOSITORY: ${{ github.repository }}
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

tests:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
- name: Upload schema as artifact
uses: actions/upload-artifact@v3
with:
name: ioc-schema
path: ibek.ioc.schema.json

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

steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
submodules: recursive
name: ioc-schema
path: ./

- name: System Test
run: tests/run-tests.sh
- name: Github Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
files: |
ibek.ioc.schema.json
generate_release_notes: true
28 changes: 15 additions & 13 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ stages:
- env | grep "CI_"
- /bin/sh .gitlab/kanikobuild.sh
- echo "Done!"
only:
refs:
- tags
# uncomment to only publish on tags. At present untagged builds are published
# to gcr.io/diamond-privreg/controls/work/ioc
# only:
# refs:
# - tags

build_linux_runtime:
extends: .build
Expand All @@ -32,14 +34,14 @@ build_linux_developer:
ARCH: linux
TARGET: developer

build_rtems_runtime:
extends: .build
variables:
ARCH: rtems
TARGET: runtime
# build_rtems_runtime:
# extends: .build
# variables:
# ARCH: rtems
# TARGET: runtime

build_rtems_developer:
extends: .build
variables:
ARCH: rtems
TARGET: developer
# build_rtems_developer:
# extends: .build
# variables:
# ARCH: rtems
# TARGET: developer
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

29 changes: 17 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
##### build stage ##############################################################

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

##### build stage ##############################################################

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

# Get latest ibek while in development. Will come from epics-base in future.
RUN pip install --upgrade ibek==1.4.0
# get latest ibek while under dev. In future the epics-base version will be used
RUN pip install --upgrade ibek==1.4.2

# The devcontainer mounts the project root to /epics/ioc-adsimdetector. Using
# the same location here makes devcontainer/runtime differences transparent.
WORKDIR /epics/ioc-adsimdetector/ibek-support
# the devcontainer mounts the project root to /epics/ioc-template
WORKDIR /epics/ioc-template/ibek-support

# copy the global ibek files
COPY ibek-support/_global/ _global
Expand All @@ -28,11 +27,17 @@ RUN autosave/install.sh R5-10-2
COPY ibek-support/busy/ busy/
RUN busy/install.sh R1-7-3

COPY ibek-support/ADCore/ ADCore/
RUN ADCore/install.sh R3-12-1
COPY ibek-support/sscan/ sscan/
RUN sscan/install.sh R2-11-6

COPY ibek-support/calc/ calc/
RUN calc/install.sh R3-7-5

COPY ibek-support/motor/ motor/
RUN motor/install.sh R7-2-3b1

COPY ibek-support/ADSimDetector/ ADSimDetector/
RUN ADSimDetector/install.sh R2-10
COPY ibek-support/pmac/ pmac/
RUN pmac/install.sh 2-4-10

# Generate template IOC source tree / generate Makefile / compile
RUN ibek ioc build
Expand All @@ -56,4 +61,4 @@ RUN ibek support apt-install --runtime

ENV TARGET_ARCHITECTURE ${TARGET_ARCHITECTURE}

ENTRYPOINT ["/bin/bash", "-c", "${IOC}/start.sh"]
ENTRYPOINT ["/bin/bash", "-c", "${IOC}/start.sh"]
Loading

0 comments on commit 4e729a7

Please sign in to comment.