Skip to content

Commit

Permalink
ci: use pyproject.toml for project metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
henryborchers committed Nov 1, 2024
1 parent 168476e commit 81886bc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 102 deletions.
103 changes: 37 additions & 66 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ def mac_wheels(){
)
def fusedWheel = findFiles(excludes: '', glob: 'out/*.whl')[0]
def pythonVersionShort = pythonVersion.replace('.','')
def universalWheel = "uiucprescon.ocr-${props.Version}-cp${pythonVersionShort}-cp${pythonVersionShort}-macosx_11_0_universal2.whl"
def props = readTOML( file: 'pyproject.toml')['project']
def universalWheel = "uiucprescon.ocr-${props.version}-cp${pythonVersionShort}-cp${pythonVersionShort}-macosx_11_0_universal2.whl"
sh "mv ${fusedWheel.path} ./dist/${universalWheel}"
stash includes: 'dist/*.whl', name: "python${pythonVersion} mac-universal2 wheel"
wheelStashes << "python${pythonVersion} mac-universal2 wheel"
Expand Down Expand Up @@ -623,32 +624,17 @@ def mac_wheels(){
}
parallel(wheelStages)
}
def get_sonarqube_unresolved_issues(report_task_file){
script{

def get_props(){
stage('Reading Package Metadata'){
node() {
try{
unstash 'DIST-INFO'
def metadataFile = findFiles(excludes: '', glob: '*.dist-info/METADATA')[0]
def package_metadata = readProperties interpolate: true, file: metadataFile.path
echo """Metadata:
Name ${package_metadata.Name}
Version ${package_metadata.Version}
"""
return package_metadata
} finally {
cleanWs(
patterns: [
[pattern: '*.dist-info/**', type: 'INCLUDE'],
],
notFailBuild: true,
deleteDirs: true
)
}
}
def props = readProperties file: '.scannerwork/report-task.txt'
def response = httpRequest url : props['serverUrl'] + "/api/issues/search?componentKeys=" + props['projectKey'] + "&resolved=no"
def outstandingIssues = readJSON text: response.content
return outstandingIssues
}
}


def startup(){
def SONARQUBE_CREDENTIAL_ID = SONARQUBE_CREDENTIAL_ID
parallel(
Expand All @@ -669,47 +655,11 @@ def startup(){
}
}
},
'Getting Distribution Info': {
stage('Getting Distribution Info'){
node('linux && docker') {
timeout(2){
ws{
checkout scm
try{
docker.image('python').inside {
withEnv(['PIP_NO_CACHE_DIR=off']) {
sh(
label: 'Running setup.py with dist_info',
script: '''python --version
python setup.py dist_info
'''
)
}
stash includes: '*.dist-info/**', name: 'DIST-INFO'
archiveArtifacts artifacts: '*.dist-info/**'
}
} finally{
cleanWs(
patterns: [
[pattern: '*.dist-info/**', type: 'INCLUDE'],
[pattern: '.eggs/', type: 'INCLUDE'],
[pattern: '**/__pycache__/', type: 'INCLUDE'],
],
notFailBuild: true,
deleteDirs: true
)
}
}
}
}
}
}
]
)
}
stage('Pipeline Pre-tasks'){
startup()
props = get_props()
}
pipeline {
agent none
Expand Down Expand Up @@ -783,7 +733,11 @@ pipeline {
}
success{
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'build/docs/html', reportFiles: 'index.html', reportName: 'Documentation', reportTitles: ''])
zip archive: true, dir: 'build/docs/html', glob: '', zipFile: "dist/${props.Name}-${props.Version}.doc.zip"
script{
def props = readTOML( file: 'pyproject.toml')['project']
zip archive: true, dir: 'build/docs/html', glob: '', zipFile: "dist/${props.name}-${props.version}.doc.zip"
}

stash includes: 'dist/*.doc.zip,build/docs/html/**', name: 'DOCS_ARCHIVE'
}
}
Expand Down Expand Up @@ -1000,11 +954,28 @@ pipeline {
}
steps{
script{
load('ci/jenkins/scripts/sonarqube.groovy').sonarcloudSubmit(
props,
'reports/sonar-report.json',
SONARQUBE_CREDENTIAL_ID
)
def props = readTOML( file: 'pyproject.toml')['project']
withSonarQubeEnv(installationName:'sonarcloud', credentialsId: SONARQUBE_CREDENTIAL_ID) {
if (env.CHANGE_ID){
sh(
label: 'Running Sonar Scanner',
script: "sonar-scanner -Dsonar.projectVersion=${props.version} -Dsonar.buildString=\"${env.BUILD_TAG}\" -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.cfamily.cache.enabled=false -Dsonar.cfamily.threads=\$(grep -c ^processor /proc/cpuinfo) -Dsonar.cfamily.build-wrapper-output=build/build_wrapper_output_directory"
)
} else {
sh(
label: 'Running Sonar Scanner',
script: "sonar-scanner -Dsonar.projectVersion=${props.version} -Dsonar.buildString=\"${env.BUILD_TAG}\" -Dsonar.branch.name=${env.BRANCH_NAME} -Dsonar.cfamily.cache.enabled=false -Dsonar.cfamily.threads=\$(grep -c ^processor /proc/cpuinfo) -Dsonar.cfamily.build-wrapper-output=build/build_wrapper_output_directory"
)
}
}
timeout(time: 1, unit: 'HOURS') {
def sonarqube_result = waitForQualityGate(abortPipeline: false)
if (sonarqube_result.status != 'OK') {
unstable "SonarQube quality gate: ${sonarqube_result.status}"
}
def outstandingIssues = get_sonarqube_unresolved_issues('.scannerwork/report-task.txt')
writeJSON file: 'reports/sonar-report.json', json: outstandingIssues
}
}
}
post {
Expand Down
36 changes: 0 additions & 36 deletions ci/jenkins/scripts/sonarqube.groovy

This file was deleted.

0 comments on commit 81886bc

Please sign in to comment.