Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Run Unit Tests
on: [pull_request]
on: [push, pull_request]

jobs:
ctests:
Expand Down
100 changes: 100 additions & 0 deletions ci/driver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash --login

my_dir="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"

# ==============================================================================
usage() {
set +x
echo
echo "Usage: $0 -t <target> -h"
echo
echo " -t target/machine script is running on DEFAULT: $(hostname)"
echo " -h display this message and quit"
echo
exit 1
}

# ==============================================================================
# First, set up runtime environment

export TARGET="$(hostname)"

while getopts "t:h" opt; do
case $opt in
t)
TARGET=$OPTARG
;;
h|\?|:)
usage
;;
esac
done

case ${TARGET} in
hera | orion)
echo "Running Automated Testing on $TARGET"
source $MODULESHOME/init/sh
source $my_dir/${TARGET}.sh
module purge
module use $GDAS_MODULE_USE
module load GDAS/$TARGET
module list
;;
*)
echo "Unsupported platform. Exiting with error."
exit 1
;;
esac


# ==============================================================================
# pull on the repo and get list of open PRs
cd $GDAS_CI_ROOT/repo
CI_LABEL="${GDAS_CI_HOST}-RT"
gh pr list --label "$CI_LABEL" --state "open" | awk '{print $1;}' > $GDAS_CI_ROOT/open_pr_list
open_pr_list=$(cat $GDAS_CI_ROOT/open_pr_list)

# ==============================================================================
# clone, checkout, build, test, etc.
repo_url="https://github.com/NOAA-EMC/GDASApp.git"
# loop through all open PRs
for pr in $open_pr_list; do
gh pr edit $pr --remove-label $CI_LABEL --add-label ${CI_LABEL}-Running
echo "Processing Pull Request #${pr}"
mkdir -p $GDAS_CI_ROOT/PR/$pr
cd $GDAS_CI_ROOT/PR/$pr

# clone copy of repo
git clone $repo_url
cd GDASApp

# checkout pull request
git pull
gh pr checkout $pr

# get commit hash
commit=$(git log --pretty=format:'%h' -n 1)
if [ -f "$GDAS_CI_ROOT/PR/$pr/commit" ]; then
oldcommit=$(cat $GDAS_CI_ROOT/PR/$pr/commit)
if [ $oldcommit == $commit ]; then
# do no more for this PR, as the commit has already been tested
continue
fi
fi
echo "$commit" > $GDAS_CI_ROOT/PR/$pr/commit

# run build and testing command
$my_dir/run_ci.sh -d $GDAS_CI_ROOT/PR/$pr/GDASApp -o $GDAS_CI_ROOT/PR/$pr/output_${commit}
ci_status=$?
gh pr comment $pr --body-file $GDAS_CI_ROOT/PR/$pr/output_${commit}
if [ $ci_status -eq 0 ]; then
gh pr edit $pr --remove-label ${CI_LABEL}-Running --add-label ${CI_LABEL}-Passed
else
gh pr edit $pr --remove-label ${CI_LABEL}-Running --add-label ${CI_LABEL}-Failed
fi
done

# ==============================================================================
# scrub working directory for older files
find $GDAS_CI_ROOT/PR/* -mtime +3 -exec rm -rf {} \;

10 changes: 10 additions & 0 deletions ci/orion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
GDAS_CI_ROOT=/work2/noaa/stmp/cmartin/CI/GDASApp
Comment thread
aerorahul marked this conversation as resolved.
GDAS_CI_HOST='orion'
Comment thread
aerorahul marked this conversation as resolved.
export GDAS_MODULE_USE=$GDAS_CI_ROOT/repo/modulefiles
export SLURM_ACCOUNT=da-cpu
export SALLOC_ACCOUNT=$SLURM_ACCOUNT
export SBATCH_ACCOUNT=$SLURM_ACCOUNT
export SLURM_QOS=debug
export SLURM_EXCLUSIVE=user
export OMP_NUM_THREADS=1
ulimit -s unlimited
75 changes: 75 additions & 0 deletions ci/run_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash
#set -eu
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you intend to leave this commented out?


# ==============================================================================
usage() {
set +x
echo
echo "Usage: $0 -d <directory> -o <output> -h"
echo
echo " -d Run build and ctest for clone in <directory>"
echo " -o Path to output message detailing results of CI tests"
echo " -h display this message and quit"
echo
exit 1
}

# ==============================================================================
while getopts "d:o:h" opt; do
case $opt in
d)
repodir=$OPTARG
;;
o)
outfile=$OPTARG
;;
h|\?|:)
usage
;;
esac
done

# ==============================================================================
# start output file
echo "Automated Pull Request Testing Results:" > $outfile
echo "Machine: ${TARGET}" >> $outfile
echo '```' >> $outfile
echo "Start: $(date) on $(hostname)" >> $outfile
echo "---------------------------------------------------" >> $outfile
# ==============================================================================
# run build script
cd $repodir
module purge
./build.sh -t $TARGET &>> log.build
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you want to capture stderr as well? 2>&1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this do that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, but I may be wrong.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>> out is stdout but &>> adds the stderr I thought.

build_status=$?
if [ $build_status -eq 0 ]; then
echo "Build: *SUCCESS*" >> $outfile
echo "Build: Completed at $(date)" >> $outfile
else
echo "Build: *FAILED*" >> $outfile
echo "Build: Failed at $(date)" >> $outfile
echo "Build: see output at $repodir/log.build" >> $outfile
echo '```' >> $outfile
exit $build_status
fi
# ==============================================================================
# run ctests
cd $repodir/build
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CoryMartin-NOAA , why not limit the testing to this repo only and ignore the test status of the jedi components? It might sounds silly right now, but in the next few pr's we will have specific tests for the "prep" "run" and "post" steps, which will be making use of the various jedi components. I think it's a good enough "canary".
I vote for ctest -R gdasapp or something of that effect.
Or maybe 2 reports? One for the jedi components and one for the gdasapp tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you also suggest not building the JEDI apps (at least for now) also?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, we might as well do the build now. We're going to start adding tests using the jedi apps soon enough.
That's currently what I'm working on, just empty stubs right now but I'm hoping to have a basic jedi/soca var application by the end of the day:

build$ ctest -R gdasapp
Test project /home/gvernier/sandboxes/GDASApp/build
    Start 1448: test_gdasapp_soca_obsdb
1/4 Test #1448: test_gdasapp_soca_obsdb ..........   Passed    0.27 sec
    Start 1449: test_gdasapp_soca_ana_prep
2/4 Test #1449: test_gdasapp_soca_ana_prep .......   Passed    0.01 sec
    Start 1450: test_gdasapp_soca_ana_run
3/4 Test #1450: test_gdasapp_soca_ana_run ........   Passed    0.00 sec
    Start 1451: test_gdasapp_soca_ana_post
4/4 Test #1451: test_gdasapp_soca_ana_post .......   Passed    0.00 sec

100% tests passed, 0 tests failed out of 4

Label Time Summary:
gdasapp    =   0.29 sec*proc (4 tests)
script     =   0.29 sec*proc (4 tests)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to remember adding gdasapp (or something) to the one test we currently have. It's now called test_check_yaml_keys so something like test_gdasapp_check_yaml_keys, or whatever consensus we decide on.

module use $GDAS_MODULE_USE
module load GDAS/$TARGET
echo "---------------------------------------------------" >> $outfile
ctest -R gdasapp --output-on-failure &>> log.ctest
ctest_status=$?
npassed=$(cat log.ctest | grep "tests passed")
if [ $ctest_status -eq 0 ]; then
echo "Tests: *SUCCESS*" >> $outfile
echo "Tests: Completed at $(date)" >> $outfile
echo "Tests: $npassed" >> $outfile
else
echo "Tests: *Failed*" >> $outfile
echo "Tests: Failed at $(date)" >> $outfile
echo "Tests: $npassed" >> $outfile
echo "Tests: see output at $repodir/build/log.ctest" >> $outfile
fi
echo '```' >> $outfile
Comment thread
aerorahul marked this conversation as resolved.
exit $ctest_status
6 changes: 3 additions & 3 deletions modulefiles/GDAS/orion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ load("eckit/ecmwf-1.16.0")
load("fckit/ecmwf-0.9.2")
load("atlas/ecmwf-0.24.1")

load("hpc")
load("miniconda3")
load("gdasapp")
load("hpc/1.2.0")
load("miniconda3/4.6.14")
load("gdasapp/1.0.0")

setenv("CC","mpiicc")
setenv("FC","mpiifort")
Expand Down
6 changes: 3 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ install(FILES ${test_data}

##### unit tests
# test for python coding norms
add_test(NAME GDASApp_check_python_norms
add_test(NAME test_gdasapp_check_python_norms
COMMAND pycodestyle -v --config ./.pycodestyle .
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
# test for ush/check_yaml_keys.py
add_test(NAME GDASApp_check_yaml_keys
add_test(NAME test_gdasapp_check_yaml_keys
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/ush/check_yaml_keys.py ${PROJECT_SOURCE_DIR}/test/testinput/check_yaml_keys_ref.yaml ${PROJECT_SOURCE_DIR}/test/testinput/check_yaml_keys_test.yaml
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/)
# test for ush/jediinc2fv3.py
add_test(NAME GDASApp_jedi_increment_to_fv3
add_test(NAME test_gdasapp_jedi_increment_to_fv3
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/ush/jediinc2fv3.py ${PROJECT_BINARY_DIR}/test/testdata/atminc_compress.nc4 ${PROJECT_BINARY_DIR}/test/testdata/fv_increment.nc
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/)