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

[INFRA] Parallelize Buildkite test job, take 3 #7242

Merged
merged 6 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
69 changes: 66 additions & 3 deletions .buildkite/pipelines/pipeline_pull_request_test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,72 @@
# 🏠/.buildkite/pipelines/pipeline_pull_request_test.yml

steps:
- agents:
- command: .buildkite/scripts/pipeline_test.sh
label: ":typescript: Linting"
agents:
provider: "gcp"
command: .buildkite/scripts/pipeline_test.sh
if: build.branch != "main" # We're skipping testing commits in main for now to maintain parity with previous Jenkins setup
env:
TEST_TYPE: 'lint'
if: build.branch != "main" # This job is triggered by the combined test and deploy docs for every PR

- command: .buildkite/scripts/pipeline_test.sh
label: ":jest: TS unit tests"
agents:
provider: "gcp"
env:
TEST_TYPE: 'unit:ts'
if: build.branch != "main"

- command: .buildkite/scripts/pipeline_test.sh
label: ":jest: TSX unit tests on React 16"
agents:
provider: "gcp"
env:
TEST_TYPE: 'unit:tsx:16'
if: build.branch != "main"

- command: .buildkite/scripts/pipeline_test.sh
label: ":jest: TSX unit tests on React 17"
agents:
provider: "gcp"
env:
TEST_TYPE: 'unit:tsx:17'
if: build.branch != "main"

- command: .buildkite/scripts/pipeline_test.sh
label: ":jest: TSX unit tests on React 18"
agents:
provider: "gcp"
env:
TEST_TYPE: 'unit:tsx'
if: build.branch != "main"

- command: .buildkite/scripts/pipeline_test.sh
label: ":cypress: Cypress tests on React 16"
agents:
provider: "gcp"
env:
TEST_TYPE: 'cypress:16'
if: build.branch != "main"
artifact_paths:
- "cypress/screenshots/**/*.png"

- command: .buildkite/scripts/pipeline_test.sh
label: ":cypress: Cypress tests on React 17"
agents:
provider: "gcp"
env:
TEST_TYPE: 'cypress:17'
if: build.branch != "main"
artifact_paths:
- "cypress/screenshots/**/*.png"

- command: .buildkite/scripts/pipeline_test.sh
label: ":cypress: Cypress tests on React 18"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these labels and icons are heckin beautiful!

agents:
provider: "gcp"
env:
TEST_TYPE: 'cypress:18'
if: build.branch != "main"
artifact_paths:
- "cypress/screenshots/**/*.png"
74 changes: 60 additions & 14 deletions .buildkite/scripts/pipeline_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,63 @@

set -euo pipefail

docker run \
-i --rm \
--env GIT_COMMITTER_NAME=test \
--env GIT_COMMITTER_EMAIL=test \
--env HOME=/tmp \
--user="$(id -u):$(id -g)" \
--volume="$(pwd):/app" \
--workdir=/app \
docker.elastic.co/eui/ci:5.3 \
bash -c "/opt/yarn*/bin/yarn \
&& yarn cypress install \
&& yarn lint \
&& yarn test-unit --node-options=--max_old_space_size=2048 \
&& yarn test-cypress --node-options=--max_old_space_size=2048"
DOCKER_OPTIONS=(
-i --rm
--env GIT_COMMITTER_NAME=test
--env GIT_COMMITTER_EMAIL=test
--env HOME=/tmp
--user="$(id -u):$(id -g)"
--volume="$(pwd):/app"
--workdir=/app
docker.elastic.co/eui/ci:5.3
)

case $TEST_TYPE in
lint)
echo "[TASK]: Running linters"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn && yarn lint")
;;

unit:ts)
echo "[TASK]: Running .ts and .js unit tests"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn && yarn test-unit --node-options=--max_old_space_size=2048 --testMatch=non-react")
;;

unit:tsx:16)
echo "[TASK]: Running Jest .tsx tests against React 16"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn && yarn test-unit --node-options=--max_old_space_size=2048 --react-version=16 --testMatch=react")
;;

unit:tsx:17)
echo "[TASK]: Running Jest .tsx tests against React 17"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn && yarn test-unit --node-options=--max_old_space_size=2048 --react-version=17 --testMatch=react")
;;

unit:tsx)
echo "[TASK]: Running Jest .tsx tests against React 18"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn && yarn test-unit --node-options=--max_old_space_size=2048 --testMatch=react")
;;

cypress:16)
echo "[TASK]: Running Cypress tests against React 16"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn && yarn test-cypress --node-options=--max_old_space_size=2048 --react-version=16")
;;

cypress:17)
echo "[TASK]: Running Cypress tests against React 17"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn && yarn test-cypress --node-options=--max_old_space_size=2048 --react-version=17")
;;

cypress:18)
echo "[TASK]: Running Cypress tests against React 18"
DOCKER_OPTIONS+=(bash -c "/opt/yarn*/bin/yarn && yarn test-cypress --node-options=--max_old_space_size=2048")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to yarn cypress install for these tests?

Copy link
Contributor Author

@1Copenut 1Copenut Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good call, I meant to remove those. I'll update quick. Maybe? IIRC, the test logs ignore the install because it's already added in the Dockerfile. I think we could be more discerning and add Cypress here or a better approach might be to pin the Dockerfile Cypress install to the same version we're using in our package.json file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a better approach might be to pin the Dockerfile Cypress install to the same version we're using in our package.json file.

I'm not a super huge fan of that because it's another fragility point between local and CI that could fall out of date if we forget (e.g. we update package.json but not the dockerfile). It's 100% happened in the past before as well, so I'd rather the Docker container reuse package.json for simplicity if possible.

Copy link
Contributor Author

@1Copenut 1Copenut Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's valid. I'll add the yarn install cypress back to these three Cypress run calls so we have an "at the metal" install.

;;

*)
echo "[ERROR]: Unknown task"
echo "Exit code: 1"
exit 1
;;
esac

docker run "${DOCKER_OPTIONS[@]}"
Loading