From 902fa4f2ae8650053c7ef4f8465774aa716a3840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Wed, 13 Nov 2024 17:36:49 +0100 Subject: [PATCH 1/4] Simplify unexecuted test check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- vars/common.groovy | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vars/common.groovy b/vars/common.groovy index 186b1362c..ab37cee34 100644 --- a/vars/common.groovy +++ b/vars/common.groovy @@ -333,8 +333,9 @@ BranchInfo get_branch_information(String branch) { } def check_every_all_sh_component_will_be_run(BranchInfo info) { - def untested_all_sh_components = info.all_all_sh_components.collectMany( - {name, platform -> platform ? [] : [name]}) + def untested_all_sh_components = info.all_all_sh_components.findResults { + name, platform -> platform ? null : name + } if (untested_all_sh_components != []) { error( "Pre-test checks failed: Unable to run all.sh components: \ From da9a183baa42c6fb7cdde94a9e79b06e325f3c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Wed, 13 Nov 2024 20:09:50 +0100 Subject: [PATCH 2/4] Store BranchInfos in Lists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prepares us for the refactor in the next commit. Signed-off-by: Bence Szépkúti --- vars/mbedtls.groovy | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/vars/mbedtls.groovy b/vars/mbedtls.groovy index 0145e8597..e851b913c 100644 --- a/vars/mbedtls.groovy +++ b/vars/mbedtls.groovy @@ -100,7 +100,7 @@ void run_pr_job(String target_repo, boolean is_production, List branches } } - Map infos + List infos try { common.maybe_notify_github('PENDING', 'In progress') @@ -128,7 +128,7 @@ void run_pr_job(String target_repo, boolean is_production, List branches } } pre_test_checks.failFast = false - infos = parallel(pre_test_checks) + infos = parallel(pre_test_checks).values() } } catch (err) { def description = 'Pre-test checks failed.' @@ -141,11 +141,11 @@ void run_pr_job(String target_repo, boolean is_production, List branches try { stage('tls-testing') { - run_tls_tests(infos.values()) + run_tls_tests(infos) } } finally { stage('result-analysis') { - analysis.analyze_results(infos.values()) + analysis.analyze_results(infos) } } @@ -169,7 +169,7 @@ void run_release_job(String branches) { void run_release_job(List branches) { analysis.main_record_timestamps('run_release_job') { - Map infos = [:] + List infos = [] try { environ.set_tls_release_environment() common.init_docker_images() @@ -181,12 +181,12 @@ void run_release_job(List branches) { } } branch_info_jobs.failFast = false - infos = parallel(branch_info_jobs) + infos = parallel(branch_info_jobs).values() } try { stage('tls-testing') { - def jobs = infos.collectEntries { branch, info -> - String prefix = branches.size() > 1 ? "$branch-" : '' + def jobs = infos.collectEntries { info -> + String prefix = branches.size() > 1 ? "$info.branch-" : '' return gen_jobs.gen_release_jobs(info, prefix) } jobs = common.wrap_report_errors(jobs) @@ -198,7 +198,7 @@ void run_release_job(List branches) { } finally { stage('result-analysis') { - analysis.analyze_results(infos.values()) + analysis.analyze_results(infos) } } } finally { @@ -209,7 +209,7 @@ void run_release_job(List branches) { } else { type = 'release' } - common.maybe_send_email("Mbed TLS $type tests", infos.values()) + common.maybe_send_email("Mbed TLS $type tests", infos) } } } From 0d87e6a2b648f28156f5e036b3c704e1bbd82ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Wed, 13 Nov 2024 19:54:38 +0100 Subject: [PATCH 3/4] Improve visualization of multi-branch info gathering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Blue Ocean doesn't display nested parallel stages correctly, so instead refactor get_branch_info and check_every_all_sh_component_will_be_run to handle multiple branches at once. Signed-off-by: Bence Szépkúti --- vars/common.groovy | 170 ++++++++++++++++++++++++-------------------- vars/mbedtls.groovy | 19 +---- 2 files changed, 97 insertions(+), 92 deletions(-) diff --git a/vars/common.groovy b/vars/common.groovy index ab37cee34..1fca4a9c0 100644 --- a/vars/common.groovy +++ b/vars/common.groovy @@ -224,69 +224,37 @@ docker run -u \$(id -u):\$(id -g) -e MAKEFLAGS -e VERBOSE_LOGS $env_args --rm -- /* Gather information about the branch that determines how to set up the * test environment. * In particular, get components of all.sh for Linux platforms. */ -BranchInfo get_branch_information(String branch) { - BranchInfo info = new BranchInfo() - info.branch = branch - +List get_branch_information(Collection branches) { + List infos = [] Map jobs = [:] - jobs << gen_jobs.job('all-platforms') { - node('container-host') { - try { - // Log the environment for debugging purposes - sh script: 'export' - - dir('src') { - deleteDir() - checkout_repo.checkout_tls_repo(branch) - - info.has_min_requirements = fileExists('scripts/min_requirements.py') + branches.each { String branch -> + BranchInfo info = new BranchInfo() + info.branch = branch + infos << info - if (info.has_min_requirements) { - info.python_requirements_override_content = construct_python_requirements_override() - if (info.python_requirements_override_content) { - info.python_requirements_override_file = 'override.requirements.txt' - } - } - } - - String platform = linux_platforms[0] - get_docker_image(platform) - def all_sh_help = sh( - script: docker_script( - platform, "./tests/scripts/all.sh", "--help" - ), - returnStdout: true - ) - if (all_sh_help.contains('list-components')) { - def all = sh( - script: docker_script( - platform, "./tests/scripts/all.sh", - "--list-all-components" - ), - returnStdout: true - ).trim().split('\n') - echo "All all.sh components: ${all.join(" ")}" - return all.collectEntries { element -> - return [(element): null] - } - } else { - error('Pre Test Checks failed: Base branch out of date. Please rebase') - } - } finally { - deleteDir() - } - } - } - - linux_platforms.each { platform -> - jobs << gen_jobs.job(platform) { - node(gen_jobs.node_label_for_platform(platform)) { + String prefix = branches.size() > 1 ? "$branch-" : '' + jobs << gen_jobs.job(prefix + 'all-platforms') { + node('container-host') { try { + // Log the environment for debugging purposes + sh script: 'export' + dir('src') { deleteDir() checkout_repo.checkout_tls_repo(branch) + + info.has_min_requirements = fileExists('scripts/min_requirements.py') + + if (info.has_min_requirements) { + info.python_requirements_override_content = construct_python_requirements_override() + if (info.python_requirements_override_content) { + info.python_requirements_override_file = 'override.requirements.txt' + } + } } + + String platform = linux_platforms[0] get_docker_image(platform) def all_sh_help = sh( script: docker_script( @@ -295,15 +263,16 @@ BranchInfo get_branch_information(String branch) { returnStdout: true ) if (all_sh_help.contains('list-components')) { - def available = sh( + def all = sh( script: docker_script( - platform, "./tests/scripts/all.sh", "--list-components" + platform, "./tests/scripts/all.sh", + "--list-all-components" ), returnStdout: true ).trim().split('\n') - echo "Available all.sh components on ${platform}: ${available.join(" ")}" - return available.collectEntries { element -> - return [(element): platform] + echo "All all.sh components: ${all.join(" ")}" + return all.collectEntries { element -> + return [(element): null] } } else { error('Pre Test Checks failed: Base branch out of date. Please rebase') @@ -313,34 +282,83 @@ BranchInfo get_branch_information(String branch) { } } } + + linux_platforms.each { platform -> + jobs << gen_jobs.job(prefix + platform) { + node(gen_jobs.node_label_for_platform(platform)) { + try { + dir('src') { + deleteDir() + checkout_repo.checkout_tls_repo(branch) + } + get_docker_image(platform) + def all_sh_help = sh( + script: docker_script( + platform, "./tests/scripts/all.sh", "--help" + ), + returnStdout: true + ) + if (all_sh_help.contains('list-components')) { + def available = sh( + script: docker_script( + platform, "./tests/scripts/all.sh", "--list-components" + ), + returnStdout: true + ).trim().split('\n') + echo "Available all.sh components on ${platform}: ${available.join(" ")}" + return available.collectEntries { element -> + return [(element): platform] + } + } else { + error('Pre Test Checks failed: Base branch out of date. Please rebase') + } + } finally { + deleteDir() + } + } + } + } } jobs.failFast = true def results = (Map>) parallel(jobs) - info.all_all_sh_components = results['all-platforms'] - linux_platforms.reverseEach { platform -> - info.all_all_sh_components << results[platform] - } + infos.each { BranchInfo info -> + String prefix = infos.size() > 1 ? "$info.branch-" : '' - if (env.JOB_TYPE == 'PR') { - // Do not run release components in PR jobs - info.all_all_sh_components = info.all_all_sh_components.findAll { - component, platform -> !component.startsWith('release') + info.all_all_sh_components = results[prefix + 'all-platforms'] + linux_platforms.reverseEach { platform -> + info.all_all_sh_components << results[prefix + platform] + } + + if (env.JOB_TYPE == 'PR') { + // Do not run release components in PR jobs + info.all_all_sh_components = info.all_all_sh_components.findAll { + component, platform -> !component.startsWith('release') + } } } - return info + return infos } -def check_every_all_sh_component_will_be_run(BranchInfo info) { - def untested_all_sh_components = info.all_all_sh_components.findResults { - name, platform -> platform ? null : name +void check_every_all_sh_component_will_be_run(Collection infos) { + Map> untested_all_sh_components = infos.collectEntries { info -> + def components = info.all_all_sh_components.findResults { + name, platform -> platform ? null : name + } + return components ? [(info.branch): components] : [:] } - if (untested_all_sh_components != []) { - error( - "Pre-test checks failed: Unable to run all.sh components: \ - ${untested_all_sh_components.join(",")}" + + if (untested_all_sh_components) { + def error_lines = ['Pre-test checks failed: Unable to run all.sh components:'] + untested_all_sh_components.collect( + error_lines, + { branch, components -> + String prefix = infos.size() > 1 ? "$branch: " : '' + return prefix + components.join(',') + } ) + error(error_lines.join('\n')) } } diff --git a/vars/mbedtls.groovy b/vars/mbedtls.groovy index e851b913c..724f71944 100644 --- a/vars/mbedtls.groovy +++ b/vars/mbedtls.groovy @@ -120,15 +120,8 @@ void run_pr_job(String target_repo, boolean is_production, List branches common.init_docker_images() stage('pre-test-checks') { - def pre_test_checks = branches.collectEntries { - branch -> gen_jobs.job(branch) { - BranchInfo info = common.get_branch_information(branch) - common.check_every_all_sh_component_will_be_run(info) - return info - } - } - pre_test_checks.failFast = false - infos = parallel(pre_test_checks).values() + infos = common.get_branch_information(branches) + common.check_every_all_sh_component_will_be_run(infos) } } catch (err) { def description = 'Pre-test checks failed.' @@ -175,13 +168,7 @@ void run_release_job(List branches) { common.init_docker_images() stage('branch-info') { - def branch_info_jobs = branches.collectEntries { - branch -> gen_jobs.job(branch) { - return common.get_branch_information(branch) - } - } - branch_info_jobs.failFast = false - infos = parallel(branch_info_jobs).values() + infos = common.get_branch_information(branches) } try { stage('tls-testing') { From be28b7d9cd58e79b4a405590f611ca981e2f7d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Mon, 25 Nov 2024 12:28:07 +0100 Subject: [PATCH 4/4] Fix Blue Ocean display of pre-test-checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Blue Ocean does not properly display "single-threaded" steps in any stage that also includes a parallel step. Separate the BranchInfo gathering into its own separate step, so the other checks are displayed properly. Signed-off-by: Bence Szépkúti --- vars/mbedtls.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vars/mbedtls.groovy b/vars/mbedtls.groovy index 724f71944..161ed32b1 100644 --- a/vars/mbedtls.groovy +++ b/vars/mbedtls.groovy @@ -119,8 +119,11 @@ void run_pr_job(String target_repo, boolean is_production, List branches common.init_docker_images() - stage('pre-test-checks') { + stage('branch-info') { infos = common.get_branch_information(branches) + } + + stage('pre-test-checks') { common.check_every_all_sh_component_will_be_run(infos) } } catch (err) {