Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
14 changes: 14 additions & 0 deletions .buildkite/pipelines/pipeline_pull_request_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,17 @@ steps:
- "cypress/videos/**/*.mp4"
timeout_in_minutes: 45
retry: *retry_policy

- command: .buildkite/scripts/pipelines/pipeline_test.sh
label: ":typescript: Workspace linting"
env:
TEST_TYPE: 'pkg:lint'
if: build.branch != "main"
retry: *retry_policy

- command: .buildkite/scripts/pipelines/pipeline_test.sh
label: ":jest: Workspace unit tests"
env:
TEST_TYPE: 'pkg:unit'
if: build.branch != "main"
retry: *retry_policy
7 changes: 6 additions & 1 deletion .buildkite/pull-requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))",
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))",
"set_commit_status": true,
"skip_ci_on_only_changed": ["^.github/", "^wiki/"]
"skip_ci_on_only_changed": [
"^\\.github/",
"^wiki/",
"^packages/website/",
"^packages/docusaurus-"
]
Comment thread
weronikaolejniczak marked this conversation as resolved.
},
{
"enabled": true,
Expand Down
52 changes: 52 additions & 0 deletions .buildkite/scripts/pipelines/pipeline_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,40 @@ source .buildkite/scripts/common/utils.sh

buildkite_analytics_vault="secret/ci/elastic-eui/buildkite-test-analytics"

# Paths that don't affect the EUI test suite.
# When a PR's diff is contained entirely within these paths,
# the heavy EUI jobs (lint, unit:*, cypress:*) exit early below.
# The lightweight per-package jobs always run.
NON_EUI_PATHS_REGEXP='^(\.github/|wiki/|packages/(website|docusaurus-[^/]+|eslint-plugin)/)'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In theory, these will be skipped earlier. This is an additional check.


is_eui_test_type() {
case "$1" in
lint|unit:ts|unit:tsx|unit:tsx:17|cypress:17|cypress:18|cypress:a11y) return 0 ;;
*) return 1 ;;
esac
}

should_skip_eui_tests() {
local base_branch="${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-main}"
git fetch --no-tags --quiet origin "$base_branch" 2>/dev/null || return 1

local merge_base
merge_base=$(git merge-base "origin/$base_branch" HEAD 2>/dev/null) || return 1

local changed
changed=$(git diff --name-only "$merge_base" HEAD 2>/dev/null) || return 1

[[ -n "$changed" ]] || return 1
echo "$changed" | grep -qvE "$NON_EUI_PATHS_REGEXP" && return 1

return 0
}

if is_eui_test_type "$TEST_TYPE" && should_skip_eui_tests; then
echo "[SKIP]: Only non-EUI paths changed; skipping ${TEST_TYPE}"
exit 0
fi

DOCKER_OPTIONS=(
-i --rm
--env GIT_COMMITTER_NAME=test
Expand Down Expand Up @@ -67,6 +101,24 @@ case $TEST_TYPE in
COMMAND="/opt/yarn*/bin/yarn --cwd packages/eui && yarn --cwd packages/eui build:workspaces && yarn --cwd packages/eui cypress install && yarn --cwd packages/eui run test-cypress-a11y --node-options=--max_old_space_size=2048"
;;

pkg:lint)
echo "[TASK]: Linting all workspaces except @elastic/eui"
COMMAND="/opt/yarn*/bin/yarn && yarn workspace @elastic/eui build:workspaces && \
yarn workspaces foreach -A -pi \
--exclude '@elastic/eui' \
--exclude '@elastic/eui-monorepo' \
run lint"
;;

pkg:unit)
echo "[TASK]: Running unit tests for all workspaces except @elastic/eui"
COMMAND="/opt/yarn*/bin/yarn && yarn workspace @elastic/eui build:workspaces && \
yarn workspaces foreach -A -pi \
--exclude '@elastic/eui' \
--exclude '@elastic/eui-monorepo' \
run test-unit"
;;

*)
echo "[ERROR]: Unknown task"
echo "Exit code: 1"
Expand Down
4 changes: 2 additions & 2 deletions packages/test-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"private": true,
"scripts": {
"lint": "tsc --noEmit",
"test": "yarn lint && yarn test-unit",
"test-unit": "playwright test",
"test": "yarn lint && yarn test-e2e",
"test-e2e": "playwright test",
"show-report": "playwright show-report"
},
"peerDependencies": {
Expand Down