From 8c621b9ae62015aca9e69b001fdb11fda3bcc976 Mon Sep 17 00:00:00 2001 From: Jakub Date: Thu, 25 Jul 2024 11:07:02 +0200 Subject: [PATCH] ci: bump status-jenkins-lib version, don't use a branch (#6446) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: bump status-jenkins-lib version, don't use a branch Also renamed `Jenkinsfile.nix` to `nix.Jenkinsfile` because the filename makes no sense. But left a symlink temporarily to not break things. Signed-off-by: Jakub Sokołowski * nix: fix hash for Nim compiler checksums repo Signed-off-by: Jakub Sokołowski * nix: do not create variable name conflicts Signed-off-by: Jakub Sokołowski --------- Signed-off-by: Jakub Sokołowski --- ci/Jenkinsfile | 2 +- ci/Jenkinsfile.nix | 86 +--------------------------------------------- ci/nix.Jenkinsfile | 85 +++++++++++++++++++++++++++++++++++++++++++++ nix/checksums.nix | 2 +- nix/tools.nix | 2 +- 5 files changed, 89 insertions(+), 88 deletions(-) mode change 100644 => 120000 ci/Jenkinsfile.nix create mode 100644 ci/nix.Jenkinsfile diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 097ce0be4..cc521a31d 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -6,7 +6,7 @@ * * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). * at your option. This file may not be copied, modified, or distributed except according to those terms. */ -library 'status-jenkins-lib@v1.8.14' +library 'status-jenkins-lib@v1.9.2' pipeline { /* This way we run the same Jenkinsfile on different platforms. */ diff --git a/ci/Jenkinsfile.nix b/ci/Jenkinsfile.nix deleted file mode 100644 index 44607fcca..000000000 --- a/ci/Jenkinsfile.nix +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env groovy -/* beacon_chain - * Copyright (c) 2019-2024 Status Research & Development GmbH - * Licensed and distributed under either of - * * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). - * * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). - * at your option. This file may not be copied, modified, or distributed except according to those terms. - */ -library 'status-jenkins-lib@nix/flake-build' - -pipeline { - /* This way we run the same Jenkinsfile on different platforms. */ - agent { label params.AGENT_LABEL } - - parameters { - string( - name: 'AGENT_LABEL', - description: 'Label for targetted CI slave host: linux/macos', - defaultValue: params.AGENT_LABEL ?: getAgentLabel(), - ) - choice( - name: 'VERBOSITY', - description: 'Value for the V make flag to increase log verbosity', - choices: [0, 1, 2] - ) - } - - options { - timestamps() - ansiColor('xterm') - /* This also includes wait time in the queue. */ - timeout(time: 1, unit: 'HOURS') - /* Limit builds retained. */ - buildDiscarder(logRotator( - numToKeepStr: '5', - daysToKeepStr: '30', - )) - /* Abort old builds for non-main branches. */ - disableConcurrentBuilds( - abortPrevious: !isMainBranch() - ) - } - - stages { - stage('Beacon Node') { - steps { script { - nix.flake('beacon_node') - } } - } - - stage('Version check') { - steps { script { - sh 'result/bin/nimbus_beacon_node --version' - } } - } - } - - post { - always { - cleanWs( - disableDeferredWipeout: true, - deleteDirs: true - ) - } - } -} - -def isMainBranch() { - return ['stable', 'testing', 'unstable'].contains(env.BRANCH_NAME) -} - -/* This allows us to use one Jenkinsfile and run - * jobs on different platforms based on job name. */ -def getAgentLabel() { - if (params.AGENT_LABEL) { return params.AGENT_LABEL } - /* We extract the name of the job from currentThread because - * before an agent is picket env is not available. */ - def tokens = Thread.currentThread().getName().split('/') - def labels = [] - /* Check if the job path contains any of the valid labels. */ - ['linux', 'macos', 'x86_64', 'aarch64', 'arm64'].each { - if (tokens.contains(it)) { labels.add(it) } - } - return labels.join(' && ') -} diff --git a/ci/Jenkinsfile.nix b/ci/Jenkinsfile.nix new file mode 120000 index 000000000..87764d4ee --- /dev/null +++ b/ci/Jenkinsfile.nix @@ -0,0 +1 @@ +nix.Jenkinsfile \ No newline at end of file diff --git a/ci/nix.Jenkinsfile b/ci/nix.Jenkinsfile new file mode 100644 index 000000000..1c8d904cc --- /dev/null +++ b/ci/nix.Jenkinsfile @@ -0,0 +1,85 @@ +#!/usr/bin/env groovy +/* beacon_chain + * Copyright (c) 2019-2024 Status Research & Development GmbH + * Licensed and distributed under either of + * * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). + * * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). + * at your option. This file may not be copied, modified, or distributed except according to those terms. + */ +library 'status-jenkins-lib@v1.9.2' + +pipeline { + /* This way we run the same Jenkinsfile on different platforms. */ + agent { label params.AGENT_LABEL } + + parameters { + string( + name: 'AGENT_LABEL', + description: 'Label for targetted CI slave host: linux/macos', + defaultValue: params.AGENT_LABEL ?: getAgentLabel(), + ) + choice( + name: 'VERBOSITY', + description: 'Value for the V make flag to increase log verbosity', + choices: [0, 1, 2] + ) + } + + options { + timestamps() + ansiColor('xterm') + /* This also includes wait time in the queue. */ + timeout(time: 1, unit: 'HOURS') + /* Limit builds retained. */ + buildDiscarder(logRotator( + numToKeepStr: '5', + daysToKeepStr: '30', + )) + /* Abort old builds for non-main branches. */ + disableConcurrentBuilds( + abortPrevious: !isMainBranch() + ) + } + + stages { + stage('Beacon Node') { + steps { script { + nix.flake('beacon_node') + } } + } + + stage('Version check') { + steps { script { + sh 'result/bin/nimbus_beacon_node --version' + } } + } + } + + post { + always { + cleanWs( + disableDeferredWipeout: true, + deleteDirs: true + ) + } + } +} + +def isMainBranch() { + return ['stable', 'testing', 'unstable'].contains(env.BRANCH_NAME) +} + +/* This allows us to use one Jenkinsfile and run + * jobs on different platforms based on job name. */ +def getAgentLabel() { + if (params.AGENT_LABEL) { return params.AGENT_LABEL } + /* We extract the name of the job from currentThread because + * before an agent is picket env is not available. */ + def tokens = Thread.currentThread().getName().split('/') + def labels = [] + /* Check if the job path contains any of the valid labels. */ + ['linux', 'macos', 'x86_64', 'aarch64', 'arm64'].each { + if (tokens.contains(it)) { labels.add(it) } + } + return labels.join(' && ') +} diff --git a/nix/checksums.nix b/nix/checksums.nix index c3b322e3a..2c8f2c54c 100644 --- a/nix/checksums.nix +++ b/nix/checksums.nix @@ -8,5 +8,5 @@ in pkgs.fetchFromGitHub { repo = "checksums"; rev = tools.findKeyValue "^ +ChecksumsStableCommit = \"([a-f0-9]+)\"$" sourceFile; # WARNING: Requires manual updates when Nim compiler version changes. - hash = "sha256-AIiMBqLcGJCTkINHfJ2dN3ogitU7Za9Z9Sv9zjKeOQk="; + hash = "sha256-RB2IXs2xcfYHhV9d7l1mtHW51mtsrqrYRapSoTikvHw="; } diff --git a/nix/tools.nix b/nix/tools.nix index 1a9736862..108d38606 100644 --- a/nix/tools.nix +++ b/nix/tools.nix @@ -7,7 +7,7 @@ let in { findKeyValue = regex: sourceFile: let - linesFrom = sourceFile: splitString "\n" (fileContents sourceFile); + linesFrom = file: splitString "\n" (fileContents file); matching = regex: lines: map (line: match regex line) lines; extractMatch = matches: last (flatten (remove null matches)); in