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

Run TF-PSA-Crypto components without cloning Mbed TLS #190

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions src/org/mbed/tls/jenkins/BranchInfo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class BranchInfo {
* if no platform has been chosen yet. */
public Map<String, String> mbed_tls_all_sh_components

/** Map from component name to chosen platform to run it, or to null
* if no platform has been chosen yet. Empty if we are not running any tests.*/
public Map<String, String> tf_psa_crypto_all_sh_components

/** Whether scripts/min_requirements.py is available. Older branches don't
* have it, so they only get what's hard-coded in the docker files on Linux,
* and bare python on other platforms. */
Expand Down Expand Up @@ -36,6 +40,7 @@ class BranchInfo {

BranchInfo() {
this.mbed_tls_all_sh_components = [:]
this.tf_psa_crypto_all_sh_components = [:]
this.has_min_requirements = false
this.python_requirements_override_content = ''
this.python_requirements_override_file = ''
Expand Down
122 changes: 76 additions & 46 deletions vars/common.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ List<BranchInfo> get_branch_information(Collection<String> branches) {
List<BranchInfo> infos = []
Map<String, Object> jobs = [:]

def repo_roots = ['tls': '.']

if (env.RUN_TF_PSA_CRYPTO_ALL_SH == 'true') {
repo_roots['tf-psa-crypto'] = 'tf-psa-crypto'
}

branches.each { String branch ->
BranchInfo info = new BranchInfo()
info.branch = branch
Expand Down Expand Up @@ -256,26 +262,33 @@ List<BranchInfo> get_branch_information(Collection<String> branches) {

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]
return repo_roots.collectEntries { repo, root ->
dir(root) {
if (!fileExists('./tests/scripts/all.sh')) {
return [(repo): [:]]
}
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(" ")}"
mpg marked this conversation as resolved.
Show resolved Hide resolved
return [(repo): all.collectEntries { element ->
return [(element): null]
}]
} else {
error('Pre Test Checks failed: Base branch out of date. Please rebase')
}
}
} else {
error('Pre Test Checks failed: Base branch out of date. Please rebase')
}
} finally {
deleteDir()
Expand All @@ -292,25 +305,36 @@ List<BranchInfo> get_branch_information(Collection<String> branches) {
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]
return repo_roots.collectEntries { repo, root ->
// Only run tf-psa-crypto tests on the first branch
if (repo == 'tf-psa-crypto' && branch != branches[0]) {
return [(repo): [:]]
}
dir(root) {
if (!fileExists('./tests/scripts/all.sh')) {
return [(repo): [:]]
}
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 [(repo): available.collectEntries { element ->
return [(element): platform]
}]
} else {
error('Pre Test Checks failed: Base branch out of date. Please rebase')
}
}
} else {
error('Pre Test Checks failed: Base branch out of date. Please rebase')
}
} finally {
deleteDir()
Expand All @@ -321,22 +345,28 @@ List<BranchInfo> get_branch_information(Collection<String> branches) {
}

jobs.failFast = true
def results = (Map<String, Map<String, String>>) parallel(jobs)
def results = (Map<String, Map<String, Map<String, String>>>) parallel(jobs)

infos.each { BranchInfo info ->
String prefix = infos.size() > 1 ? "$info.branch-" : ''

info.mbed_tls_all_sh_components = results[prefix + 'all-platforms']
linux_platforms.reverseEach { platform ->
info.mbed_tls_all_sh_components << results[prefix + platform]
}
Map<String, Map<String, String>> repo_components = repo_roots.keySet().collectEntries {repo ->
def components = results[prefix + 'all-platforms'][repo]
linux_platforms.reverseEach { platform ->
components << results[prefix + platform][repo]
}

if (env.JOB_TYPE == 'PR') {
// Do not run release components in PR jobs
info.mbed_tls_all_sh_components = info.mbed_tls_all_sh_components.findAll {
component, platform -> !component.startsWith('release')
if (env.JOB_TYPE == 'PR') {
// Do not run release components in PR jobs
components = components.findAll {
component, platform -> !component.startsWith('release')
}
}
return [(repo): components]
}

info.mbed_tls_all_sh_components = repo_components['tls']
info.tf_psa_crypto_all_sh_components = repo_components['tf-psa-crypto'] ?: [:]
}
return infos
}
Expand Down