Skip to content

Commit

Permalink
Merge pull request #19 from MetOffice/feature/ci
Browse files Browse the repository at this point in the history
Use both JCSDA and UKMO environments for CI build
  • Loading branch information
phlndrwd authored Oct 3, 2023
2 parents b96e1fa + 7ea56df commit 4dd6bdd
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 33 deletions.
119 changes: 103 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,116 @@
---
name: UKMO-CI-Azure
name: CI

on:
pull_request:
branches: [develop]

jobs:
build:
env:
REPO: ${{ github.event.repository.name }}
BUNDLE: pr-${{ github.event.number }}

jobs:
build1:
if: github.repository_owner == 'MetOffice'
name: gnu 11.3.1 (UKMO)
runs-on: jedi-self-hosted-rg
env:
PR: ${{ github.event.number }}
REPO: ${{ github.event.repository.name }}
BUNDLE: ${{ github.event.number }}-bundle

steps:
- name: pre-submit cleanup
run: |
ls -la ./
rm -fr ./${{ env.BUNDLE }} || true
ls -la ./
- name: checkout current
uses: actions/checkout@v4
with:
path: ./${{ env.BUNDLE }}/${{ env.REPO }}
- name: initiate bundle
run: cp ./${{ env.BUNDLE }}/${{ env.REPO }}/ci/* ./${{ env.BUNDLE }}/

- name: checkout jedicmake
uses: actions/checkout@v4
with:
path: ./${{ env.BUNDLE }}/jedicmake
repository: JCSDA-internal/jedi-cmake
submodules: true
token: ${{ secrets.GH_PAT }}

- name: checkout oops
uses: actions/checkout@v4
with:
path: ./${{ env.BUNDLE }}/oops
repository: JCSDA-internal/oops
token: ${{ secrets.GH_PAT }}
- name: matching branch checkout attempt oops ${{ github.head_ref }}
if: github.event_name == 'pull_request'
run: ./${{ env.BUNDLE }}/get-ref-branch ./${{ env.BUNDLE }}/oops

- name: build and test
env:
MOBB_DATA: ${{ github.workspace }}/MOBB_DATA
run: |
az acr login --name ngmssboxjediacr
ln -sfT /testdata/model-interface-data ${MOBB_DATA}
docker run --rm \
--entrypoint=/usr/local/src/${REPO}/${BUNDLE}/build-and-test \
--workdir=/usr/local/src/${REPO}/${BUNDLE} \
--volume ${PWD}/${BUNDLE}:/usr/local/src/${REPO}/${BUNDLE} \
--volume ${MOBB_DATA}:/var/tmp/MOBB_DATA \
'ngmssboxjediacr.azurecr.io/jedibase:alma9' \
&& rm -fr ${{ github.workspace }}/${{ env.BUNDLE }}
build2:
if: '! github.event.pull_request.draft'
name: gnu 9.4.0 (JCSDA)
runs-on: ubuntu-latest

steps:
- name: checkout current
uses: actions/checkout@v4
with:
path: ${{ env.PR }}
- name: create bundle
path: ./${{ env.BUNDLE }}/${{ env.REPO }}
- name: initiate bundle
run: cp ./${{ env.BUNDLE }}/${{ env.REPO }}/ci/* ./${{ env.BUNDLE }}/

- name: checkout jedicmake
uses: actions/checkout@v4
with:
path: ./${{ env.BUNDLE }}/jedicmake
repository: JCSDA-internal/jedi-cmake
submodules: true
token: ${{ secrets.GH_PAT }}

- name: checkout oops
uses: actions/checkout@v4
with:
path: ./${{ env.BUNDLE }}/oops
repository: JCSDA-internal/oops
token: ${{ secrets.GH_PAT }}
- name: matching branch checkout attempt oops ${{ github.head_ref }}
if: github.event_name == 'pull_request'
run: ./${{ env.BUNDLE }}/get-ref-branch ./${{ env.BUNDLE }}/oops

- name: build and lint
run: |
mkdir -p ${{ env.BUNDLE }}/${{ env.REPO }}
cp -r ${{ env.PR }}/ci/* ${{ env.BUNDLE }}/
cp -r ${{ env.PR }}/* ${{ env.BUNDLE }}/${{ env.REPO }}
docker run --rm \
--entrypoint=/usr/local/src/${REPO}/${BUNDLE}/build-and-lint \
--workdir=/usr/local/src/${REPO}/${BUNDLE} \
--volume ${PWD}/${BUNDLE}:/usr/local/src/${REPO}/${BUNDLE} \
'jcsda/docker-gnu-openmpi-dev:latest'
build3:
if: '! github.event.pull_request.draft'
name: clang 10.0.0 (JCSDA)
runs-on: ubuntu-latest

steps:
- name: checkout current
uses: actions/checkout@v4
with:
path: ./${{ env.BUNDLE }}/${{ env.REPO }}
- name: initiate bundle
run: cp ./${{ env.BUNDLE }}/${{ env.REPO }}/ci/* ./${{ env.BUNDLE }}/

- name: checkout jedicmake
uses: actions/checkout@v4
Expand All @@ -44,9 +132,8 @@ jobs:

- name: build and lint
run: |
az acr login --name ngmssboxjediacr
docker run --rm \
--entrypoint=/usr/local/src/${REPO}/${BUNDLE}/build-and-test \
--entrypoint=/usr/local/src/${REPO}/${BUNDLE}/build-and-lint \
--workdir=/usr/local/src/${REPO}/${BUNDLE} \
--volume $PWD/${BUNDLE}:/usr/local/src/${REPO}/${BUNDLE} \
'ngmssboxjediacr.azurecr.io/jedibase:alma9'
--volume ${PWD}/${BUNDLE}:/usr/local/src/${REPO}/${BUNDLE} \
'jcsda/docker-clang-mpich-dev:latest'
48 changes: 48 additions & 0 deletions ci/build-and-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
#
# (C) Crown Copyright 2023, the Met Office. All rights reserved.
#
set -euo pipefail

finally() {
trap '' ERR
trap '' EXIT
if [[ -d "${WORKD:-}" ]]; then
cd /
rm -fr "${WORKD}"
fi
}

# HERE is /usr/local/src/<REPONAME>/pr-<#> (cf ../.github/workflow/ci.yml)
HERE="$(cd "$(dirname "$0")" && pwd)"
THIS="$(basename "$0")"
NPROC=${NPROC:-$(nproc)}
WORKD="$(mktemp -d "${THIS}-XXXXXX" -t)"
GENERATOR=Unix\ Makefiles
if command -v ninja &>/dev/null; then GENERATOR=Ninja; fi
BASE="${HERE%/*}"
TESTDIR="${BASE##*/}"

trap finally ERR EXIT

cd "${WORKD}"

# -- Activate spack env if using JCSDA Docker container
if [[ -f /opt/spack-environment/activate.sh ]]; then
source /opt/spack-environment/activate.sh
fi


# -- Configure
cmake -B . -S "${HERE}" -G "${GENERATOR}" \
-DCMAKE_BUILD_TYPE=Debug \
-DMPI_ARGS="--oversubscribe"

# -- Build
cmake --build . -j "${NPROC}"

# -- Test
env OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 \
ctest -j"${NPROC}" --test-dir "${TESTDIR}" -R 'coding_norms' -V

exit
41 changes: 24 additions & 17 deletions ci/build-and-test
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash
set -euo pipefail
#
# (C) Crown Copyright 2023, the Met Office. All rights reserved.
#
set -euxo pipefail

finally() {
trap '' ERR
Expand All @@ -10,33 +13,37 @@ finally() {
fi
}

# HERE is /usr/local/src/<REPONAME>/pr-<#> (cf ../.github/workflow/ci.yml)
HERE="$(cd "$(dirname "$0")" && pwd)"
THIS="$(basename "$0")"
NPROC=${NPROC:-$(nproc)}
WORKD="$(mktemp -d "${THIS}-XXXXXX" -t)"

trap finally ERR
trap finally EXIT

GENERATOR=Unix\ Makefiles
if command -v ninja &>/dev/null; then GENERATOR=Ninja; fi
BASE="${HERE%/*}"
TESTDIR="${BASE##*/}"
export OMPI_MCA_rmaps_base_oversubscribe=true
export LFRICLITE_DATA_REP_DIR="/var/tmp/MOBB_DATA/lfric-lite/Data"
ls -l "${LFRICLITE_DATA_REP_DIR}"

trap finally ERR EXIT
cd "${WORKD}"

GENERATOR=Unix\ Makefiles
if command -v ninja; then GENERATOR=Ninja; fi
# -- Activate spack env if using JCSDA Docker container
if [[ -f /opt/spack-environment/activate.sh ]]; then
source /opt/spack-environment/activate.sh
fi

# -- Configure
( set -x;
cmake -B . -S "${HERE}" -G "$GENERATOR" \
-DCMAKE_BUILD_TYPE=Debug \
-DMPI_ARGS="--oversubscribe"

cmake -B . -S "${HERE}" -G "${GENERATOR}" -DCMAKE_BUILD_TYPE=Debug

# -- Build
cmake --build . -j "${NPROC}"

cmake --build . -j "${NPROC}"

# -- Test
env OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 \
ctest -j "$NPROC" -R "coding_norms" --output-on-failure
)
env OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 \
ctest -j"${NPROC}" --test-dir "${TESTDIR}" || \
env OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 \
ctest --test-dir "${TESTDIR}" --rerun-failed -V

exit

0 comments on commit 4dd6bdd

Please sign in to comment.