Skip to content

Commit

Permalink
Merge branch 'jenkins_experimental' into jenkins_test
Browse files Browse the repository at this point in the history
  • Loading branch information
a-larkins99 committed Jan 10, 2024
2 parents 4d2def4 + eef14c3 commit 0d587ae
Showing 1 changed file with 126 additions and 109 deletions.
235 changes: 126 additions & 109 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ properties([
description: 'Agent to run the build on.',
trim: true
),
string(
name: 'PYTHON_VERSION',
defaultValue: '3.8',
choice(
name: 'PYTHON_FILTER',
choices: ['all','3.7','3.8','3.9','3.10','3.11'],
description: 'Version of python to run the build with.',
trim: true
),
Expand Down Expand Up @@ -57,130 +57,146 @@ def name_conda_env(String python_version) {

pipeline {

//NOTE: may need moving to within matrix
agent {
label get_agent(env.JOB_BASE_NAME)
}

environment {
ENV_NAME = name_conda_env(env.PYTHON_VERSION)
}
// IDEA: could apply a filter with all as an option
matrix {

stages {
when { anyOf {
expression { params.PYTHON_FILTER == 'all' }
expression { params.PYTHON_FILTER == env.PYTHON_VERSION }
} }

stage('Notify') {
steps {
post_github_status("pending", "The build is running")
axes {
axis {
name 'PYTHON_VERSION'
values '3.7','3.8','3.9','3.10','3.11'
}
}

stage("Build-Pace-Python") {
steps {
script {
if (isUnix()) {
sh '''
module purge
module load matlab/\$MATLAB_VERSION
module load cmake
module load conda
module load gcc/\$GCC_VERSION
conda create -n \$ENV_NAME -c conda-forge python=\$PYTHON_VERSION -y
conda activate \$ENV_NAME
conda install -c conda-forge setuptools
python setup.py bdist_wheel
'''
archiveArtifacts artifacts: 'dist/*whl'
}
else {
powershell '''
conda create -n \$env:ENV_NAME -c conda-forge python=\$env:PYTHON_VERSION -y
conda activate \$env:ENV_NAME
conda install -c conda-forge setuptools
python setup.py bdist_wheel -DMatlab_ROOT_DIR=/opt/modules-common/software/MATLAB/R\$env:MATLAB_VERSION
'''
archiveArtifacts artifacts: 'dist/*whl'
}
}
}
environment {
ENV_NAME = name_conda_env(env.PYTHON_VERSION)
}

stage("Get-Pace-Python-Demo") {
steps {
dir('demo') {
checkout([
$class: 'GitSCM',
branches: [[name: "refs/heads/main"]],
extensions: [[$class: 'WipeWorkspace']],
userRemoteConfigs: [[url: 'https://github.com/pace-neutrons/pace-python-demo']]
])
stages {

stage('Notify') {
steps {
post_github_status("pending", "The build is running")
}
}
}

stage("Run-Pace-Python-Tests") {
environment {
LD_LIBRARY_PATH = "/opt/modules-common/software/MATLAB/R2020b/runtime/glnxa64:/opt/modules-common/software/MATLAB/R2020b/bin/glnxa64"
LD_PRELOAD = "/opt/modules-common/software/MATLAB/R2020b/sys/os/glnxa64/libiomp5.so"
stage("Build-Pace-Python") {
steps {
script {
if (isUnix()) {
sh '''
module purge
module load matlab/\$MATLAB_VERSION
module load cmake
module load conda
module load gcc/\$GCC_VERSION
conda create -n \$ENV_NAME -c conda-forge python=\$PYTHON_VERSION -y
conda activate \$ENV_NAME
conda install -c conda-forge setuptools
python setup.py bdist_wheel
'''
archiveArtifacts artifacts: 'dist/*whl'
}
else {
powershell '''
conda create -n \$env:ENV_NAME -c conda-forge python=\$env:PYTHON_VERSION -y
conda activate \$env:ENV_NAME
conda install -c conda-forge setuptools
python setup.py bdist_wheel -DMatlab_ROOT_DIR=/opt/modules-common/software/MATLAB/R\$env:MATLAB_VERSION
'''
archiveArtifacts artifacts: 'dist/*whl'
}
}
}
}
steps {
script {
if (isUnix()) {
sh '''
module purge
module load conda
module load matlab/\$MATLAB_VERSION
eval "$(/opt/conda/bin/conda shell.bash hook)"
conda env remove -n \$ENV_NAME
conda create -n \$ENV_NAME -c conda-forge python=\$PYTHON_VERSION -y
conda activate \$ENV_NAME
pip install numpy scipy euphonic --no-input
export MKL_NUM_THREADS=1
python -m pip install brille
python -m pip install $(find dist -name "*whl"|tail -n1)
timeout --signal 15 6m python test/run_test.py -v
test -f success
'''

stage("Get-Pace-Python-Demo") {
steps {
dir('demo') {
checkout([
$class: 'GitSCM',
branches: [[name: "refs/heads/main"]],
extensions: [[$class: 'WipeWorkspace']],
userRemoteConfigs: [[url: 'https://github.com/pace-neutrons/pace-python-demo']]
])
}
else {
powershell '''
conda env remove -n \$env:ENV_NAME
conda create -n \$env:ENV_NAME -c conda-forge python=\$env:PYTHON_VERSION -y
conda activate \$env:ENV_NAME
conda install -c conda-forge scipy euphonic -y
python -m pip install brille
python -m pip install ./dist/*.whl
python test/run_test.py -v
'''
}
}

stage("Run-Pace-Python-Tests") {
environment {
LD_LIBRARY_PATH = "/opt/modules-common/software/MATLAB/R2020b/runtime/glnxa64:/opt/modules-common/software/MATLAB/R2020b/bin/glnxa64"
LD_PRELOAD = "/opt/modules-common/software/MATLAB/R2020b/sys/os/glnxa64/libiomp5.so"
}
steps {
script {
if (isUnix()) {
sh '''
module purge
module load conda
module load matlab/\$MATLAB_VERSION
eval "$(/opt/conda/bin/conda shell.bash hook)"
conda env remove -n \$ENV_NAME
conda create -n \$ENV_NAME -c conda-forge python=\$PYTHON_VERSION -y
conda activate \$ENV_NAME
pip install numpy scipy euphonic --no-input
export MKL_NUM_THREADS=1
python -m pip install brille
python -m pip install $(find dist -name "*whl"|tail -n1)
timeout --signal 15 6m python test/run_test.py -v
test -f success
'''
}
else {
powershell '''
conda env remove -n \$env:ENV_NAME
conda create -n \$env:ENV_NAME -c conda-forge python=\$env:PYTHON_VERSION -y
conda activate \$env:ENV_NAME
conda install -c conda-forge scipy euphonic -y
python -m pip install brille
python -m pip install ./dist/*.whl
python test/run_test.py -v
'''
}
}
}
}
}

// stage("Push release") {
// environment {
// GITHUB_TOKEN = get_github_token()
// }
// steps {
// script {
// if (env.ref_type == 'tag') {
// if (isUnix()) {
// sh '''
// podman run -v `pwd`:/mnt localhost/pace_python_builder /mnt/installer/jenkins_compiler_installer.sh
// eval "$(/opt/conda/bin/conda shell.bash hook)"
// conda activate py37
// pip install requests pyyaml
// python release.py --github --notest
// '''
// } else {
// powershell './cmake/run_release.ps1'
// }
// }
// }
// }
// }
// stage("Push release") {
// environment {
// GITHUB_TOKEN = get_github_token()
// }
// steps {
// script {
// if (env.ref_type == 'tag') {
// if (isUnix()) {
// sh '''
// podman run -v `pwd`:/mnt localhost/pace_python_builder /mnt/installer/jenkins_compiler_installer.sh
// eval "$(/opt/conda/bin/conda shell.bash hook)"
// conda activate py37
// pip install requests pyyaml
// python release.py --github --notest
// '''
// } else {
// powershell './cmake/run_release.ps1'
// }
// }
// }
// }
// }

}
}

post {
post {

success {
post_github_status("success", "The build succeeded")
Expand All @@ -190,9 +206,10 @@ pipeline {
post_github_status("failure", "The build failed")
}

cleanup {
deleteDir()
}
cleanup {
deleteDir()
}

}
}
}
}

0 comments on commit 0d587ae

Please sign in to comment.