diff --git a/Jenkinsfile b/Jenkinsfile index 8921bb666..e1ffe3292 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,185 +1,179 @@ pipeline { parameters {string(defaultValue: '', description: 'api-token', name: 'API_TOKEN') string(defaultValue: '', description: 'buildable phid', name: 'BUILD_TARGET_PHID') string(defaultValue: '', description: 'Commit id', name: 'COMMIT_ID') string(defaultValue: '', description: 'Diff id', name: 'DIFF_ID') } options { disableConcurrentBuilds() } environment { PHABRICATOR_HOST = 'https://c4science.ch/api/' PYTHONPATH = sh returnStdout: true, script: 'echo ${WORKSPACE}/test/ci/script/' BLA_VENDOR = 'OpenBLAS' OMPI_MCA_plm = 'isolated' OMPI_MCA_btl = 'tcp,self' } agent { dockerfile { filename 'Dockerfile' dir 'test/ci' additionalBuildArgs '--tag akantu-environment' } } - stages { + stages { stage('Lint') { steps { sh """ - arc lint --output json --rev ${GIT_PREVIOUS_COMMIT}^1 | jq . -srM | tee lint.json + arc lint --output json --rev ${COMMIT_ID} | jq . -srM | tee lint.json ./test/ci/scripts/hbm send-arc-lint -f lint.json """ } } stage('Configure') { steps { sh """#!/bin/bash set -o pipefail mkdir -p build cd build cmake -DAKANTU_COHESIVE_ELEMENT:BOOL=TRUE \ -DAKANTU_IMPLICIT:BOOL=TRUE \ -DAKANTU_PARALLEL:BOOL=TRUE \ -DAKANTU_PYTHON_INTERFACE:BOOL=TRUE \ -DAKANTU_TESTS:BOOL=TRUE .. | tee configure.txt """ } post { failure { uploadArtifact('configure.txt', 'Configure') deleteDir() } } } stage('Compile') { steps { sh '''#!/bin/bash set -o pipefail make -C build/src | tee compilation.txt ''' } post { failure { uploadArtifact('compilation.txt', 'Compilation') } } } stage ('Warnings gcc') { steps { warnings(consoleParsers: [[parserName: 'GNU Make + GNU C Compiler (gcc)']]) } } stage('Compile python') { steps { sh '''#!/bin/bash set -o pipefail + make -C build/python | tee compilation_python.txt ''' } post { failure { uploadArtifact('compilation_python.txt', 'Compilation_Python') } } } stage('Compile tests') { steps { sh '''#!/bin/bash set -o pipefail + make -C build/test | tee compilation_test.txt ''' } post { failure { uploadArtifact('compilation_test.txt', 'Compilation_Tests') } } } stage('Tests') { steps { sh ''' #rm -rf build/gtest_reports cd build/ #source ./akantu_environement.sh ctest -T test --no-compress-output || true + tag=$(head -n 1 < Testing/TAG) + if [ -e Testing/${tag}/Test.xml ]; then + cp Testing/${tag}/Test.xml ../CTestResults.xml + fi ''' } - post { - always { - script { - def TAG = sh returnStdout: true, script: 'head -n 1 < build/Testing/TAG' - def TAG_ = TAG.trim() - - if (fileExists("build/Testing/${TAG}/Test.xml")) { - sh "cp build/Testing/${TAG}/Test.xml CTestResults.xml" - } - } - } - } } } post { always { createArtifact("./CTestResults.xml") step([$class: 'XUnitBuilder', thresholds: [ [$class: 'SkippedThreshold', failureThreshold: '0'], [$class: 'FailedThreshold', failureThreshold: '0']], tools: [ [$class: 'CTestType', pattern: 'CTestResults.xml', skipNoTestFiles: true] ]]) // step([$class: 'XUnitBuilder', // thresholds: [ // [$class: 'SkippedThreshold', failureThreshold: '100'], // [$class: 'FailedThreshold', failureThreshold: '0']], // tools: [ // [$class: 'GoogleTestType', pattern: 'build/gtest_reports/**', skipNoTestFiles: true] // ]]) } success { passed() } failure { // emailext( // body: '''${SCRIPT, template="groovy-html.template"}''', // mimeType: 'text/html', // subject: "[Jenkins] ${currentBuild.fullDisplayName} Failed", // recipientProviders: [[$class: 'CulpritsRecipientProvider']], // to: 'akantu-admins@akantu.ch', // replyTo: 'akantu-admins@akantu.ch', // attachLog: true, // compressLog: false) failed() } } } def failed() { sh "./test/ci/scripts/hbm failed" } def passed() { sh "./test/ci/scripts/hbm passed" } def createArtifact(artifact) { sh "./test/ci/scripts/hbm send-uri -k 'Jenkins URI' -u ${BUILD_URL} -l 'View Jenkins result'" sh "./test/ci/scripts/hbm send-ctest-results -f ${artifact}" } def uploadArtifact(artifact, name) { sh "./test/ci/scripts/hbm upload-file -f ${artifact} -n \"${name}\" -v PHID-PROJ-5eqyu6ooyjktagbhf473" } diff --git a/test/ci/scripts/hbm b/test/ci/scripts/hbm index 494b55969..0ebd246a7 100755 --- a/test/ci/scripts/hbm +++ b/test/ci/scripts/hbm @@ -1,69 +1,69 @@ #!/usr/bin/env python3 import click import harbomaster @click.group() @click.option('-a', '--api-token', default=None, envvar='API_TOKEN') @click.option('-h', '--host', default=None, envvar='PHABRICATOR_HOST') @click.option('-b', '--build-target-phid', envvar='BUILD_TARGET_PHID') @click.pass_context def hbm(ctx, api_token, host, build_target_phid): ctx.obj['API_TOKEN'] = api_token ctx.obj['HOST'] = host ctx.obj['BUILD_TARGET_PHID'] = build_target_phid @hbm.command() @click.option('-f', '--filename') @click.pass_context def send_ctest_results(ctx, filename): try: _hbm = harbomaster.Harbormaster(ctx=ctx.obj) with harbomaster.CTestResults(filename) as tests: _hbm.send_unit_tests(tests) - except e: + except: pass @hbm.command() @click.option('-f', '--filename') @click.pass_context def send_arc_lint(ctx, filename): try: _hbm = harbomaster.Harbormaster(ctx=ctx.obj) with harbomaster.ARCLintJson(filename) as tests: _hbm.send_lint(tests) - except e: + except: pass @hbm.command() @click.option('-k', '--key') @click.option('-u', '--uri') @click.option('-l', '--label') @click.pass_context def send_uri(ctx, key, uri, label): _hbm = harbomaster.Harbormaster(ctx=ctx.obj) _hbm.send_uri(key, uri, label) @hbm.command() @click.option('-f', '--filename') @click.option('-n', '--name') @click.option('-v', '--view_policy', default=None) @click.pass_context def upload_file(ctx, filename, name, view_policy): _hbm = harbomaster.Harbormaster(ctx=ctx.obj) _hbm.upload_file(filename, name, view_policy) @hbm.command() @click.pass_context def passed(ctx): _hbm = harbomaster.Harbormaster(ctx=ctx.obj) _hbm.passed() @hbm.command() @click.pass_context def failed(ctx): _hbm = harbomaster.Harbormaster(ctx=ctx.obj) _hbm.failed() if __name__ == '__main__': hbm(obj={})