Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 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
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 --output-on-failure &>> log.ctest

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.

is this why set -e was commented up?
If so, you can wrap the ctest line around set +e and set -e.

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.

The set -e comes from conda when you do module load, it is something in the pyproj init shell script. I could probably manually fix this in the conda env if you think that is okay?

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
47 changes: 39 additions & 8 deletions modulefiles/GDAS/orion.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- NOAA HPC Orion Modulefile for UFS-DA
-- NOAA HPC Orion Modulefile for GDASApp
help([[
]])

Expand All @@ -11,19 +11,50 @@ setenv('JEDI_OPT', jedi_opt)
local jedi_core = pathJoin(jedi_opt, 'modulefiles/core')
prepend_path("MODULEPATH", jedi_core)

load('jedi/intel-impi')
prepend_path("MODULEPATH", '/work2/noaa/da/python/opt/modulefiles/stack')

load("cmake/3.18.1")
load("git/2.28.0")
load("git-lfs/2.13.2")

load("jedi-intel/2020.2")
load("mkl/2020.2")
load("szip/2.1.1")
load("zlib/1.2.11")
load("udunits/2.2.28")
load("gsl_lite/0.37.0")
load("jedi-impi/2020.2")

load("hdf5/1.12.0")
load("pnetcdf/1.12.1")
load("netcdf/4.7.4")

load("boost-headers/1.68.0")
load("eigen/3.3.7")
load("bufr/noaa-emc-11.5.0")
load("pybind11/2.7.0")
load("nccmp/1.8.7.0")
load("pio/2.5.1-debug")

load("ecbuild/ecmwf-3.6.1")
load("eckit/ecmwf-1.16.0")
load("fckit/ecmwf-0.9.2")
load("atlas/ecmwf-0.24.1")

load("hpc")
load("miniconda3")
load("gdasapp")

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.

Try and list the explicit versions instead of relying on defaults

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.

Good suggestion.


setenv("CC","mpiicc")
setenv("FC","mpiifort")
setenv("CXX","mpiicpc")
local mpiexec = '/opt/slurm/bin/srun'
local mpinproc = '-n'
setenv('MPIEXEC_EXEC', mpiexec)
setenv('MPIEXEC_NPROC', mpinproc)

-- add R2D2 and SOLO to PYTHONPATH
prepend_path("PYTHONPATH", "/work2/noaa/da/cmartin/UFSDA/python/local/lib/python3.9/site-packages")
-- add R2D2 to path
prepend_path("PATH", "/work2/noaa/da/cmartin/UFSDA/python/local/bin")

whatis("Name: ".. pkgName)
whatis("Version: " .. pkgVersion)
whatis("Category: UFS-DA")
whatis("Description: Load JEDI-Stack for UFS-DA")
whatis("Category: GDASApp")
whatis("Description: Load all libraries needed for GDASApp")