Skip to content

Commit

Permalink
Merge pull request #43 from coecms/update_payu_again
Browse files Browse the repository at this point in the history
Move container build to github actions. Update payu again
  • Loading branch information
dsroberts committed Aug 17, 2023
2 parents a174719 + a8e94ba commit c9894f5
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 47 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@ on: pull_request
jobs:
build:
runs-on: ubuntu-latest
container:
image: quay.io/singularity/singularity:v3.11.4
options: --privileged
steps:
- name: Checkout repository
### Latest at time of writing
uses: actions/[email protected]
- name: Check if container definition has changed
id: changed-container-def
uses: tj-actions/changed-files@v37
with:
files_yaml: |
containerdef:
- container/container.def
- name: Build container if definition has changed
if: steps.changed-container-def.outputs.containerdef_any_changed == 'true'
run: |
sudo -E singularity build container/base.sif container/container.def
- name: Sync repository to Gadi
### Latest at time of writing
uses: up9cloud/[email protected]
Expand Down
Binary file removed container/base.sif
Binary file not shown.
3 changes: 0 additions & 3 deletions container/build_container.sh

This file was deleted.

81 changes: 44 additions & 37 deletions container/container.def
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
%setup
mkdir -p ${SINGULARITY_ROOTFS}/usr/bin
ln -s usr/bin ${SINGULARITY_ROOTFS}/bin
ln -s half-root/boot ${SINGULARITY_ROOTFS}/boot
ln -s half-root/etc ${SINGULARITY_ROOTFS}/etc
ln -s half-root/images ${SINGULARITY_ROOTFS}/images
ln -s half-root/initrd ${SINGULARITY_ROOTFS}/initrd
ln -s usr/lib ${SINGULARITY_ROOTFS}/lib
ln -s usr/lib64 ${SINGULARITY_ROOTFS}/lib64
ln -s usr/sbin ${SINGULARITY_ROOTFS}/sbin

mkdir -p ${SINGULARITY_ROOTFS}/opt
ln -s ../half-root/opt/Modules ${SINGULARITY_ROOTFS}/opt/Modules
ln -s ../half-root/opt/beegfs ${SINGULARITY_ROOTFS}/opt/beegfs
ln -s ../half-root/opt/bin ${SINGULARITY_ROOTFS}/opt/bin
ln -s ../half-root/opt/gdrcopy ${SINGULARITY_ROOTFS}/opt/gdrcopy
ln -s ../half-root/opt/intel ${SINGULARITY_ROOTFS}/opt/intel
ln -s ../half-root/opt/knem-1.1.4.90mlnx1 ${SINGULARITY_ROOTFS}/opt/knem-1.1.4.90mlnx1
ln -s ../half-root/opt/mellanox ${SINGULARITY_ROOTFS}/opt/mellanox
ln -s ../half-root/opt/pbs ${SINGULARITY_ROOTFS}/opt/pbs
ln -s ../half-root/opt/rash ${SINGULARITY_ROOTFS}/opt/rash
ln -s ../half-root/opt/rh ${SINGULARITY_ROOTFS}/opt/rh

### Mount points for various bits of the image
mkdir -p ${SINGULARITY_ROOTFS}/etc
mkdir -p ${SINGULARITY_ROOTFS}/half-root
mkdir -p ${SINGULARITY_ROOTFS}/local
mkdir -p ${SINGULARITY_ROOTFS}/ram
mkdir -p ${SINGULARITY_ROOTFS}/run
mkdir -p ${SINGULARITY_ROOTFS}/system
mkdir -p ${SINGULARITY_ROOTFS}/usr

### Mount points for service sockets
mkdir -p ${SINGULARITY_ROOTFS}/var/lib/sss
mkdir -p ${SINGULARITY_ROOTFS}/var/run/munge

%runscript
Bootstrap: scratch

%setup
mkdir -p ${SINGULARITY_ROOTFS}/usr/bin
ln -s usr/bin ${SINGULARITY_ROOTFS}/bin
ln -s half-root/boot ${SINGULARITY_ROOTFS}/boot
ln -s half-root/etc ${SINGULARITY_ROOTFS}/etc
ln -s half-root/images ${SINGULARITY_ROOTFS}/images
ln -s half-root/initrd ${SINGULARITY_ROOTFS}/initrd
ln -s usr/lib ${SINGULARITY_ROOTFS}/lib
ln -s usr/lib64 ${SINGULARITY_ROOTFS}/lib64
ln -s usr/sbin ${SINGULARITY_ROOTFS}/sbin

mkdir -p ${SINGULARITY_ROOTFS}/opt
ln -s ../half-root/opt/Modules ${SINGULARITY_ROOTFS}/opt/Modules
ln -s ../half-root/opt/beegfs ${SINGULARITY_ROOTFS}/opt/beegfs
ln -s ../half-root/opt/bin ${SINGULARITY_ROOTFS}/opt/bin
ln -s ../half-root/opt/gdrcopy ${SINGULARITY_ROOTFS}/opt/gdrcopy
ln -s ../half-root/opt/intel ${SINGULARITY_ROOTFS}/opt/intel
ln -s ../half-root/opt/knem-1.1.4.90mlnx1 ${SINGULARITY_ROOTFS}/opt/knem-1.1.4.90mlnx1
ln -s ../half-root/opt/mellanox ${SINGULARITY_ROOTFS}/opt/mellanox
ln -s ../half-root/opt/pbs ${SINGULARITY_ROOTFS}/opt/pbs
ln -s ../half-root/opt/rash ${SINGULARITY_ROOTFS}/opt/rash
ln -s ../half-root/opt/rh ${SINGULARITY_ROOTFS}/opt/rh

### Mount points for various bits of the image
mkdir -p ${SINGULARITY_ROOTFS}/etc
mkdir -p ${SINGULARITY_ROOTFS}/half-root
mkdir -p ${SINGULARITY_ROOTFS}/local
mkdir -p ${SINGULARITY_ROOTFS}/ram
mkdir -p ${SINGULARITY_ROOTFS}/run
mkdir -p ${SINGULARITY_ROOTFS}/system
mkdir -p ${SINGULARITY_ROOTFS}/usr

### Mount points for service sockets
mkdir -p ${SINGULARITY_ROOTFS}/var/lib/sss
mkdir -p ${SINGULARITY_ROOTFS}/var/run/munge

mkdir -p ${SINGULARITY_ROOTFS}/opt/conda/analysis3-22.07
mkdir -p ${SINGULARITY_ROOTFS}/opt/conda/analysis3-22.10
mkdir -p ${SINGULARITY_ROOTFS}/opt/conda/analysis3-23.01
mkdir -p ${SINGULARITY_ROOTFS}/opt/conda/analysis3-23.04

%runscript
/usr/bin/bash -l
16 changes: 12 additions & 4 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,23 @@ fi

ln -sf "${ENV_INSTALLATION_PATH}" "${CONDA_OUTER_BASE}"/"${APPS_SUBDIR}"/"${CONDA_INSTALL_BASENAME}"/envs/

"${SINGULARITY_BINARY_PATH}" -s exec --bind /etc,/half-root,/local,/ram,/run,/system,/usr,/var/lib/sss,/var/run/munge,/var/lib/rpm,"${OVERLAY_BASE}":/g "${CONTAINER_PATH}" $( realpath $0 ) --inner "${DO_UPDATE}"
if [[ -e "${CONTAINER_PATH}" ]]; then
### New container, use that
my_container="${CONTAINER_PATH}"
else
my_container="${CONDA_OUTER_BASE}"/"${APPS_SUBDIR}"/"${CONDA_INSTALL_BASENAME}"/etc/"${CONTAINER_PATH##*/}"
fi

"${SINGULARITY_BINARY_PATH}" -s exec --bind /etc,/half-root,/local,/ram,/run,/system,/usr,/var/lib/sss,/var/run/munge,/var/lib/rpm,"${OVERLAY_BASE}":/g "${my_container}" $( realpath $0 ) --inner "${DO_UPDATE}"
if [[ $? -ne 0 ]]; then
exit 1
fi

### See if the container has been updated
read newhash fn < <( md5sum "${CONTAINER_PATH}" )
read oldhash fn < <( md5sum "${CONDA_OUTER_BASE}"/"${APPS_SUBDIR}"/"${CONDA_INSTALL_BASENAME}"/etc/"${CONTAINER_PATH##*/}" )
if [[ "${oldhash}" != "${newhash}" ]]; then
### The container will only exist on ${CONTAINER_PATH} if it was built by the github action
#read newhash fn < <( md5sum "${CONTAINER_PATH}" )
#read oldhash fn < <( md5sum "${CONDA_OUTER_BASE}"/"${APPS_SUBDIR}"/"${CONDA_INSTALL_BASENAME}"/etc/"${CONTAINER_PATH##*/}" )
if [[ -e "${CONTAINER_PATH}" ]]; then
echo "Container update detected. Copying in new container"
cp "${CONTAINER_PATH}" "${CONDA_OUTER_BASE}"/"${APPS_SUBDIR}"/"${CONDA_INSTALL_BASENAME}"/etc/"${CONTAINER_PATH##*/}"
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ dependencies:
- coecms-util
- yamanifest
- cmocean
- accessnri::payu==1.0.27
- accessnri::payu
- splitvar
- marineHeatWaves
- holoviews
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export FULLENV="${ENVIRONMENT}-${VERSION_TO_MODIFY}"
### Other settings
export TEST_OUT_FILE=test_results.xml
export PYTHONNOUSERSITE=true
export CONTAINER_PATH=$( realpath "${SCRIPT_DIR}"/../container/base.sif )
export CONTAINER_PATH="${SCRIPT_DIR}"/../container/base.sif
export SINGULARITY_BINARY_PATH="/opt/singularity/bin/singularity"

declare -a rpms_to_remove=( "openssh-clients" "openssh-server" "openssh" )
Expand Down
9 changes: 8 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ for f in "${outside_files_to_copy[@]}"; do
cp "${f}" "${OVERLAY_BASE}"/"${f#/g/}"
done

"${SINGULARITY_BINARY_PATH}" -s exec --bind /etc,/half-root,/local,/ram,/run,/system,/usr,/var/lib/sss,/var/run/munge,/var/lib/rpm,"${OVERLAY_BASE}":/g --overlay="${BUILD_STAGE_DIR}"/"${FULLENV}".sqsh.tmp "${CONTAINER_PATH}" $( realpath $0 ) --inner
if [[ -e "${CONTAINER_PATH}" ]]; then
### New container, use that
my_container="${CONTAINER_PATH}"
else
my_container="${CONDA_OUTER_BASE}"/"${APPS_SUBDIR}"/"${CONDA_INSTALL_BASENAME}"/etc/"${CONTAINER_PATH##*/}"
fi

"${SINGULARITY_BINARY_PATH}" -s exec --bind /etc,/half-root,/local,/ram,/run,/system,/usr,/var/lib/sss,/var/run/munge,/var/lib/rpm,"${OVERLAY_BASE}":/g --overlay="${BUILD_STAGE_DIR}"/"${FULLENV}".sqsh.tmp "${my_container}" $( realpath $0 ) --inner

if [[ ! -e "${TEST_OUT_FILE}" ]]; then
echo "TESTS FILE MISSING - assuming tests have failed"
Expand Down

0 comments on commit c9894f5

Please sign in to comment.