Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidNew-NOAA committed Dec 5, 2024
1 parent e4aff0a commit 576526d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 33 deletions.
40 changes: 20 additions & 20 deletions ci/driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ case ${TARGET} in
;;
esac

# ==============================================================================
# set list of available CI tests to run on the Global Workflow
CI_TESTS=("C96C48_hybatmDA"
"C96C48_ufs_hybatmDA"
"C96C48_hybatmaerosnowDA"
Expand Down Expand Up @@ -188,27 +190,25 @@ for pr in $open_pr_list; do
commit=$(git log --pretty=format:'%h' -n 1)
echo "$commit" > $PR_TEST_DIR/$pr/commit

# get ci tests from PR description and convert into a regular expressions to included and exclude
branch_body=$(gh pr view $pr --repo ${gdasapp_url} --json body --jq '.body')
ci_checklist=$(echo "$branch_body" | grep '\[x\]')
ci_include_regex="gdasapp"
ci_exclude_regex=""
for ci_test in ${CI_TESTS[@]}; do
if echo "$ci_checklist" | grep -q "$ci_test"; then
ci_include_regex+="${ci_include_regex:+|}$ci_test"
else
ci_exclude_regex+="${ci_exclude_regex:+|}$ci_test"
fi
done

# run build and testing command
echo "Running run_ci.sh for $PR_TEST_DIR/$pr/$BASE_REPO at $(date)"
run_ci_cmd="$my_dir/run_ci.sh -d $PR_TEST_DIR/$pr/$BASE_REPO -o $PR_TEST_DIR/$pr/output_${commit} -R $ci_include_regex"
if [ -n "$ci_exclude_regex" ]; then
run_ci_cmd+=" -E $ci_exclude_regex"
fi
if [[ TEST_WORKFLOW == 1 ]]; then
run_ci_cmd+=" -w"
run_ci_cmd="$my_dir/run_ci.sh -d $PR_TEST_DIR/$pr/$BASE_REPO -o $PR_TEST_DIR/$pr/output_${commit} -R gdasapp"
if [[ $TEST_WORKFLOW == 1 ]]; then
# get ci tests from PR description and convert into a regular expressions to be exclude
branch_body=$(gh pr view $pr --repo ${gdasapp_url} --json body --jq '.body')
ci_checklist=$(echo "$branch_body" | grep '\[x\]')
ctest_regex_exclude=""
for ci_test in ${CI_TESTS[@]}; do
if ! echo "$ci_checklist" | grep -q "$ci_test"; then
ctest_regex_exclude+="${ctest_regex_exclude:+|}$ci_test"
fi
done

# setup run_ci.sh arguments to exclude chosen CI tests
run_ci_cmd+=" -w"
if [ -n "$ctest_regex_exclude" ]; then
run_ci_cmd+=" -E $ctest_regex_exclude"
fi
fi
$run_ci_cmd
ci_status=$?
Expand All @@ -226,7 +226,7 @@ for pr in $open_pr_list; do
echo "No authorized users assigned to this PR. Aborting CI..."
fi

echo "Finished processing Pull Request #{pr} at $(date)"
echo "Finished processing Pull Request #${pr} at $(date)"
done

# ==============================================================================
Expand Down
34 changes: 21 additions & 13 deletions ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,35 @@ usage() {
echo
echo " -d Run build and ctest for clone in <directory>"
echo " -o Path to output message detailing results of CI tests"
echo " -w Test GDASApp within the Global Workflow"
echo " -R Regular expression of CTests to include"
echo " -E Regular expression of CTests to exclude"
echo " -h display this message and quit"
echo
exit 1
}

# ==============================================================================
TEST_WORKFLOW=0
ci_regex_include="gdasapp"
ci_regex_exclude=""
while getopts "d:o:h" opt; do
ctest_regex_include=""
ctest_regex_exclude=""
while getopts "d:o:h:R:E:w" opt; do
case $opt in
d)
repodir=$OPTARG
;;
o)
outfile=$OPTARG
;;
w)
TEST_WORKFLOW=1
;;
R)
ci_regex_include=$OPTARG
ctest_regex_include+=$OPTARG
;;
E)
ci_regex_exclude=$OPTARG
ctest_regex_exclude+=$OPTARG
;;
w)
TEST_WORKFLOW=1
;;
h|\?|:)
usage
;;
Expand All @@ -44,7 +47,7 @@ done
if [[ $TEST_WORKFLOW == 1 ]]; then
export WORKFLOW_BUILD="ON"

workflow_dir=$repo_dir
workflow_dir=$repodir
gdasapp_dir=$workflow_dir/sorc/gdas.cd

build_cmd_dir=$workflow_dir/sorc
Expand Down Expand Up @@ -84,7 +87,7 @@ else
echo '```' >> $outfile
exit $build_status
fi
if [[ TEST_WORKFLOW == 1 ]]; then
if [[ $TEST_WORKFLOW == 1 ]]; then
./link_workflow.sh
fi
# ==============================================================================
Expand All @@ -94,11 +97,16 @@ module use $gdasapp_dir/modulefiles
module load GDAS/$TARGET
echo "---------------------------------------------------" >> $outfile
rm -rf log.ctest
ctest_cmd="ctest -j${NTASKS_TESTS} -R $ci_regex_include"
if [ -n "$ci_regex_exclude" ]; then
ctest_cmd+=" -E $ci_regex_exclude"
ctest_cmd="ctest -j${NTASKS_TESTS}"
if [ -n "$ctest_regex_include" ]; then
ctest_cmd+=" -R $ctest_regex_include"
fi
if [ -n "$ctest_regex_exclude" ]; then
ctest_cmd+=" -E $ctest_regex_exclude"
fi
pwd
$ctest_cmd --output-on-failure &>> log.ctest
echo "Tests: $ctest_cmd" >> $outfile
ctest_status=$?
npassed=$(cat log.ctest | grep "tests passed")
if [ $ctest_status -eq 0 ]; then
Expand Down

0 comments on commit 576526d

Please sign in to comment.