Skip to content

Commit

Permalink
build: add Loki CI step to eui-pull-request-and-deploy pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
tkajtoch committed May 13, 2024
1 parent 5c40315 commit a79e29f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .buildkite/pipelines/pipeline_pull_request_test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,32 @@

steps:
- trigger: "eui-pull-request-test"
key: "test"
label: ":hammer: EUI pull request test"
build:
branch: "${BUILDKITE_BRANCH}"
commit: "${BUILDKITE_COMMIT}"
- trigger: "eui-pull-request-deploy-docs"
key: "deploy-docs"
label: ":newspaper: EUI pull request deploy docs"
build:
branch: "${BUILDKITE_BRANCH}"
commit: "${BUILDKITE_COMMIT}"
env:
GIT_BRANCH: "${BUILDKITE_BRANCH}"
GIT_PULL_REQUEST_ID: "${BUILDKITE_PULL_REQUEST}"
- depends_on: "deploy-docs"
label: ":camera_with_flash: Visual regression tests"
command: ".buildkite/scripts/visual_regression/run_loki.sh"
agents:
provider: "gcp"
# Loki isn't resource heavy and doesn't benefit
# from faster CPUs like the n2 family
machineType: 'n1-standard-1'
# Use spot instances
# https://cloud.google.com/spot-vms
preemptible: true
retry:
automatic:
- exit_status: '-1'
limit: 1
30 changes: 30 additions & 0 deletions .buildkite/scripts/visual_regression/run_loki.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -euo pipefail

storybook_url="https://eui.elastic.co/storybook"

# If the branch is not a pull request, Buildkite passes "false"
# https://buildkite.com/docs/pipelines/environment-variables#BUILDKITE_PULL_REQUEST
if [[ "${BUILDKITE_PULL_REQUEST}" != "false" ]]; then
echo "+++ Running visual regression tests on pull request #${BUILDKITE_PULL_REQUEST}"
echo "https://github.com/elastic/eui/pull/${BUILDKITE_PULL_REQUEST}"
storybook_url="https://eui.elastic.co/pr_${BUILDKITE_PULL_REQUEST}/storybook"
elif [[ "${BUILDKITE_BRANCH}" == "main" ]]; then
echo "+++ Running visual regression tests on main"
else
echo "+++ :x: Visual regression tests can only be run against \`main\` and open pull requests. Exiting"
exit 1
fi

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_BASE_IMAGE" \
bash -c "yarn && yarn --cwd packages/eui test-visual-regression --reactUri $storybook_url"

0 comments on commit a79e29f

Please sign in to comment.