From d860d825c106dca13624b0e7e383f2a81a6f4ec6 Mon Sep 17 00:00:00 2001 From: Jakub Date: Wed, 16 Aug 2023 14:04:57 +0200 Subject: [PATCH] ci: add RACE parameter to fix conditional (#648) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We are checking if `JOB_NAME` contains a token `race` to set the default value for `RACE` parameter which decides which tests run. Signed-off-by: Jakub SokoĊ‚owski --- ci/Jenkinsfile.tests | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ci/Jenkinsfile.tests b/ci/Jenkinsfile.tests index 1e528f5c..29e9b35e 100644 --- a/ci/Jenkinsfile.tests +++ b/ci/Jenkinsfile.tests @@ -18,6 +18,16 @@ pipeline { )) } + /* WARNING: Defining parameters here with the ?: trick causes them to remember last value. */ + parameters { + booleanParam( + name: 'RACE', + description: 'Run tests with check for race condition.', + defaultValue: getRaceDefault() + ) + } + + environment { TARGET = 'tests' REPO = "${env.WORKSPACE}/src/github.com/waku-org/go-waku" @@ -40,7 +50,7 @@ pipeline { stage('Test') { steps { script { dir(env.REPO) { - if (env.JOB_BASE_NAME == "race") { + if (params.RACE) { nix.develop('make test-with-race', pure: false) }else { nix.develop('make test-ci', pure: false) @@ -64,7 +74,7 @@ pipeline { GANACHE_NETWORK_RPC_URL = "ws://localhost:${env.GANACHE_RPC_PORT}" } steps { script { dir(env.REPO) { - if (env.JOB_BASE_NAME == "race") { + if (params.RACE) { nix.develop('make test-onchain-with-race', pure: false) }else { nix.develop('make test-onchain', pure: false) @@ -86,3 +96,7 @@ pipeline { } } } } + +def Boolean getRaceDefault() { + return env.JOB_NAME.split('/').contains('race') +}