diff --git a/.arcconfig b/.arcconfig new file mode 100644 index 0000000..500a450 --- /dev/null +++ b/.arcconfig @@ -0,0 +1,6 @@ +{ + "repository.callsign" : "TAMAAS", + "phabricator.uri" : "https://c4science.ch/", + "history.immutable" : true, + "projects": "tamaas" +} diff --git a/.gitmodules b/.gitmodules index 20f15f0..d0c20f3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,12 @@ [submodule "third-party/pybind11"] path = third-party/pybind11 url = https://github.com/pybind/pybind11.git [submodule "third-party/googletest"] path = third-party/googletest url = https://github.com/google/googletest.git [submodule "third-party/expolit"] path = third-party/expolit url = ssh://git@c4science.ch/source/expolit.git +[submodule "tests/ci/scripts"] + path = tests/ci/scripts + url = ssh://git@c4science.ch/diffusion/HBMJCI/hbm-jenkins-ci.git diff --git a/Jenkinsfile b/Jenkinsfile index 84f1558..b0b18d6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,55 +1,109 @@ pipeline { - agent { - dockerfile { additionalBuildArgs '--tag tamaas-environment'} + 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') + string(defaultValue: 'PHID-PROJ-gbo56hpf2y5bi7t5jusk', description: 'ID of the project', name: 'PROJECT_ID') } - triggers { - pollSCM('H/15 * * * *') + environment { + PHABRICATOR_HOST = 'https://c4science.ch/api/' + PYTHONPATH = sh returnStdout: true, script: 'echo ${WORKSPACE}/tests/ci/script/' + } + + agent { + dockerfile { additionalBuildArgs '--tag tamaas-environment'} } stages { + stage('SCM Checkout') { + steps { + checkout scm: [$class: 'GitSCM', + branches: [[name: '${COMMIT_ID}']], + extensions: [ + [$class: 'SubmoduleOption', + disableSubmodules: false, + parentCredentials: true, + recursiveSubmodules: true, + trackingSubmodules: true] + ] + ], changelog: true + } + } + stage('Configure') { steps { - sh 'echo "py_exec = \'python3\'" > build-setup.conf' - sh 'echo "build_python = \'true\'" >> build-setup.conf' - sh 'echo "build_tests = \'true\'" >> build-setup.conf' - sh 'echo "use_googletest = \'true\'" >> build-setup.conf' + sh '''#!/usr/bin/env bash + echo "py_exec = \'python3\'" > build-setup.conf + echo "build_python = \'true\'" >> build-setup.conf + echo "build_tests = \'true\'" >> build-setup.conf + echo "use_googletest = \'true\'" >> build-setup.conf + ''' } } stage('Compile') { steps { sh 'rm -rf .sconf_temp' - sh 'scons' + sh 'scons | tee compilation.txt' + } + + post { + failure { + uploadArtifact('compilation.txt', 'Compilation') + } } } stage('Run tests') { steps { sh 'PYTHONPATH=build-release/python/ python3 -m pytest --junitxml=results.xml build-release' } } } post { always { + createArtifact("results.xml") junit 'results.xml' step([$class: 'XUnitBuilder', thresholds: [ [$class: 'SkippedThreshold', failureThreshold: '0'], [$class: 'FailedThreshold', failureThreshold: '0']], tools: [[$class: 'GoogleTestType', pattern: 'build-release/tests/gtest_results.xml']]]) } + success { + passed_hbm() + } + failure { + failed_hbm() emailext( body: '''${SCRIPT, template="groovy-html.template"}''', mimeType: 'text/html', subject: "[Jenkins] ${currentBuild.fullDisplayName} Failed", recipientProviders: [[$class: 'CulpritsRecipientProvider']], to: 'lucas.frerot@epfl.ch', attachLog: true, compressLog: true) } } } + +def createArtifact(filename) { + sh "./tests/ci/scripts/hbm send-uri -k 'Jenkins URI' -u ${BUILD_URL} -l 'View Jenkins result'" + sh "./tests/ci/scripts/hbm send-junit-results -f ${filename}" +} + +def uploadArtifact(artifact, name) { + sh "./test/ci/scripts/hbm upload-file -f ${artifact} -n \"${name}\" -v ${PROJECT_ID}" +} + +def failed_hbm() { + sh "./tests/ci/scripts/hbm failed" +} + +def passed_hbm() { + sh "./tests/ci/scripts/hbm passed" +} \ No newline at end of file diff --git a/tests/ci/scripts b/tests/ci/scripts new file mode 160000 index 0000000..e20109b --- /dev/null +++ b/tests/ci/scripts @@ -0,0 +1 @@ +Subproject commit e20109b241d517abe8e2869216562914ee05aaf3