Skip to content

Commit 062987a

Browse files
Merge branch 'develop' into feature/wcoss2_spack-stack
2 parents bd19676 + a36255a commit 062987a

File tree

90 files changed

+1626
-2035
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1626
-2035
lines changed

.github/pull_request_template.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Description
2+
3+
<!-- Enter PR description here. -->
4+
5+
# Companion PRs
6+
7+
<!-- Enter links to any companion PRs here. -->
8+
9+
# Issues
10+
11+
<!-- Enter any issues referenced or resolved by this PR here. Use keywords "Resolves" or "Refs".
12+
Resolves #1234
13+
Refs #4321
14+
Refs NOAA-EMC/repo#5678
15+
-->
16+
17+
# Automated CI tests to run in Global Workflow
18+
<!-- Which Global Workflow CI tests are required to adequately test this PR? -->
19+
- [ ] atm_jjob <!-- JEDI atm single cycle DA !-->
20+
- [ ] C96C48_ufs_hybatmDA <!-- JEDI atm cycled DA !-->
21+
- [ ] C96C48_hybatmaerosnowDA <!-- JEDI aero/snow cycled DA !-->
22+
- [ ] C48mx500_3DVarAOWCDA <!-- JEDI low-res marine 3DVar cycled DA !-->
23+
- [ ] C48mx500_hybAOWCDA <!-- JEDI marine hybrid envar cycled DA !-->
24+
- [ ] C96C48_hybatmDA <!-- GSI atm cycled DA !-->

ci/ci_tests.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CI_TESTS=("atm_jjob"
2+
"C96C48_ufs_hybatmDA"
3+
"C96C48_hybatmaerosnowDA"
4+
"C48mx500_3DVarAOWCDA"
5+
"C48mx500_hybAOWCDA"
6+
"C96C48_hybatmDA")

ci/driver.sh

Lines changed: 123 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash --login
22

3-
echo "Start at $(date)"
3+
echo "Starting automated testing at $(date)"
44

55
my_dir="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
66
echo "Set my_dir ${my_dir}"
@@ -13,6 +13,7 @@ usage() {
1313
echo
1414
echo " -t target/machine script is running on DEFAULT: $(hostname)"
1515
echo " -h display this message and quit"
16+
echo " -w run workflow tests on $(hostname)"
1617
echo
1718
exit 1
1819
}
@@ -22,20 +23,25 @@ usage() {
2223

2324
export TARGET="$(hostname)"
2425

25-
while getopts "t:h" opt; do
26+
TEST_WORKFLOW=0
27+
while getopts "t:h:w" opt; do
2628
case $opt in
2729
t)
2830
TARGET=$OPTARG
2931
;;
3032
h|\?|:)
3133
usage
3234
;;
35+
w)
36+
TEST_WORKFLOW=1
37+
;;
3338
esac
3439
done
3540

41+
echo "Running automated testing on $TARGET"
42+
3643
case ${TARGET} in
37-
hera | orion)
38-
echo "Running Automated Testing on $TARGET"
44+
hera | orion | hercules)
3945
source $MODULESHOME/init/sh
4046
source $my_dir/${TARGET}.sh
4147
module purge
@@ -49,106 +55,176 @@ case ${TARGET} in
4955
;;
5056
esac
5157

58+
# ==============================================================================
59+
# set list of available CI tests to run on the Global Workflow
60+
source $my_dir/ci_tests.sh
61+
62+
# ==============================================================================
63+
# set things that depend on whether running workflow tests or not
64+
gdasapp_url="https://github.com/NOAA-EMC/GDASApp.git"
65+
if [[ $TEST_WORKFLOW == 1 ]]; then
66+
echo "Testing GDASApp inside the Global Workflow"
67+
68+
CI_LABEL="${GDAS_CI_HOST}-GW-RT"
69+
OPEN_PR_LIST_DIR=$GDAS_CI_ROOT/open_pr_list_gw
70+
PR_TEST_DIR=$GDAS_CI_ROOT/workflow/PR
71+
BASE_REPO=global-workflow
72+
73+
# Default Global Workflow repo and branch if no companion PR found
74+
workflow_url="https://github.com/NOAA-EMC/global-workflow.git"
75+
workflow_branch="develop"
76+
else
77+
echo "Testing stand-alone GDASApp"
78+
79+
CI_LABEL="${GDAS_CI_HOST}-RT"
80+
OPEN_PR_LIST_DIR=$GDAS_CI_ROOT/open_pr_list
81+
PR_TEST_DIR=$GDAS_CI_ROOT/PR
82+
BASE_REPO=GDASApp
83+
fi
84+
5285
# ==============================================================================
5386
# pull on the repo and get list of open PRs
87+
5488
cd $GDAS_CI_ROOT/repo
55-
CI_LABEL="${GDAS_CI_HOST}-RT"
56-
gh pr list --label "$CI_LABEL" --state "open" | awk '{print $1;}' > $GDAS_CI_ROOT/open_pr_list
5789

58-
open_pr=`cat $GDAS_CI_ROOT/open_pr_list | wc -l`
90+
gh pr list --label "$CI_LABEL" --state "open" | awk '{print $1;}' > $OPEN_PR_LIST_DIR
91+
92+
open_pr=`cat $OPEN_PR_LIST_DIR | wc -l`
5993
if (( $open_pr == 0 )); then
6094
echo "No open PRs with ${CI_LABEL}, exit."
61-
echo "Finish at $(date)"
95+
echo "Finished automated testing at $(date)"
6296
exit
6397
fi
6498

65-
open_pr_list=$(cat $GDAS_CI_ROOT/open_pr_list)
99+
open_pr_list=$(cat $OPEN_PR_LIST_DIR)
66100

67101
# ==============================================================================
68102
# clone, checkout, build, test, etc.
69-
repo_url="https://github.com/NOAA-EMC/GDASApp.git"
70103
# loop through all open PRs
71104
for pr in $open_pr_list; do
72105
echo " "
73-
echo "Start processing Pull Request #${pr} at $(date)"
106+
echo "Starting processing of pull request #${pr} at $(date)"
74107

75108
# get the branch name used for the PR
76109
gdasapp_branch=$(gh pr view $pr --json headRefName -q ".headRefName")
77110

78-
# get additional branch information
79-
branch_owner=$(gh pr view $pr --repo ${repo_url} --json headRepositoryOwner --jq '.headRepositoryOwner.login')
80-
branch_name=$(gh pr view $pr --repo ${repo_url} --json headRepository --jq '.headRepository.name')
81-
pr_assignees=$(gh pr view $pr --repo ${repo_url} --json assignees --jq '.assignees[].login')
82-
111+
# get additional branch informatio
112+
branch_owner=$(gh pr view $pr --repo ${gdasapp_url} --json headRepositoryOwner --jq '.headRepositoryOwner.login')
113+
branch_name=$(gh pr view $pr --repo ${gdasapp_url} --json headRepository --jq '.headRepository.name')
114+
pr_assignees=$(gh pr view $pr --repo ${gdasapp_url} --json assignees --jq '.assignees[].login')
115+
83116
# check if any assignee is authorized to run CI
84-
authorized_by=""
117+
rc=1
85118
for str in ${pr_assignees[@]}; do
86-
grep $str /scratch1/NCEPDEV/da/role.jedipara/CI/GDASApp/authorized_users
87-
rc=$?
119+
grep $str $AUTHORIZED_USERS_FILE > /dev/null
120+
if (( rc != 0 )); then
121+
rc=$?
122+
fi
88123
if (( rc == 0 )); then
89-
authorized_by=${str}
90-
echo "FOUND MATCH $str, rc $rc"
91-
break
124+
echo "Authorized user $str assigned to this PR"
92125
fi
93126
done
94127

95128
# Authorized to run CI
96129
if (( rc == 0 )); then
97-
echo "Run CI"
130+
echo "CI authorized. Running CI..."
98131

99132
# update PR label
100133
gh pr edit $pr --remove-label $CI_LABEL --add-label ${CI_LABEL}-Running
101-
102-
# construct the fork URL
103-
gdasapp_url="https://github.com/$branch_owner/${branch_name}.git"
104-
134+
105135
echo "GDASApp URL: $gdasapp_url"
106136
echo "GDASApp branch Name: $gdasapp_branch"
107-
echo "CI authorized by $authorized_by at $(date)"
137+
138+
if [[ $TEST_WORKFLOW == 1 ]]; then
139+
# check for a companion PR in the global-workflow
140+
companion_pr_exists=$(gh pr list --repo ${workflow_url} --head ${gdasapp_branch} --state open)
141+
142+
if [ -n "$companion_pr_exists" ]; then
143+
# get the PR number
144+
companion_pr=$(echo "$companion_pr_exists" | awk '{print $1;}')
145+
146+
# extract the necessary info
147+
branch_owner=$(gh pr view $companion_pr --repo $workflow_url --json headRepositoryOwner --jq '.headRepositoryOwner.login')
148+
branch_name=$(gh pr view $companion_pr --repo $workflow_url --json headRepository --jq '.headRepository.name')
149+
150+
# Construct fork URL. Update workflow branch name
151+
workflow_url="https://github.com/$branch_owner/$branch_name.git"
152+
workflow_branch=$gdasapp_branch
153+
fi
154+
155+
echo "Found companion Global Workflow PR #${companion_pr}!"
156+
echo "Global Workflow URL: $workflow_url"
157+
echo "Global Workflow branch name: $workflow_branch"
158+
fi
108159

109-
# create PR specific directory
110-
if [ -d $GDAS_CI_ROOT/PR/$pr ]; then
111-
rm -rf $GDAS_CI_ROOT/PR/$pr
160+
# create PR specific directory
161+
if [ -d $PR_TEST_DIR/$pr ]; then
162+
rm -rf $PR_TEST_DIR/$pr
112163
fi
113-
mkdir -p $GDAS_CI_ROOT/PR/$pr
114-
cd $GDAS_CI_ROOT/PR/$pr
164+
mkdir -p $PR_TEST_DIR/$pr
165+
cd $PR_TEST_DIR/$pr
115166
pwd
116167

117168
# clone copy of repo
118-
git clone --recursive --jobs 8 --branch $gdasapp_branch $gdasapp_url
119-
cd GDASApp
169+
if [[ $TEST_WORKFLOW == 1 ]]; then
170+
echo "Cloning Global Workflow branch $workflow_branch from $workflow_url at $(date)"
171+
git clone --recursive --jobs 8 --branch $workflow_branch $workflow_url
172+
cd global-workflow/sorc/gdas.cd
173+
else
174+
echo "Cloning GDASApp branch $workflow_branch at $(date)"
175+
git clone --recursive --jobs 8 --branch $gdasapp_branch $gdasapp_url
176+
cd GDASApp
177+
fi
120178
pwd
121179

122180
# checkout GDASApp pull request
123-
git pull
124181
gh pr checkout $pr
125182
git submodule update --init --recursive
126183

127184
# get commit hash
128185
commit=$(git log --pretty=format:'%h' -n 1)
129-
echo "$commit" > $GDAS_CI_ROOT/PR/$pr/commit
186+
echo "$commit" > $PR_TEST_DIR/$pr/commit
130187

131188
# run build and testing command
132-
echo "Execute $my_dir/run_ci.sh for $GDAS_CI_ROOT/PR/$pr/GDASApp at $(date)"
133-
$my_dir/run_ci.sh -d $GDAS_CI_ROOT/PR/$pr/GDASApp -o $GDAS_CI_ROOT/PR/$pr/output_${commit}
189+
echo "Running run_ci.sh for $PR_TEST_DIR/$pr/$BASE_REPO at $(date)"
190+
run_ci_cmd="$my_dir/run_ci.sh -d $PR_TEST_DIR/$pr/$BASE_REPO -o $PR_TEST_DIR/$pr/output_${commit}"
191+
if [[ $TEST_WORKFLOW == 1 ]]; then
192+
# get ci tests from PR description and convert into a regular expressions to be excluded
193+
branch_body=$(gh pr view $pr --repo ${gdasapp_url} --json body --jq '.body')
194+
ci_checklist=$(echo "$branch_body" | grep '\[x\]')
195+
ctest_regex_exclude=""
196+
for ci_test in ${CI_TESTS[@]}; do
197+
if ! echo "$ci_checklist" | grep -q "$ci_test"; then
198+
ctest_regex_exclude+="${ctest_regex_exclude:+|}$ci_test"
199+
fi
200+
done
201+
202+
# setup run_ci.sh arguments to test in the Global Workflow and exclude chosen CI tests
203+
run_ci_cmd+=" -w"
204+
if [ -n "$ctest_regex_exclude" ]; then
205+
run_ci_cmd+=" -E $ctest_regex_exclude"
206+
fi
207+
fi
208+
$run_ci_cmd
134209
ci_status=$?
135-
echo "After run_ci.sh with ci_status ${ci_status} at $(date)"
136-
gh pr comment $pr --repo ${repo_url} --body-file $GDAS_CI_ROOT/PR/$pr/output_${commit}
210+
echo "Finished running run_ci.sh with ci_status ${ci_status} at $(date)"
211+
212+
gh pr comment $pr --repo ${gdasapp_url} --body-file $PR_TEST_DIR/$pr/output_${commit}
137213
if [ $ci_status -eq 0 ]; then
138-
gh pr edit $pr --repo ${repo_url} --remove-label ${CI_LABEL}-Running --add-label ${CI_LABEL}-Passed
214+
gh pr edit $pr --repo ${gdasapp_url} --remove-label ${CI_LABEL}-Running --add-label ${CI_LABEL}-Passed
139215
else
140-
gh pr edit $pr --repo ${repo_url} --remove-label ${CI_LABEL}-Running --add-label ${CI_LABEL}-Failed
216+
gh pr edit $pr --repo ${gdasapp_url} --remove-label ${CI_LABEL}-Running --add-label ${CI_LABEL}-Failed
141217
fi
142218

143219
# Not authorized to run CI
144220
else
145-
echo "Do NOT run CI"
221+
echo "No authorized users assigned to this PR. Aborting CI..."
146222
fi
147223

148-
echo "Finish processing Pull Request #{pr} at $(date)"
224+
echo "Finished processing Pull Request #${pr} at $(date)"
149225
done
150226

151227
# ==============================================================================
152228
# scrub working directory for older files
153-
find $GDAS_CI_ROOT/PR/* -maxdepth 1 -mtime +3 -exec rm -rf {} \;
154-
echo "Finish at $(date)"
229+
find $PR_TEST_DIR/* -maxdepth 1 -mtime +3 -exec rm -rf {} \;
230+
echo "Finished automated testing at $(date)"

0 commit comments

Comments
 (0)