Skip to content

Commit

Permalink
update to template 3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Mar 28, 2024
1 parent e7ad942 commit 830b702
Show file tree
Hide file tree
Showing 38 changed files with 700 additions and 215 deletions.
9 changes: 9 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 3.4.0
_src_path: gh:epics-containers/ioc-template
description: Generic IOC for simulation motors
git_platform: github.com
github_org: epics-containers
name: ioc-motorsim
repo_uri: [email protected]:epics-containers/ioc-motorsim.git
rtems: true
47 changes: 21 additions & 26 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"dockerfile": "../Dockerfile",
"target": "developer",
"args": {
"TARGET_ARCHITECTURE": "linux"
// Native target development settings ==============================
"EPICS_TARGET_ARCH": "linux-x86_64"
// Local cross compilation settings ================================
// "EPICS_TARGET_ARCH": "RTEMS-beatnik",
// "IMAGE_EXT": "-rtems-beatnik"
}
},
"remoteEnv": {
Expand All @@ -15,15 +19,16 @@
"EC_PROJECT": "${localWorkspaceFolderBasename}"
},
"features": {
// add quality of life features for developers including git config integration
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": false,
"installOhMyZsh": false,
"installOhMyZshConfig": false,
// don't upgrade to make this similar to the runtime container
"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.
// set to vscode. You will run as vscode with full sudo rights.
// For podman it should be left blank. You will run as root but host mounts
// will be owned by your user.
"remoteUser": "${localEnv:EC_REMOTE_USER}",
"customizations": {
"vscode": {
Expand All @@ -34,37 +39,27 @@
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters",
"epicsdeb.vscode-epics",
"ms-python.black-formatter"
"charliermarsh.ruff"
]
}
},
// 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
// You can place any 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
// One time global setup commands inside the container
"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
// Make sure SELinux does not disable write access to host filesystems like tmp
"--security-opt=label=disable"
],
"workspaceMount": "source=${localWorkspaceFolder},target=/epics/${localWorkspaceFolderBasename},type=bind",
"workspaceFolder": "/epics/${localWorkspaceFolderBasename}",
// Mount the parent of the project folder so we can access peer projects
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
// mount in other useful files from the host
"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"
// we also mount the project folder into a know location in the container
// this is where the ibek-support and ioc folders reside in the container build
// in this way the devcontainer and runtime look very similar
"source=${localWorkspaceFolder},target=/epics/generic-source,type=bind"
]
}
13 changes: 2 additions & 11 deletions .devcontainer/initializeCommand
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
#!/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
# custom initialization goes here - runs outside of the dev container
# just before the container is launched but after the container is created

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

# Custom initialization goes here if needed.
# Runs inside the dev container after the container is created

################################################################################
# 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
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
fi

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

# add ibek completion to bash and zsh
echo 'source <(ibek --show-completion bash)' >> $HOME/.bashrc
echo 'source <(ibek --show-completion zsh)' >> $HOME/.zshrc

# pick a theme that does not cause completion corruption in zsh
sed -i $HOME/.zshrc -e 's/ZSH_THEME="devcontainers"/ZSH_THEME="lukerandall"/'

# add user's custom profile container creation script
if [ -f ~/.bashprofile_dev_container ]; then
. ~/.bashprofile_dev_container
# allow personalization of all devcontainers in this subdirectory
# by placing a .devcontainer_rc file in the workspace root
if [[ -f /workspaces/.devcontainer_rc ]] ; then
source /workspaces/.devcontainer_rc
fi
4 changes: 0 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ updates:
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
103 changes: 68 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,108 @@ on:
pull_request:

jobs:
build-push-images:
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
matrix:
epics-target: [RTEMS-beatnik,linux-x86_64] # , linux-aarch64]
include:
- architecture: linux
os: ubuntu-latest
- os: ubuntu-latest # everyone is on ubuntu-latest
- epics-target: RTEMS-beatnik
extension: -rtems-beatnik
platform: linux/amd64
- epics-target: linux-x86_64
extension: ""
platform: linux/amd64

# # a temporary name until multi-arch is supported
# - epics-target: linux-aarch64
# extension: -native-aarch64
# platform: linux/arm64

runs-on: ${{ matrix.os }}
env:
TAG: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}${{ matrix.extension }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
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 QEMU
uses: docker/setup-qemu-action@v3

- 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.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: tests/run-tests.sh ci_test

- 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: Push developer image
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
target: developer
build-args: |
IMAGE_EXT=${{ matrix.extension }}
tags: ${{ env.TAG }}-developer:${{ github.ref_name }}
push: true

- name: Upload schema as artifact
uses: actions/upload-artifact@v3
- name: Push runtime 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.platform }}
target: runtime
build-args: |
IMAGE_EXT=${{ matrix.extension }}
tags: ${{ env.TAG }}-runtime:${{ github.ref_name }}
push: true

release:
# Release on tag push - publish ioc schema
needs: [build-push-images]
needs: [build]
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
runs-on: ubuntu-latest

# this job runs in the native developer container we just made
container:
image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-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
15 changes: 10 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ repos*
# while working on ibek with this project somethimes include it as subfolder
ibek

# The ioc source tree is created here from a template inside the generic ioc
# repo.
# Remove from .gitignore if you want to customize the template.
/ioc/

# dont save workspaces as other users will have differing folders
*workspace

# 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

# this gets updated during RTEMS builds in devcontainer but we dont want to commit it
# TODO this entry does not work - why on earth not?
ioc/configure/CONFIG_SITE.Common.linux-x86_64
49 changes: 49 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Generic IOC debugging launcher
// To use this l
// 1. make sure you have gdb installed in your container with
// apt update; apt-get install gdb
// 2. run the IOC once to make sure rutime assets are generated:
// cd /epics/ioc; make
// ./start.sh
// 3. stop the IOC with 'exit'
// 4. In vscode go to the support source in /epics/support/xxx
// 5. Set any breakpoints in the source code that you require.
// 6. You may want to set 'HOST_OPT=NO' in CONFIG_SITE and rebuild the support
// 6. Go to the debug tab and select 'IOC devcontainer debug' from the
// RUN AND DEBUG dropdown
{
"version": "0.2.0",
"configurations": [
{
"name": "IOC devcontainer debug",
"type": "cppdbg",
"request": "launch",
"program": "/epics/ioc/bin/linux-x86_64/ioc",
"args": [
"/epics/runtime/st.cmd"
],
"stopAtEntry": false,
"cwd": "/epics/ioc",
"environment": [
{
"name": "RUNTIME_DIR",
"value": "/epics/runtime"
}
],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
Loading

0 comments on commit 830b702

Please sign in to comment.