-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/buildgroup' into feature/ci_update
- Loading branch information
Showing
15 changed files
with
328 additions
and
227 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
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
This file was deleted.
Oops, something went wrong.
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,72 @@ | ||
#!/bin/bash | ||
# | ||
# (C) Crown Copyright 2024, the Met Office. All rights reserved. | ||
# | ||
# shellcheck disable=SC2317 | ||
# shellcheck source=/dev/null | ||
set -euo pipefail | ||
|
||
finally() { | ||
trap '' ERR | ||
trap '' EXIT | ||
if [[ -d "${WORKD:-}" ]]; then | ||
cd / | ||
rm -fr "${WORKD}" | ||
fi | ||
if [[ -d ${BASE:-} ]]; then | ||
cd / | ||
rm -fr "$BASE" 2>/dev/null || true | ||
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)" | ||
BASE="${HERE%/*}" | ||
TESTDIR="${BASE##*/}" | ||
export CI_TESTS=${CI_TESTS:-0} | ||
export OMPI_ALLOW_RUN_AS_ROOT=1 | ||
export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 | ||
CI_TESTS=${CI_TESTS//$'\r'} # remove those pesky invisible EOL characters | ||
|
||
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 | ||
|
||
# -- Enable OpenMPI over subscription ----------------------------------------- | ||
if command -v ompi_info &>/dev/null; then | ||
ompi_vn=$(ompi_info | awk '/Ident string:/ {print $3}') | ||
case $ompi_vn in | ||
4.*) export OMPI_MCA_rmaps_base_oversubscribe=1 ;; | ||
5.*) export PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe ;; | ||
esac | ||
fi | ||
|
||
if command -v ninja &>/dev/null; then | ||
GENERATOR=Ninja; | ||
else | ||
GENERATOR=Unix\ Makefiles; | ||
fi | ||
|
||
# -- Configure | ||
cmake -B . -S "${HERE}" -G "${GENERATOR}" -DCMAKE_BUILD_TYPE=Release | ||
|
||
# -- Build | ||
cmake --build . -j "${NPROC}" | ||
|
||
# -- Test | ||
case "$CI_TESTS" in | ||
0) ctest -j"${NPROC}" --test-dir "${TESTDIR}" --output-on-failure -R 'coding_norms' ;; | ||
1) ctest -j"${NPROC}" --test-dir "${TESTDIR}" --output-on-failure ;; | ||
*) echo "** Error: CI_TESTS=$CI_TESTS is not a valid option **"; | ||
exit 1 ;; | ||
esac | ||
|
||
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,37 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# (C) Copyright 2024 MetOffice Crown Copyright | ||
# | ||
# This script attempts to checkout a branch for a particular repository | ||
# annotated in the body of the PR from which the GitHub action is triggered. | ||
# | ||
set -euo pipefail | ||
|
||
action_repo="${GITHUB_REPOSITORY}" # "owner/repository" | ||
action_branch="${GITHUB_HEAD_REF}" | ||
if [[ "${action_branch}" == 'develop' ]]; then | ||
exit | ||
fi | ||
|
||
target_dir="$1" | ||
target_repo="${target_dir##*/}" | ||
found=$(gh pr view "${action_branch}" -R "${action_repo}" \ | ||
| grep 'build-group=' \ | ||
| grep -E "/${target_repo}/|/${target_repo}#") || { | ||
echo "-- No build-group"; exit 0; } | ||
echo "$found" | ||
|
||
cd "$target_dir" | ||
target_pr=${found##*/} | ||
if [[ $target_pr =~ '#' ]]; then | ||
target_pr=${target_pr##*#} | ||
fi | ||
target_pr=${target_pr//$'\r'} # remove those pesky invisible EOL characters | ||
target_branch=$(gh pr list --search "$target_pr" \ | ||
--json number,headRefName \ | ||
-q ".[]|select(.number|contains($target_pr))|.headRefName") | ||
git fetch origin "pull/${target_pr}/head:${target_branch}" | ||
gh pr checkout "$target_pr" | ||
echo "-- Switched to $(git branch --show-current)" | ||
|
||
exit |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.