diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84a78052..3e759fd9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,63 +1,140 @@ -name: UKMO_CI_Azure +--- +name: CI on: - push: - branches: [develop] pull_request: branches: [develop] jobs: - build: + build1: + name: gnu 11.3.1 (UKMO) + if: github.repository_owner == 'MetOffice' runs-on: jedi-self-hosted-rg + + env: + REPO: ${{ github.event.repository.name }} + BUNDLE: pr-${{ github.event.number }} + steps: + - name: pre-submit cleanup + run: | + ls -la ./ + rm -fr ./${{ env.BUNDLE }} || true + ls -la ./ - name: checkout current - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - path: ci/opsinputs + path: ./${{ env.BUNDLE }}/${{ env.REPO }} + - name: initiate bundle + run: cp ./${{ env.BUNDLE }}/${{ env.REPO }}/ci/* ./${{ env.BUNDLE }}/ - name: checkout jedicmake - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - path: ci/jedicmake + path: ./${{ env.BUNDLE }}/jedicmake repository: JCSDA-internal/jedi-cmake submodules: true token: ${{ secrets.GH_PAT }} - name: checkout oops - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - path: ci/oops + 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: ./ci/get-ref-branch ./ci/oops + run: ./${{ env.BUNDLE }}/get-ref-branch ./${{ env.BUNDLE }}/oops - name: checkout ioda - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - path: ci/ioda + path: ./${{ env.BUNDLE }}/ioda repository: JCSDA-internal/ioda token: ${{ secrets.GH_PAT }} - name: matching branch checkout attempt ioda ${{ github.head_ref }} if: github.event_name == 'pull_request' - run: ./ci/get-ref-branch ./ci/ioda + run: ./${{ env.BUNDLE }}/get-ref-branch ./${{ env.BUNDLE }}/ioda - name: checkout ufo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - path: ci/ufo + path: ./${{ env.BUNDLE }}/ufo repository: JCSDA-internal/ufo token: ${{ secrets.GH_PAT }} - name: matching branch checkout attempt ufo ${{ github.head_ref }} if: github.event_name == 'pull_request' - run: ./ci/get-ref-branch ./ci/ufo + run: ./${{ env.BUNDLE }}/get-ref-branch ./${{ env.BUNDLE }}/ufo - name: build and test run: | az acr login --name ngmssboxjediacr docker run --rm \ - --entrypoint=/usr/local/src/opsinputs/ci/build-and-test \ - --workdir=/usr/local/src/opsinputs/ci \ - --volume $PWD:/usr/local/src/opsinputs \ - 'ngmssboxjediacr.azurecr.io/jedibase:alma9' + --entrypoint=/usr/local/src/${REPO}/${BUNDLE}/build-and-test \ + --workdir=/usr/local/src/${REPO}/${BUNDLE} \ + --volume ${PWD}/${BUNDLE}:/usr/local/src/${REPO}/${BUNDLE} \ + 'ngmssboxjediacr.azurecr.io/jedibase:alma9' \ + && rm -fr ${{github.workspace}}/${{env.BUNDLE}} + + build2: + name: gnu 9.4.0 (JCSDA) + if: github.repository_owner == 'MetOffice' + runs-on: ubuntu-latest + + env: + REPO: ${{ github.event.repository.name }} + BUNDLE: pr-${{ github.event.number }} + + 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 + 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: checkout ioda + uses: actions/checkout@v4 + with: + path: ./${{ env.BUNDLE }}/ioda + repository: JCSDA-internal/ioda + token: ${{ secrets.GH_PAT }} + - name: matching branch checkout attempt ioda ${{ github.head_ref }} + if: github.event_name == 'pull_request' + run: ./${{ env.BUNDLE }}/get-ref-branch ./${{ env.BUNDLE }}/ioda + + - name: checkout ufo + uses: actions/checkout@v4 + with: + path: ./${{ env.BUNDLE }}/ufo + repository: JCSDA-internal/ufo + token: ${{ secrets.GH_PAT }} + - name: matching branch checkout attempt ufo ${{ github.head_ref }} + if: github.event_name == 'pull_request' + run: ./${{ env.BUNDLE }}/get-ref-branch ./${{ env.BUNDLE }}/ufo + + - name: build and test + run: | + 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} \ + 'jcsda/docker-gnu-openmpi-dev:latest' diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 6fa45292..a5c27e16 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -17,7 +17,7 @@ jobs: - name: Fail if PR is not labelled as ready to merge if: "!contains(github.event.pull_request.labels.*.name,'ready to merge')" run: | - echo "This PR is not yet ready to merge." + echo "This PR does not have 'ready to merge' label." exit 1 - name: Pass if PR is labelled as ready to merge diff --git a/ci/build-and-test b/ci/build-and-test index b51ecc39..2320be3e 100755 --- a/ci/build-and-test +++ b/ci/build-and-test @@ -2,8 +2,7 @@ # # (C) Crown Copyright 2023, the Met Office. All rights reserved. # -# -set -euo pipefail +set -euxo pipefail finally() { trap '' ERR @@ -18,21 +17,30 @@ 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 -trap finally ERR -trap finally EXIT +trap finally ERR EXIT cd "${WORKD}" -rm -f "${HERE}/bundle" -ln -s '..' "${HERE}/bundle" +# 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" -# -- Configure & Build -cmake -B . -S "${HERE}" -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" --output-on-failure --test-dir './opsinputs' + ctest -j"${NPROC}" --test-dir './opsinputs' --output-on-failure ||\ +env OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 \ + ctest --test-dir './opsinputs' --rerun-failed -V exit