From ba1920846904fe9ea927afb249aa2af349917db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alan=20Dragomirecky=CC=81?= Date: Fri, 9 Jul 2021 23:50:00 +0200 Subject: [PATCH] Add Dockerfile/Jenkinsfile for Holly --- utils/holly/Dockerfile | 9 ++++ utils/holly/Jenkinsfile | 116 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 utils/holly/Dockerfile create mode 100644 utils/holly/Jenkinsfile diff --git a/utils/holly/Dockerfile b/utils/holly/Dockerfile new file mode 100644 index 0000000..c44582c --- /dev/null +++ b/utils/holly/Dockerfile @@ -0,0 +1,9 @@ +FROM gcc:11.1 +RUN apt-get clean && \ + apt-get update -qq -y && \ + apt-get install curl python3 python3-pip libncurses5 -y +RUN pip3 install pre-commit ecdsa +WORKDIR /work +ADD utils/bootstrap.py bootstrap.py +RUN gcc --version +RUN python3 bootstrap.py diff --git a/utils/holly/Jenkinsfile b/utils/holly/Jenkinsfile new file mode 100644 index 0000000..cc2d03d --- /dev/null +++ b/utils/holly/Jenkinsfile @@ -0,0 +1,116 @@ +pipeline { + agent { + dockerfile { + label 'docker' + filename 'utils/holly/Dockerfile' + additionalBuildArgs '-t prusa-firmware-mmu' + } + } + + parameters { + string(name: 'VERSION_SUFFIX', defaultValue: '', description: 'Specify custom version suffix for the build (e.g. "-RC1+1010"). Set to "" to use the default one. Leave empty to make a final-version build without any suffix.') + string(name: 'VERSION_SUFFIX_SHORT', defaultValue: '', description: 'Specify custom version suffix for the build (e.g. "-RC1"). Set to "" to use the default one. Leave empty to make a final-version build without any suffix.') + } + + stages { + stage('Prepare Build Stages') { + steps { + script { + // required configurations + def configurations = [ + [build_type: "release"], + ] + + // prepare version suffix + def commit_nr = sh(script: 'git rev-list HEAD --count', returnStdout: true).trim() + def short_suffix + def full_suffix + if (env.CHANGE_ID) { + // This is a PR build + short_suffix = "-BETA+${commit_nr}" + full_suffix = "${short_suffix}.PR${env.CHANGE_ID}.B${env.BUILD_NUMBER}" + } else if (env.BRANCH_NAME.startsWith("RELEASE-")) { + // This is an RC build + short_suffix = "-RC+${commit_nr}" + full_suffix = "${short_suffix}.B${env.BUILD_NUMBER}" + } else { + // This is build of an ordinary branch (not a release branch) + short_suffix = "-BETA+${commit_nr}" + def branch_spec = env.BRANCH_NAME.replaceAll("_", "-") + full_suffix = "${short_suffix}.BRANCH-${branch_spec}.B${env.BUILD_NUMBER}" + } + + if (params.VERSION_SUFFIX != '') { + full_suffix = params.VERSION_SUFFIX + } + if (params.VERSION_SUFFIX_SHORT != '') { + short_suffix = params.VERSION_SUFFIX_SHORT + } + + // create the build stages + configurations.each { config -> + stage("Build - ${config.build_type}") { + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + sh """ + ln -fs /.dependencies + python3 utils/build.py \ + --build-type ${config.build_type} \ + --generate-bbf \ + --generate-dfu \ + --no-store-output \ + --version-suffix=${full_suffix} \ + --version-suffix-short=${short_suffix} \ + -DCUSTOM_COMPILE_OPTIONS:STRING=-Werror + """ + } + } + } + } + } + } + + stage('Check Formatting') { + when { + expression { env.CHANGE_TARGET } + } + steps { + sh """ + export XDG_CACHE_HOME=\$PWD/.precommit + pre-commit install + pre-commit run \ + --source remotes/origin/${env.CHANGE_TARGET} \ + --origin HEAD \ + --show-diff-on-failure \ + --hook-stage manual + """ + } + } + + stage('Test') { + steps { + sh """ + python3 utils/bootstrap.py + export PATH=\$PWD/.dependencies/cmake-3.15.5/bin:\$PWD/.dependencies/ninja-1.9.0:\$PATH + mkdir -p build-test + LD_LIBRARY_PATH=/usr/local/lib32 \$PWD/.dependencies/cmake-3.15.5/bin/ctest --build-and-test . build-test \ + -DCMAKE_MAKE_PROGRAM=\$PWD/.dependencies/ninja-1.9.0/ninja \ + --build-generator Ninja \ + --build-target tests \ + --test-command ctest + """ + } + } + } + + post { + always { + // archive build products + archiveArtifacts artifacts: 'build/products/*', fingerprint: true + // archive test products + archiveArtifacts artifacts: 'build-test/Testing/Temporary/LastTest.log' + } + cleanup { + deleteDir() + } + } +}