-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathstable_driver.sh
executable file
·150 lines (131 loc) · 4.36 KB
/
stable_driver.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/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 stability check 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
set -x
# ==============================================================================
datestr="$(date +%Y%m%d)"
repo_url="https://github.com/NOAA-EMC/GDASApp.git"
workflow_url="https://github.com/NOAA-EMC/global-workflow.git"
stableroot=$GDAS_CI_ROOT/stable
[[ -d $stableroot/$datestr ]] && rm -rf $stableroot/$datestr
mkdir -p $stableroot/$datestr
cd $stableroot/$datestr
# clone global workflow develop branch
git clone --recursive $workflow_url
# checkout develop
cd $stableroot/$datestr/global-workflow/sorc/gdas.cd
git checkout develop
git pull
git submodule update --init --recursive
# ==============================================================================
# update the hashes to the most recent
gdasdir=$stableroot/$datestr/global-workflow/sorc/gdas.cd
$gdasdir/ush/submodules/update_develop.sh $gdasdir
# ==============================================================================
# email information
PEOPLE="Cory.R.Martin@noaa.gov David.New@noaa.gov Russ.Treadon@noaa.gov"
BODY=$stableroot/$datestr/stable_nightly
# ==============================================================================
# run the automated testing
$my_dir/run_ci.sh -d $stableroot/$datestr/global-workflow -o $stableroot/$datestr/output -w
ci_status=$?
total=0
if [ $ci_status -eq 0 ]; then
cd $gdasdir
# checkout feature/stable-nightly
git checkout feature/stable-nightly
rc=$?
total=$(($total+$rc))
if [ $rc -ne 0 ]; then
echo "Unable to checkout feature/stable-nightly" >> $stableroot/$datestr/output
fi
# merge in develop
git merge develop
rc=$?
total=$(($total+$rc))
if [ $rc -ne 0 ]; then
echo "Unable to merge develop" >> $stableroot/$datestr/output
fi
# add in submodules
$gdasdir/ush/submodules/add_submodules.sh $gdasdir
rc=$?
total=$(($total+$rc))
if [ $rc -ne 0 ]; then
echo "Unable to add updated submodules to commit" >> $stableroot/$datestr/output
fi
git diff-index --quiet HEAD || git commit -m "Update to new stable build on $datestr"
rc=$?
total=$(($total+$rc))
if [ $rc -ne 0 ]; then
echo "Unable to commit" >> $stableroot/$datestr/output
fi
git push --set-upstream origin feature/stable-nightly
rc=$?
total=$(($total+$rc))
if [ $rc -ne 0 ]; then
echo "Unable to push" >> $stableroot/$datestr/output
fi
if [ $total -ne 0 ]; then
SUBJECT="Problem updating feature/stable-nightly branch of GDASApp"
cat > $BODY << EOF
Problem updating feature/stable-nightly branch of GDASApp. Please check $stableroot/$datestr/global-workflow
EOF
else
SUBJECT="Success updating feature/stable-nightly branch of GDASApp"
cat > $BODY << EOF
feature/stable-nightly branch of GDASApp updated successfully. See $stableroot/$datestr/global-workflow for details.
EOF
fi
else
# do nothing
SUBJECT="Testing or building of feature/stable-nightly branch of GDASApp failed"
cat > $BODY << EOF
Testing or building of feature/stable-nightly branch of GDASApp failed. Please check $stableroot/$datestr/global-workflow.
EOF
fi
echo $SUBJECT
mail -r "Darth Vader - NOAA Affiliate <darth.vader@noaa.gov>" -s "$SUBJECT" "$PEOPLE" < $BODY
# ==============================================================================
# publish some information to RZDM for quick viewing
# THIS IS A TODO FOR NOW
# ==============================================================================
# scrub working directory for older files
find $stableroot/* -maxdepth 1 -mtime +1 -exec rm -rf {} \;