diff --git a/vars/common.groovy b/vars/common.groovy index c0fd4516b..ef45b8cce 100644 --- a/vars/common.groovy +++ b/vars/common.groovy @@ -403,31 +403,50 @@ void check_every_all_sh_component_will_be_run(Collection infos) { * description for a given context. If it is omitted, this * method determines the correct context from is_open_ci_env * and BRANCH_NAME. + * prepend_ci (optional): a boolean value that determines whether the CI ID + * computed from is_open_ci_env should be prepended to the + * supplied context. */ -void maybe_notify_github(String state, String description, String context=null) { +void maybe_notify_github(String state, String description, String context=null, Boolean prepend_ci=null) { if (!env.BRANCH_NAME) { return; } + if (prepend_ci == null) { + prepend_ci = context == null + } + /* Truncate the description. Otherwise githubNotify fails. */ final MAX_DESCRIPTION_LENGTH = 140 if (description.length() > MAX_DESCRIPTION_LENGTH) { description = description.take(MAX_DESCRIPTION_LENGTH - 1) + '…' } + def ctxs if (context == null) { + if (env.BRANCH_NAME ==~ /PR-\d+-merge/) { + ctxs = ['ABI stability tests', 'Storage format tests'] + } else { + ctxs = ['PR tests'] + } + } else { + ctxs = [context] + } + + if (prepend_ci) { def ci = is_open_ci_env ? 'TF OpenCI' : 'Internal CI' - def job = env.BRANCH_NAME ==~ /PR-\d+-merge/ ? 'Interface stability tests' : 'PR tests' - context = "$ci: $job" + ctxs = ctxs.collect {ctx -> "$ci: $ctx"} } - githubNotify context: context, - status: state, - description: description, - /* Set owner and repository explicitly in case the multibranch pipeline uses multiple repos -- * Needed for testing Github merge queues */ - account: env.GITHUB_ORG, - repo: env.GITHUB_REPO + ctxs.each { ctx -> + githubNotify context: ctx, + status: state, + description: description, + /* Set owner and repository explicitly in case the multibranch pipeline uses multiple repos +- * Needed for testing Github merge queues */ + account: env.GITHUB_ORG, + repo: env.GITHUB_REPO + } } def archive_zipped_log_files(job_name) { diff --git a/vars/gen_jobs.groovy b/vars/gen_jobs.groovy index 2707a0345..0bd25f497 100644 --- a/vars/gen_jobs.groovy +++ b/vars/gen_jobs.groovy @@ -491,9 +491,32 @@ git submodule foreach --recursive ' String script_in_docker = """ tests/scripts/list-identifiers.sh --internal # Workaround for abi_check.py failing to properly escape slashes in ref names -scripts/abi_check.py -o \$(git rev-parse 'origin/${env.CHANGE_TARGET}^{commit}') -n HEAD -s identifiers --brief +old_commit=\$(git rev-parse 'origin/${env.CHANGE_TARGET}^{commit}') +scripts/abi_check.py --no-check-storage -o "\$old_commit" -n HEAD -s identifiers --brief || touch abi_check.failed +scripts/abi_check.py --no-check-api --no-check-abi -o "\$old_commit" -n HEAD -s identifiers --brief || touch storage_check.failed """ + hooks.post_success = { + boolean abi_check_failed = fileExists('abi_check.failed') + boolean storage_check_failed = fileExists('storage_check.failed') + if (abi_check_failed) { + common.maybe_notify_github('FAILURE', 'abi_check.py: ABI/API check failed', 'ABI stability tests', true) + } else { + common.maybe_notify_github('SUCCESS', 'All tests passed', 'ABI stability tests', true) + } + if (storage_check_failed) { + common.maybe_notify_github('FAILURE', 'abi_check.py: Storage format check failed', 'Storage format tests', true) + } else { + common.maybe_notify_github('SUCCESS', 'All tests passed', 'Storage format tests', true) + } + if (abi_check_failed || storage_check_failed) { + /* Disable automatic status report in mbedtls.run_tls_tests() + * so we don't overwrite the ones we sent above */ + currentBuild.result = 'FAILURE' + error('Failure in abi_check.py') + } + } + return gen_docker_job(hooks, info, job_name, platform, script_in_docker) } diff --git a/vars/mbedtls.groovy b/vars/mbedtls.groovy index a7ae6acac..5b79b9e07 100644 --- a/vars/mbedtls.groovy +++ b/vars/mbedtls.groovy @@ -48,7 +48,11 @@ void run_tls_tests(Collection infos) { def failed_names = infos.collectMany({ info -> info.failed_builds}).sort().join(" ") echo "Caught: ${err}" echo "Failed jobs: ${failed_names}" - common.maybe_notify_github('FAILURE', "Failures: ${failed_names}") + if (currentBuild.resultIsWorseOrEqualTo('FAILURE') && (env.BRANCH_NAME ==~ /PR-\d+-merge/)) { + echo 'The results of abi_check.py have already been reported, skipping Github notification' + } else { + common.maybe_notify_github('FAILURE', "Failures: ${failed_names}") + } throw err } }