Skip to content

Commit

Permalink
[ci] Run Jest tests in parallel
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
  • Loading branch information
Tyler Smalley committed Oct 20, 2021
1 parent 1a5570b commit b3585c7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .buildkite/pipelines/hourly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ steps:

- command: .buildkite/scripts/steps/test/jest.sh
label: 'Jest Tests'
parallelism: 5
agents:
queue: c2-16
queue: n2-4
timeout_in_minutes: 120
key: jest

Expand Down
3 changes: 2 additions & 1 deletion .buildkite/pipelines/pull_request/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ steps:

- command: .buildkite/scripts/steps/test/jest.sh
label: 'Jest Tests'
parallelism: 5
agents:
queue: c2-16
queue: n2-4
timeout_in_minutes: 120
key: jest

Expand Down
4 changes: 2 additions & 2 deletions .buildkite/scripts/steps/test/jest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ is_test_execution_step
.buildkite/scripts/bootstrap.sh

echo '--- Jest'
checks-reporter-with-killswitch "Jest Unit Tests" \
node scripts/jest --ci --verbose --maxWorkers=10
checks-reporter-with-killswitch "Jest Unit Tests $((BUILDKITE_PARALLEL_JOB+1))" \
.buildkite/scripts/steps/test/jest_parallel.sh
16 changes: 16 additions & 0 deletions .buildkite/scripts/steps/test/jest_parallel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -euo pipefail

JOB=$BUILDKITE_PARALLEL_JOB
JOB_COUNT=$BUILDKITE_PARALLEL_JOB_COUNT

i=0
find src x-pack packages -name jest.config.js | sort | while read config; do
if [ "$(($i % $JOB_COUNT))" -eq $JOB ]; then
echo "--- $ node scripts/jest --config $config"
node scripts/jest --config $config --runInBand
fi

((i=i+1))
done

0 comments on commit b3585c7

Please sign in to comment.