From 5b4a2ef3ace210fc92e170e9767ccf70c2cdb77b Mon Sep 17 00:00:00 2001 From: Michele Scuttari Date: Wed, 18 Sep 2024 23:14:01 +0200 Subject: [PATCH] Use separate Jenkinfiles for different configurations --- .jenkins/dev-debian-12.Jenkinsfile | 75 +++++++++++++++++++++ .jenkins/dev-fedora-40.Jenkinsfile | 75 +++++++++++++++++++++ .jenkins/dev-ubuntu-22.04.Jenkinsfile | 75 +++++++++++++++++++++ Jenkinsfile | 96 --------------------------- 4 files changed, 225 insertions(+), 96 deletions(-) create mode 100644 .jenkins/dev-debian-12.Jenkinsfile create mode 100644 .jenkins/dev-fedora-40.Jenkinsfile create mode 100644 .jenkins/dev-ubuntu-22.04.Jenkinsfile delete mode 100644 Jenkinsfile diff --git a/.jenkins/dev-debian-12.Jenkinsfile b/.jenkins/dev-debian-12.Jenkinsfile new file mode 100644 index 000000000..8db306929 --- /dev/null +++ b/.jenkins/dev-debian-12.Jenkinsfile @@ -0,0 +1,75 @@ +String configName = "debian-12" +String dockerfile = "Debian.Dockerfile" + +publishChecks(name: configName, status: 'QUEUED', summary: 'Queued') + +node { + agent 'x86_64-ubuntu-22.04' + + String localWorkspace = "${WORKSPACE}/" + configName + + String srcPath = localWorkspace + "/src" + String buildPath = localWorkspace + "/build" + String installPath = localWorkspace + "/install" + + String marcoSrcPath = srcPath + "/marco" + String marcoBuildPath = buildPath + "/marco" + String marcoInstallPath = installPath + "/marco" + + stage("Checkout") { + dir(marcoSrcPath) { + def scmVars = checkout(scm) + env.GIT_COMMIT = scmVars.GIT_COMMIT + } + } + + String dockerMARCOImageName = 'marco-compiler/marco-' + "dev-" + configName + + String dockerArgs = + " --build-arg VERSION=12" + + " --build-arg LLVM_BUILD_TYPE=Release" + + " --build-arg LLVM_PARALLEL_COMPILE_JOBS=${LLVM_PARALLEL_COMPILE_JOBS}" + + " --build-arg LLVM_PARALLEL_LINK_JOBS=${LLVM_PARALLEL_LINK_JOBS}" + + " -f " + marcoSrcPath + "/.jenkins/" + dockerfile + + " " + marcoSrcPath + "/.jenkins"; + + publishChecks(name: configName, status: 'IN_PROGRESS', summary: 'In progress') + + def dockerImage + + stage("Docker image") { + dockerImage = docker.build( + dockerMARCOImageName + ':' + env.GIT_COMMIT, + "--build-arg MARCO_RUNTIME_BUILD_TYPE=Debug --build-arg LLVM_ENABLE_ASSERTIONS=ON " + dockerArgs) + } + + dockerImage.inside() { + withChecks(name: configName) { + stage("OS information") { + sh "cat /etc/os-release" + } + + stage('Configure') { + cmake arguments: "-S " + marcoSrcPath + " -B " + marcoBuildPath + " -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=" + marcoInstallPath + " -DLLVM_EXTERNAL_LIT=/virtualenv/bin/lit", installation: 'InSearchPath', label: 'Configure' + } + + stage('Build') { + cmake arguments: "--build " + marcoBuildPath, installation: 'InSearchPath', label: 'Build' + } + + stage('Unit test') { + cmake arguments: "--build " + marcoBuildPath + " --target test", installation: 'InSearchPath', label: 'Unit tests' + } + + stage('Regression test') { + cmake arguments: "--build " + marcoBuildPath + " --target check", installation: 'InSearchPath', label: 'Regression tests' + } + + stage('Install') { + cmake arguments: "--build " + marcoBuildPath + " --target install", installation: 'InSearchPath', label: 'Install' + } + } + } + + publishChecks(name: configName, conclusion: 'SUCCESS', summary: 'Completed') +} \ No newline at end of file diff --git a/.jenkins/dev-fedora-40.Jenkinsfile b/.jenkins/dev-fedora-40.Jenkinsfile new file mode 100644 index 000000000..1c4572463 --- /dev/null +++ b/.jenkins/dev-fedora-40.Jenkinsfile @@ -0,0 +1,75 @@ +String configName = "fedora-40" +String dockerfile = "Fedora.Dockerfile" + +publishChecks(name: configName, status: 'QUEUED', summary: 'Queued') + +node { + agent 'x86_64-ubuntu-22.04' + + String localWorkspace = "${WORKSPACE}/" + configName + + String srcPath = localWorkspace + "/src" + String buildPath = localWorkspace + "/build" + String installPath = localWorkspace + "/install" + + String marcoSrcPath = srcPath + "/marco" + String marcoBuildPath = buildPath + "/marco" + String marcoInstallPath = installPath + "/marco" + + stage("Checkout") { + dir(marcoSrcPath) { + def scmVars = checkout(scm) + env.GIT_COMMIT = scmVars.GIT_COMMIT + } + } + + String dockerMARCOImageName = 'marco-compiler/marco-' + "dev-" + configName + + String dockerArgs = + " --build-arg VERSION=40" + + " --build-arg LLVM_BUILD_TYPE=Release" + + " --build-arg LLVM_PARALLEL_COMPILE_JOBS=${LLVM_PARALLEL_COMPILE_JOBS}" + + " --build-arg LLVM_PARALLEL_LINK_JOBS=${LLVM_PARALLEL_LINK_JOBS}" + + " -f " + marcoSrcPath + "/.jenkins/" + dockerfile + + " " + marcoSrcPath + "/.jenkins"; + + publishChecks(name: configName, status: 'IN_PROGRESS', summary: 'In progress') + + def dockerImage + + stage("Docker image") { + dockerImage = docker.build( + dockerMARCOImageName + ':' + env.GIT_COMMIT, + "--build-arg MARCO_RUNTIME_BUILD_TYPE=Debug --build-arg LLVM_ENABLE_ASSERTIONS=ON " + dockerArgs) + } + + dockerImage.inside() { + withChecks(name: configName) { + stage("OS information") { + sh "cat /etc/os-release" + } + + stage('Configure') { + cmake arguments: "-S " + marcoSrcPath + " -B " + marcoBuildPath + " -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=" + marcoInstallPath + " -DLLVM_EXTERNAL_LIT=/virtualenv/bin/lit", installation: 'InSearchPath', label: 'Configure' + } + + stage('Build') { + cmake arguments: "--build " + marcoBuildPath, installation: 'InSearchPath', label: 'Build' + } + + stage('Unit test') { + cmake arguments: "--build " + marcoBuildPath + " --target test", installation: 'InSearchPath', label: 'Unit tests' + } + + stage('Regression test') { + cmake arguments: "--build " + marcoBuildPath + " --target check", installation: 'InSearchPath', label: 'Regression tests' + } + + stage('Install') { + cmake arguments: "--build " + marcoBuildPath + " --target install", installation: 'InSearchPath', label: 'Install' + } + } + } + + publishChecks(name: configName, conclusion: 'SUCCESS', summary: 'Completed') +} \ No newline at end of file diff --git a/.jenkins/dev-ubuntu-22.04.Jenkinsfile b/.jenkins/dev-ubuntu-22.04.Jenkinsfile new file mode 100644 index 000000000..646753ff5 --- /dev/null +++ b/.jenkins/dev-ubuntu-22.04.Jenkinsfile @@ -0,0 +1,75 @@ +String configName = "ubuntu-22.04" +String dockerfile = "Ubuntu.Dockerfile" + +publishChecks(name: configName, status: 'QUEUED', summary: 'Queued') + +node { + agent 'x86_64-ubuntu-22.04' + + String localWorkspace = "${WORKSPACE}/" + configName + + String srcPath = localWorkspace + "/src" + String buildPath = localWorkspace + "/build" + String installPath = localWorkspace + "/install" + + String marcoSrcPath = srcPath + "/marco" + String marcoBuildPath = buildPath + "/marco" + String marcoInstallPath = installPath + "/marco" + + stage("Checkout") { + dir(marcoSrcPath) { + def scmVars = checkout(scm) + env.GIT_COMMIT = scmVars.GIT_COMMIT + } + } + + String dockerMARCOImageName = 'marco-compiler/marco-' + "dev-" + configName + + String dockerArgs = + " --build-arg VERSION=22.04" + + " --build-arg LLVM_BUILD_TYPE=Release" + + " --build-arg LLVM_PARALLEL_COMPILE_JOBS=${LLVM_PARALLEL_COMPILE_JOBS}" + + " --build-arg LLVM_PARALLEL_LINK_JOBS=${LLVM_PARALLEL_LINK_JOBS}" + + " -f " + marcoSrcPath + "/.jenkins/" + dockerfile + + " " + marcoSrcPath + "/.jenkins"; + + publishChecks(name: configName, status: 'IN_PROGRESS', summary: 'In progress') + + def dockerImage + + stage("Docker image") { + dockerImage = docker.build( + dockerMARCOImageName + ':' + env.GIT_COMMIT, + "--build-arg MARCO_RUNTIME_BUILD_TYPE=Debug --build-arg LLVM_ENABLE_ASSERTIONS=ON " + dockerArgs) + } + + dockerImage.inside() { + withChecks(name: configName) { + stage("OS information") { + sh "cat /etc/os-release" + } + + stage('Configure') { + cmake arguments: "-S " + marcoSrcPath + " -B " + marcoBuildPath + " -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=" + marcoInstallPath + " -DLLVM_EXTERNAL_LIT=/virtualenv/bin/lit", installation: 'InSearchPath', label: 'Configure' + } + + stage('Build') { + cmake arguments: "--build " + marcoBuildPath, installation: 'InSearchPath', label: 'Build' + } + + stage('Unit test') { + cmake arguments: "--build " + marcoBuildPath + " --target test", installation: 'InSearchPath', label: 'Unit tests' + } + + stage('Regression test') { + cmake arguments: "--build " + marcoBuildPath + " --target check", installation: 'InSearchPath', label: 'Regression tests' + } + + stage('Install') { + cmake arguments: "--build " + marcoBuildPath + " --target install", installation: 'InSearchPath', label: 'Install' + } + } + } + + publishChecks(name: configName, conclusion: 'SUCCESS', summary: 'Completed') +} \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 952a2e83a..000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,96 +0,0 @@ -def configs = [ - ['name': 'debian-12', 'dockerfile': 'Debian.Dockerfile', 'args': '--build-arg VERSION=12'], - ['name': 'ubuntu-22.04', 'dockerfile': 'Ubuntu.Dockerfile', 'args': '--build-arg VERSION=22.04'], - ['name': 'fedora-40', 'dockerfile': 'Fedora.Dockerfile', 'args': '--build-arg VERSION=40'] -] - -Map tasks = [failFast: false] - -for (config in configs) { - String configName = "${config.name}" - String dockerImage = "${config.image}" - String dockerfile = "${config.dockerfile}" - String configArgs = "${config.args}" - - List configEnv = [] - - publishChecks(name: configName, status: 'QUEUED', summary: 'Queued') - - tasks[configName] = { -> - node { - String localWorkspace = "${WORKSPACE}/" + configName - - String srcPath = localWorkspace + "/src" - String buildPath = localWorkspace + "/build" - - String marcoSrcPath = srcPath + "/marco" - String marcoBuildPath = buildPath + "/marco" - - stage("Checkout") { - dir(marcoSrcPath) { - checkout(scm) - } - } - - String dockerMARCOImageName = 'marco-compiler/marco-' + configName - - String dockerArgs = configArgs + " --no-cache" + - " --build-arg LLVM_BUILD_TYPE=Release" + - " --build-arg LLVM_PARALLEL_COMPILE_JOBS=${LLVM_PARALLEL_COMPILE_JOBS}" + - " --build-arg LLVM_PARALLEL_LINK_JOBS=${LLVM_PARALLEL_LINK_JOBS}" + - " -f " + marcoSrcPath + "/.jenkins/" + dockerfile + - " " + marcoSrcPath + "/.jenkins"; - - withEnv(configEnv) { - publishChecks(name: configName, status: 'IN_PROGRESS', summary: 'In progress') - - docker.withRegistry('https://ghcr.io', 'marco-ci') { - def devImage - - stage("Development image") { - devImage = docker.build( - dockerMARCOImageName + '-dev:latest', - "--build-arg MARCO_RUNTIME_BUILD_TYPE=Debug --build-arg LLVM_ENABLE_ASSERTIONS=ON " + dockerArgs) - - if (BRANCH_NAME == 'master') { - devImage.push() - } - } - - devImage.inside() { - withChecks(name: configName) { - stage("OS information") { - sh "cat /etc/os-release" - } - - stage('Clean') { - dir(marcoBuildPath) { - deleteDir() - } - } - - stage('Configure') { - cmake arguments: "-S " + marcoSrcPath + " -B " + marcoBuildPath + " -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLLVM_EXTERNAL_LIT=/virtualenv/bin/lit", installation: 'InSearchPath', label: 'Configure' - } - - stage('Build') { - cmake arguments: "--build " + marcoBuildPath, installation: 'InSearchPath', label: 'Build' - } - - stage('Test') { - cmake arguments: "--build " + marcoBuildPath + " --target test", installation: 'InSearchPath', label: 'Unit tests' - cmake arguments: "--build " + marcoBuildPath + " --target check", installation: 'InSearchPath', label: 'Regression tests' - } - } - } - - publishChecks(name: configName, conclusion: 'SUCCESS', summary: 'Completed') - } - } - } - } -} - -stage("Parallel") { - parallel(tasks) -}