[buildkite] Fix off-by-one problem for test failure annotations (#113852) (#113869)

Co-authored-by: Brian Seeders <brian.seeders@elastic.co>
This commit is contained in:
Kibana Machine 2021-10-04 21:55:29 -04:00 committed by GitHub
parent ed02505f31
commit 3c59b9de7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,6 +76,12 @@ export function reportFailuresToFile(log: ToolingLog, failures: TestFailure[]) {
.flat()
.join('\n');
// Buildkite steps that use `parallelism` need a numerical suffix added to identify them
// We should also increment the number by one, since it's 0-based
const jobNumberSuffix = process.env.BUILDKITE_PARALLEL_JOB
? ` #${parseInt(process.env.BUILDKITE_PARALLEL_JOB, 10) + 1}`
: '';
const failureJSON = JSON.stringify(
{
...failure,
@ -84,9 +90,7 @@ export function reportFailuresToFile(log: ToolingLog, failures: TestFailure[]) {
jobId: process.env.BUILDKITE_JOB_ID || '',
url: process.env.BUILDKITE_BUILD_URL || '',
jobName: process.env.BUILDKITE_LABEL
? `${process.env.BUILDKITE_LABEL}${
process.env.BUILDKITE_PARALLEL_JOB ? ` #${process.env.BUILDKITE_PARALLEL_JOB}` : ''
}`
? `${process.env.BUILDKITE_LABEL}${jobNumberSuffix}`
: '',
},
null,