-
Notifications
You must be signed in to change notification settings - Fork 130
Check-in Jenkinsfile and unified scripts #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mark-a-potts
merged 1 commit into
ufs-community:develop
from
jessemcfarland:feature/cicd
May 19, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| pipeline { | ||
| agent none | ||
|
|
||
| options { | ||
| skipDefaultCheckout(true) | ||
| } | ||
|
|
||
| parameters { | ||
| // Allow job runner to filter based on platform | ||
| // choice(name: 'SRW_PLATFORM_FILTER', choices: ['all', 'cheyenne', 'gaea', 'orion', 'pcluster_noaa_v2_use1', 'azcluster_noaa', 'gcluster_noaa_v2_usc1'], description: 'Specify the platform(s) to use') | ||
| choice(name: 'SRW_PLATFORM_FILTER', choices: ['all', 'cheyenne', 'gaea', 'orion'], description: 'Specify the platform(s) to use') | ||
| // Allow job runner to filter based on compiler | ||
| choice(name: 'SRW_COMPILER_FILTER', choices: ['all', 'gnu', 'intel'], description: 'Specify the compiler(s) to use to build') | ||
| } | ||
|
|
||
| stages { | ||
| /* | ||
| // Start the NOAA Parallel Works clusters, if necessary | ||
| stage('Start Parallel Works Clusters') { | ||
| matrix { | ||
| // Start all clusters by default or only the specified cluster given by SRW_PLATFORM_FILTER | ||
| when { | ||
| anyOf { | ||
| expression { params.SRW_PLATFORM_FILTER == 'all' } | ||
| expression { params.SRW_PLATFORM_FILTER == env.SRW_PLATFORM } | ||
| } | ||
| } | ||
|
|
||
| axes { | ||
| axis { | ||
| name 'SRW_PLATFORM' | ||
| values 'pcluster_noaa_v2_use1', 'azcluster_noaa', 'gcluster_noaa_v2_usc1' | ||
| } | ||
| } | ||
|
|
||
| stages { | ||
| // Call the parallel-works-jenkins-client/start-cluster job using SRW_PLATFORM for the | ||
| // PW_CLUSTER_NAME parameter | ||
| stage('Start Cluster') { | ||
| steps { | ||
| build job: 'parallel-works-jenkins-client/start-cluster', parameters: [string(name: 'PW_CLUSTER_NAME', value: env.SRW_PLATFORM), string(name: 'PW_CLUSTER_SSH_KEY', value: '~/.ssh/id_rsa'), string(name: 'JAVA_VERSION', value: '11')] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| */ | ||
|
|
||
| // Build and test the SRW application on all supported platforms using the supported compilers for each platform | ||
| stage('Build and Test') { | ||
| matrix { | ||
| // Run on all platform/compiler combinations by default or build and test only on the platform(s) and | ||
| // compiler(s) specified by SRW_PLATFORM_FILTER and SRW_COMPILER_FILTER | ||
| when { | ||
| allOf { | ||
| anyOf { | ||
| expression { params.SRW_PLATFORM_FILTER == 'all' } | ||
| expression { params.SRW_PLATFORM_FILTER == env.SRW_PLATFORM } | ||
| } | ||
|
|
||
| anyOf { | ||
| expression { params.SRW_COMPILER_FILTER == 'all' } | ||
| expression { params.SRW_COMPILER_FILTER == env.SRW_COMPILER } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| axes { | ||
| axis { | ||
| name 'SRW_PLATFORM' | ||
| // values 'cheyenne', 'gaea', 'orion', 'pcluster_noaa_v2_use1', 'azcluster_noaa', 'gcluster_noaa_v2_usc1' | ||
| values 'cheyenne', 'gaea', 'orion' | ||
| } | ||
|
|
||
| axis { | ||
| name 'SRW_COMPILER' | ||
| values 'gnu', 'intel' | ||
| } | ||
| } | ||
|
|
||
| excludes { | ||
| // Exclude GNU from platforms that don't support it | ||
| exclude { | ||
| axis { | ||
| name 'SRW_PLATFORM' | ||
| values 'gaea', 'orion' | ||
| } | ||
|
|
||
| axis { | ||
| name 'SRW_COMPILER' | ||
| values 'gnu' | ||
| } | ||
| } | ||
| } | ||
|
|
||
| agent { | ||
| label env.SRW_PLATFORM | ||
| } | ||
|
|
||
| environment { | ||
| BUILD_VERSION = "${env.SRW_PLATFORM}-${env.SRW_COMPILER}-${env.BRANCH_NAME}-${env.BUILD_NUMBER}" | ||
| BUILD_NAME = "ufs-srweather-app_${env.BUILD_VERSION}" | ||
| } | ||
|
|
||
| stages { | ||
| // Clean the workspace, checkout the repository, and run checkout_externals | ||
| stage('Initialize') { | ||
| steps { | ||
| echo "Initializing SRW (${env.SRW_COMPILER}) build environment on ${env.SRW_PLATFORM}" | ||
| cleanWs() | ||
| checkout scm | ||
| sh '"${WORKSPACE}/manage_externals/checkout_externals"' | ||
| } | ||
| } | ||
|
|
||
| // Run the unified build script; if successful create a tarball of the build and upload to S3 | ||
| stage('Build') { | ||
| steps { | ||
| echo "Building SRW (${env.SRW_COMPILER}) on ${env.SRW_PLATFORM}" | ||
| sh 'bash --login "${WORKSPACE}/.cicd/scripts/srw_build.sh"' | ||
| } | ||
|
|
||
| post { | ||
| success { | ||
| sh 'tar --create --gzip --verbose --file "${WORKSPACE}/${BUILD_NAME}.tgz" bin include lib share' | ||
| s3Upload consoleLogLevel: 'INFO', dontSetBuildResultOnFailure: false, dontWaitForConcurrentBuildCompletion: false, entries: [[bucket: 'woc-epic-jenkins-artifacts', excludedFile: '', flatten: false, gzipFiles: false, keepForever: false, managedArtifacts: true, noUploadOnFailure: true, selectedRegion: 'us-east-1', showDirectlyInBrowser: false, sourceFile: "${env.BUILD_NAME}.tgz", storageClass: 'STANDARD', uploadFromSlave: false, useServerSideEncryption: false]], pluginFailureResultConstraint: 'FAILURE', profileName: 'main', userMetadata: [] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Run the unified test script | ||
| stage('Test') { | ||
| steps { | ||
| echo "Testing SRW (${env.SRW_COMPILER}) on ${env.SRW_PLATFORM}" | ||
| sh 'bash --login "${WORKSPACE}/.cicd/scripts/srw_test.sh"' | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| post { | ||
| always { | ||
| // Stop any Parallel Works clusters that were started during the pipeline execution | ||
| script { | ||
| def pw_clusters = ['pcluster_noaa_v2_use1', 'azcluster_noaa', 'gcluster_noaa_v2_usc1'] | ||
| def clusters = [] | ||
|
|
||
| // Determine which clusters need to be stopped, if any | ||
| if (params.SRW_PLATFORM_FILTER == 'all') { | ||
| clusters = pw_clusters | ||
| } else if (params.SRW_PLATFORM_FILTER in pw_clusters) { | ||
| clusters = [params.SRW_PLATFORM_FILTER] | ||
| } else { | ||
| echo 'No Parallel Works clusters were used in build' | ||
| } | ||
|
|
||
| for (int i = 0; i < clusters.size(); ++i) { | ||
| // Call the parallel-works-jenkins-client/stop-cluster job using clusters[i] for the | ||
| // PW_CLUSTER_NAME parameter | ||
| build job: 'parallel-works-jenkins-client/stop-cluster', parameters: [string(name: 'PW_CLUSTER_NAME', value: clusters[i])] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| */ | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/usr/bin/env bash | ||
|
gsketefian marked this conversation as resolved.
|
||
| # | ||
| # A unified build script for the SRW application. This script is expected to | ||
| # build the SRW application for all supported platforms. | ||
| # | ||
| set -e -u -x | ||
|
|
||
| script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" | ||
|
|
||
| # Get repository root from Jenkins WORKSPACE variable if set, otherwise, set | ||
| # relative to script directory. | ||
| declare workspace | ||
| if [[ -n "${WORKSPACE}" ]]; then | ||
| workspace="${WORKSPACE}" | ||
| else | ||
| workspace="$(cd -- "${script_dir}/../.." && pwd)" | ||
| fi | ||
|
|
||
| build_dir="${workspace}/build" | ||
|
|
||
| # Set build related environment variables and load required modules. | ||
| source "${workspace}/etc/lmod-setup.sh" "${SRW_PLATFORM}" | ||
| module use "${workspace}/modulefiles" | ||
| module load "build_${SRW_PLATFORM}_${SRW_COMPILER}" | ||
|
|
||
| # Compile SRW application and install to repository root. | ||
| mkdir "${build_dir}" | ||
| pushd "${build_dir}" | ||
| cmake -DCMAKE_INSTALL_PREFIX="${workspace}" "${workspace}" | ||
| make -j "${MAKE_JOBS}" | ||
| popd | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/usr/bin/env bash | ||
|
gsketefian marked this conversation as resolved.
|
||
| # | ||
| # A unified test script for the SRW application. This script is expected to | ||
| # test the SRW application for all supported platforms. NOTE: At this time, | ||
| # this script is a placeholder for a more robust test framework. | ||
| # | ||
| set -e -u -x | ||
|
|
||
| script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" | ||
|
|
||
| # Get repository root from Jenkins WORKSPACE variable if set, otherwise, set | ||
| # relative to script directory. | ||
| declare workspace | ||
| if [[ -n "${WORKSPACE}" ]]; then | ||
| workspace="${WORKSPACE}" | ||
| else | ||
| workspace="$(cd -- "${script_dir}/../.." && pwd)" | ||
| fi | ||
|
|
||
| # Verify that there is a non-zero sized weather model executable. | ||
| [[ -s "${workspace}/bin/ufs_model" ]] || [[ -s "${workspace}/bin/NEMS.exe" ]] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.