Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix visualization of multi-branch info gathering and unexecuted components test #186

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 95 additions & 76 deletions vars/common.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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<BranchInfo> get_branch_information(Collection<String> branches) {
List<BranchInfo> infos = []
Map<String, Object> 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(
Expand All @@ -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')
Expand All @@ -313,33 +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<String, Map<String, String>>) 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.collectMany(
{name, platform -> platform ? [] : [name]})
if (untested_all_sh_components != []) {
error(
"Pre-test checks failed: Unable to run all.sh components: \
${untested_all_sh_components.join(",")}"
void check_every_all_sh_component_will_be_run(Collection<BranchInfo> infos) {
Map<String, Collection<String>> 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) {
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'))
}
}

Expand Down
38 changes: 14 additions & 24 deletions vars/mbedtls.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void run_pr_job(String target_repo, boolean is_production, List<String> branches
}
}

Map<String, BranchInfo> infos
List<BranchInfo> infos

try {
common.maybe_notify_github('PENDING', 'In progress')
Expand All @@ -119,16 +119,12 @@ void run_pr_job(String target_repo, boolean is_production, List<String> branches

common.init_docker_images()

stage('branch-info') {
infos = common.get_branch_information(branches)
}

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)
common.check_every_all_sh_component_will_be_run(infos)
}
} catch (err) {
def description = 'Pre-test checks failed.'
Expand All @@ -141,11 +137,11 @@ void run_pr_job(String target_repo, boolean is_production, List<String> 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)
}
}

Expand All @@ -169,24 +165,18 @@ void run_release_job(String branches) {

void run_release_job(List<String> branches) {
analysis.main_record_timestamps('run_release_job') {
Map<String, BranchInfo> infos = [:]
List<BranchInfo> infos = []
try {
environ.set_tls_release_environment()
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)
infos = common.get_branch_information(branches)
}
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)
Expand All @@ -198,7 +188,7 @@ void run_release_job(List<String> branches) {
}
finally {
stage('result-analysis') {
analysis.analyze_results(infos.values())
analysis.analyze_results(infos)
}
}
} finally {
Expand All @@ -209,7 +199,7 @@ void run_release_job(List<String> branches) {
} else {
type = 'release'
}
common.maybe_send_email("Mbed TLS $type tests", infos.values())
common.maybe_send_email("Mbed TLS $type tests", infos)
}
}
}
Expand Down