-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce GitHub Action workflow for UK Met Office (#2354)
* setup github actions * try again after adding cmake-jedi to ukmo runner group * address review suggestions * rename workflow for consistency
- Loading branch information
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |