diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7ed8b6c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,67 @@ +name: CI + +on: + push: + branches: [develop] + pull_request: + branches: [develop] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout current repo + uses: actions/checkout@v3 + with: + lfs: true + + - name: checkout jedicmake + uses: actions/checkout@v3 + with: + path: ci/jedicmake + repository: JCSDA-internal/jedi-cmake + submodules: true + token: ${{ secrets.GH_PAT }} + + - name: checkout oops + uses: actions/checkout@v3 + with: + path: ci/oops + repository: JCSDA-internal/oops + token: ${{ secrets.GH_PAT }} + + - name: checkout ioda + uses: actions/checkout@v3 + with: + path: ci/ioda + repository: JCSDA-internal/ioda + token: ${{ secrets.GH_PAT }} + + - name: checkout ufo + uses: actions/checkout@v3 + with: + path: ci/ufo + repository: JCSDA-internal/ufo + token: ${{ secrets.GH_PAT }} + + - name: checkout atlas-orca + uses: actions/checkout@v3 + with: + path: ci/atlas-orca + repository: ECMWF/atlas-orca + + - name: checkout atlas-data + uses: actions/checkout@v3 + with: + path: ci/atlas-data + repository: MetOffice/atlas-data + lfs: true + token: ${{ secrets.GH_PAT }} + + - name: build and test + run: | + docker run --rm \ + --entrypoint=/usr/local/src/orca-jedi/ci/build-and-test.sh \ + --workdir=/usr/local/src/orca-jedi/ci \ + --volume $PWD:/usr/local/src/orca-jedi \ + 'jcsda/docker-gnu-openmpi-dev:latest' diff --git a/README.rst b/README.rst index ec37cb2..08bbc41 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,5 @@ +.. image:: https://github.com/MetOffice/orca-jedi/actions/workflows/ci.yml/badge.svg + orca-jedi ========= diff --git a/ci/CMakeLists.txt b/ci/CMakeLists.txt new file mode 100644 index 0000000..c97a353 --- /dev/null +++ b/ci/CMakeLists.txt @@ -0,0 +1,23 @@ +# (C) Copyright 2022 Met Office +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + +cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) + +project( orca-jedi-ci VERSION 1.0 LANGUAGES C CXX Fortran ) + +set( ENABLE_MPI ON CACHE BOOL "Compile with MPI" ) +set( ENABLE_OMP ON CACHE BOOL "Compile with OpenMP" ) + +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/jedicmake" EXCLUDE_FROM_ALL) +if(NOT DEFINED jedicmake_DIR) + set(jedicmake_DIR "${CMAKE_BINARY_DIR}/jedicmake") +endif() + +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/atlas-orca" EXCLUDE_FROM_ALL) +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/oops" EXCLUDE_FROM_ALL) +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/ioda" EXCLUDE_FROM_ALL) +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/ufo" EXCLUDE_FROM_ALL) +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/orca-jedi") +enable_testing() diff --git a/ci/build-and-test.sh b/ci/build-and-test.sh new file mode 100755 index 0000000..47c9373 --- /dev/null +++ b/ci/build-and-test.sh @@ -0,0 +1,55 @@ +#!/bin/bash +set -euo pipefail + +finally() { + trap '' ERR + trap '' EXIT + if [[ -d "${WORKD:-}" ]]; then + cd / + rm -fr "${WORKD}" + fi +} + +HERE="$(cd "$(dirname "$0")" && pwd)" +THIS="$(basename "$0")" +NPROC=${NPROC:-2} +WORKD="$(mktemp -d "${THIS}-XXXXXX" -t)" + +trap finally ERR +trap finally EXIT + +cd "${WORKD}" + +source /opt/spack-environment/activate.sh + +echo " +------------------------------- +gcc version $(gcc -dumpversion ||:) +$(ecbuild --version ||:) +atlas version $(atlas --version ||:) +eckit version $(eckit-version ||:) +ectrans version $(ectrans --version ||:) +fckit version $(fckit --version ||:) +fiat version $(fiat --version ||:) +lz4 version $(lz4 --version ||:) +odc version $(odc --version ||:) +------------------------------- +" + +rm -f "${HERE}/orca-jedi" +ln -s '..' "${HERE}/orca-jedi" +ecbuild -S "${HERE}" +make -j "${NPROC}" + +if [[ ! -f share/plugins/atlas-orca.yml ]]; then + echo "ERROR atlas-orca.yml not found!" | tee >(cat >&2) + exit 1 +fi + +env OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 \ + ATLAS_TRACE=1 ATLAS_DEBUG=1 \ + LD_LIBRARY_PATH="${HERE}/lib:${LD_LIBRARY_PATH}" \ + ATLAS_DATA_PATH="${HERE}/atlas-data" \ + ctest -j "${NPROC}" -V --output-on-failure --test-dir "./orca-jedi" + +exit diff --git a/src/tests/orca-jedi/CMakeLists.txt b/src/tests/orca-jedi/CMakeLists.txt index df99242..9c82961 100644 --- a/src/tests/orca-jedi/CMakeLists.txt +++ b/src/tests/orca-jedi/CMakeLists.txt @@ -9,7 +9,7 @@ ecbuild_add_test( TARGET test_orcajedi_nemo_io_field_reader.x LIST( APPEND ATLAS_TEST_ENVIRONMENT ATLAS_ORCA_CACHING=1 ATLAS_CACHE_PATH=${CMAKE_BINARY_DIR}/share - PLUGINS_MANIFEST_PATH=${CMAKE_BINARY_DIR}/atlas-orca/share/plugins ) + PLUGINS_MANIFEST_PATH=${CMAKE_BINARY_DIR}/share/plugins ) ecbuild_add_test( TARGET test_orcajedi_nemo_io_field_writer.x SOURCES test_nemo_io_field_writer.cc