forked from ufs-community/ufs-weather-model
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
152 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,161 @@ | ||
pipeline { | ||
agent none | ||
stages { | ||
stage('Run ORTs') { | ||
agent { | ||
label 'built-in' | ||
} | ||
steps { | ||
script { | ||
for (label in pullRequest.labels) { | ||
if ((label.matches("orion"))) { | ||
env.CHOICE_NODE='orion' | ||
} | ||
else if ((label.matches("hera"))) { | ||
env.CHOICE_NODE='hera' | ||
} | ||
else if ((label.matches("hercules"))) { | ||
env.CHOICE_NODE='hercules' | ||
} | ||
else if ((label.matches("jet"))) { | ||
env.CHOICE_NODE='jet' | ||
} | ||
else { | ||
env.CHOICE_NODE='none' | ||
def commentMessage | ||
|
||
void setBuildStatus(String message, String state) { | ||
step([ | ||
$class: "GitHubCommitStatusSetter", | ||
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/ufs-community/ufs-weather-model"], | ||
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "Jenkins-ci ORTs"], | ||
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]], | ||
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ] | ||
]); | ||
} | ||
|
||
def postGitHubCommentWithLogFile(commentMessage) { | ||
script { | ||
withCredentials([string(credentialsId: 'GithubJenkinsNew', variable: 'ACCESS_TOKEN')]) { | ||
def apiUrl = "https://api.github.com/repos/ufs-community/ufs-weather-model/issues/${env.CHANGE_ID}/comments" | ||
|
||
def curlCommand = "curl -s -H \"Authorization: token " + ACCESS_TOKEN + "\" \\\n" + | ||
"-X POST -d '{\"body\": \"" + commentMessage + "\"}' \\\n" + | ||
"\"" + apiUrl + "\"" | ||
|
||
def response = sh(script: curlCommand, returnStatus: true) | ||
|
||
if (response == 0) { | ||
echo "Comment added successfully to PR #${env.CHANGE_ID}" | ||
} else { | ||
error "Failed to add comment to PR #${env.CHANGE_ID}" | ||
} | ||
} | ||
// Why do I need another if..block, because it just works this way. | ||
} | ||
} | ||
} | ||
|
||
if (CHOICE_NODE == 'orion') { | ||
echo "Starting up orion ${CHOICE_NODE}...this might take 5-10 minutes...please be patient." | ||
|
||
} | ||
else if (CHOICE_NODE == 'jet') { | ||
echo "Starting up jet ${CHOICE_NODE}...this might take 5-10 minutes...please be patient." | ||
pipeline { | ||
agent none | ||
|
||
options { | ||
disableConcurrentBuilds() | ||
overrideIndexTriggers(false) | ||
skipDefaultCheckout(true) | ||
} | ||
stages { | ||
|
||
stage('Launch SonarQube') { | ||
steps { | ||
script { | ||
build job: '/ufs-weather-model/ufs-wm-sonarqube', parameters: [ | ||
string(name: 'BRANCH_NAME', value: env.CHANGE_BRANCH ?: 'develop'), | ||
string(name: 'FORK_NAME', value: env.CHANGE_FORK ?: '') | ||
], wait: false | ||
} | ||
} | ||
else if (CHOICE_NODE == 'hercules') { | ||
echo "Starting up hera ${CHOICE_NODE}...this might take 5-10 minutes...please be patient." | ||
} | ||
|
||
stage('ORT') { | ||
matrix { | ||
axes { | ||
axis { | ||
name 'TEST_NAME' | ||
values 'control_p8', 'regional_control', 'cpld_control_nowave_noaero_p8' | ||
} | ||
|
||
axis { | ||
name 'TEST_CASE' | ||
values 'thr', 'mpi', 'dcp', 'rst', 'bit', 'dbg' | ||
} | ||
} | ||
|
||
excludes { | ||
exclude { | ||
axis { | ||
name 'TEST_NAME' | ||
values 'cpld_control_nowave_noaero_p8' | ||
} | ||
|
||
axis { | ||
name 'TEST_CASE' | ||
values 'mpi', 'dcp', 'bit', 'thr' // TODO: Remove thr case from cpld_control_nowave_noaero_p8 exclusions when it is passing again | ||
} | ||
} | ||
exclude { | ||
axis { | ||
name 'TEST_NAME' | ||
values 'regional_control' | ||
} | ||
|
||
axis { | ||
name 'TEST_CASE' | ||
values 'mpi', 'rst', 'bit', 'dbg' | ||
} | ||
} | ||
} | ||
|
||
agent { | ||
label 'docker-ufs-wm-ci' | ||
} | ||
|
||
environment { | ||
IMG_NAME = 'ci-test-weather' | ||
} | ||
|
||
stages { | ||
stage('Initialize') { | ||
steps { | ||
cleanWs() | ||
checkout scm | ||
} | ||
} | ||
|
||
stage('Build') { | ||
steps { | ||
sh 'docker build --build-arg test_name="" --build-arg build_case="" --no-cache --compress --file "${WORKSPACE}/tests/ci/Dockerfile" --tag "${IMG_NAME}" "${WORKSPACE}"' | ||
} | ||
} | ||
|
||
stage('Stage Test Data') { | ||
steps { | ||
sh 'docker volume rm --force DataVolume && docker run --detach --rm --volume DataVolume:/tmp noaaepic/input-data:20221101' | ||
} | ||
} | ||
|
||
stage('Test') { | ||
steps { | ||
sh 'docker run --rm --env test_name="${TEST_NAME}" --env run_case="${TEST_CASE}" --workdir /home/builder/ufs-weather-model/tests --volume DataVolume:/home/builder/data/NEMSfv3gfs --interactive --shm-size=32gb "${IMG_NAME}"' | ||
} | ||
} | ||
} | ||
|
||
post { | ||
always { | ||
sh ''' | ||
docker rmi -f "$(docker image ls | grep -E -m1 "${IMG_NAME}" | awk '{ print $3 }')" | ||
docker rmi -f "$(docker image ls | grep -E -m1 'noaaepic' | awk '{ print $3 }')" | ||
''' | ||
} | ||
|
||
} | ||
} | ||
else if (CHOICE_NODE == 'hera') { | ||
echo "Starting up hera ${CHOICE_NODE}...this might take 5-10 minutes...please be patient." | ||
} | ||
} | ||
post { | ||
success { | ||
node('built-in') { | ||
setBuildStatus("Build succeeded", "SUCCESS"); | ||
} | ||
else { | ||
echo "${CHOICE_NODE} is NOT a platform, moving on..." | ||
} | ||
failure { | ||
node('built-in') { | ||
setBuildStatus("Build failed", "FAILURE"); | ||
} | ||
} | ||
} | ||
} | ||
stage('Run ORT on Hera') { | ||
agent { | ||
label "hera" | ||
} | ||
environment { | ||
ACCNR = 'epic' | ||
NODE_PATH = '/scratch2/NAGAPE/epic/role.epic/' | ||
} | ||
steps { | ||
|
||
cleanWs() | ||
checkout scm | ||
sh ''' | ||
git submodule update --init --recursive | ||
cd tests/fv3_conf | ||
sed 's/#SBATCH --time=.*/#SBATCH --time=02:00:00/g' -i fv3_slurm.IN_hera | ||
cd .. | ||
export machine=${NODE_NAME} | ||
export PATH=$PATH:~/bin | ||
echo $CHANGE_ID | ||
export SSH_ORIGIN=$(curl --silent https://api.github.com/repos/ufs-community/ufs-weather-model/pulls/$CHANGE_ID | jq -r '.head.repo.ssh_url') | ||
export FORK_BRANCH=$(curl --silent https://api.github.com/repos/ufs-community/ufs-weather-model/pulls/$CHANGE_ID | jq -r '.head.ref') | ||
pwd | ||
sed "s|intel|gnu|g" -i opnReqTest | ||
export ACCNR=epic | ||
./opnReqTest -n regional_control -a ${ACCNR} -c bit,dcp,thr | ||
cd logs/ | ||
cp OpnReqTests_regional_control_hera.log /scratch2/NAGAPE/epic/role.epic/jenkins/workspace | ||
cd .. | ||
./opnReqTest -n cpld_control_nowave_noaero_p8 -a ${ACCNR} -c dbg,rst | ||
cd logs/ | ||
cp OpnReqTests_cpld_control_nowave_noaero_p8_hera.log /scratch2/NAGAPE/epic/role.epic/jenkins/workspace | ||
cd .. | ||
./opnReqTest -n control_p8 -a ${ACCNR} -c std,dbg,bit,mpi,rst,thr,dcp | ||
cd logs/ | ||
cp OpnReqTests_control_p8_hera.log /scratch2/NAGAPE/epic/role.epic/jenkins/workspace | ||
git remote -v | ||
git fetch --no-recurse-submodules origin | ||
git reset FETCH_HEAD --hard | ||
cd .. && cd .. && cd .. | ||
cp OpnReqTests_control_p8_hera.log $WORKSPACE/tests/logs/ | ||
cp OpnReqTests_regional_control_hera.log $WORKSPACE/tests/logs/ | ||
cp OpnReqTests_cpld_control_nowave_noaero_p8_hera.log $WORKSPACE/tests/logs/ | ||
cd $WORKSPACE/tests/ | ||
git config user.email "ecc.platform@noaa.gov" | ||
git config user.name "epic-cicd-jenkins" | ||
echo "Testing concluded...removing labels for $machine from $GIT_URL" | ||
export machine_name_logs=$(echo $machine | awk '{ print tolower($1) }') | ||
git remote -v | grep -w sshorigin > /dev/null 2>&1 && git remote remove sshorigin > /dev/null 2>&1 | ||
git remote add sshorigin $SSH_ORIGIN > /dev/null 2>&1 | ||
git add logs/OpnReqTests_control_p8_hera.log logs/OpnReqTests_regional_control_hera.log logs/OpnReqTests_cpld_control_nowave_noaero_p8_hera.log | ||
git commit -m "ORT Jobs Completed.\n\n\n on-behalf-of @ufs-community <ecc.platform@noaa.gov>" | ||
git pull sshorigin $FORK_BRANCH | ||
git push sshorigin HEAD:$FORK_BRANCH | ||
''' | ||
always { | ||
node('built-in') { | ||
script { | ||
def buildResult = currentBuild.resultIsBetterOrEqualTo("SUCCESS") ? "passed" : "failed" | ||
commentMessage = "Jenkins-ci ORTs ${buildResult}" | ||
postGitHubCommentWithLogFile(commentMessage) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |