Skip to content

Commit

Permalink
Introduce GitHub Action workflow for UK Met Office (#2354)
Browse files Browse the repository at this point in the history
* setup github actions
* try again after adding cmake-jedi to ukmo runner group
* address review suggestions
* rename workflow for consistency
  • Loading branch information
yaswant authored Sep 13, 2023
1 parent c74956c commit 7a7dd98
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: UKMO-CI-Az

on:
push:
branches: [develop]
pull_request:
branches: [develop]

jobs:
build-and-test:
runs-on: jedi-self-hosted-ext
steps:
- name: checkout current repo
uses: actions/checkout@v3
with:
path: CI/meto/oops
repository: JCSDA-internal/oops

- name: checkout jedicmake
uses: actions/checkout@v3
with:
path: CI/meto/jedicmake
repository: JCSDA/jedi-cmake
submodules: true

- name: build and test
run: |
az acr login --name ngmssboxjediacr
docker run --rm \
--entrypoint=/usr/local/src/oops-ci/build-and-test \
--workdir=/usr/local/src/oops-ci/ \
--volume $PWD/CI/meto:/usr/local/src/oops-ci \
'ngmssboxjediacr.azurecr.io/jedibase:alma9'
15 changes: 15 additions & 0 deletions CI/meto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)

project(oops-ci VERSION 1.0.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")
if(NOT DEFINED jedicmake_DIR)
set(jedicmake_DIR "${CMAKE_BINARY_DIR}/jedicmake")
endif()
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/oops")

include(CTest)
enable_testing()
37 changes: 37 additions & 0 deletions CI/meto/build-and-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/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:-$(nproc)}
WORKD="$(mktemp -d "${THIS}-XXXXXX" -t)"

trap finally ERR
trap finally EXIT

cd "${WORKD}"

rm -f "${HERE}/bundle"
ln -s '..' "${HERE}/bundle"

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

# -- Build
# VERBOSE=1 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" --output-on-failure --test-dir './oops'

exit
20 changes: 20 additions & 0 deletions CI/meto/get-ref-branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -euxo pipefail
repo="$1" # expect path to a repo clone

branch_name="${GITHUB_HEAD_REF}"
if [[ "${branch_name}" == 'develop' ]]; then
exit
fi

# Attempt to checkout a branch from a dependency project with the same name as
# the branch triggering this GitHub Actions workflow.
cd "${repo}"
if git fetch --progress --depth=1 origin \
"+refs/heads/${branch_name}:refs/remotes/origin/${branch_name}"
then
git checkout --progress --force -B "${branch_name}" \
"refs/remotes/origin/${branch_name}"
fi

exit

0 comments on commit 7a7dd98

Please sign in to comment.