Skip to content

[9.3] Scout: enable Selective testing in Pull Requests (#261510)#262959

Merged
dmlemeshko merged 1 commit intoelastic:9.3from
kibanamachine:backport/9.3/pr-261510
Apr 14, 2026
Merged

[9.3] Scout: enable Selective testing in Pull Requests (#261510)#262959
dmlemeshko merged 1 commit intoelastic:9.3from
kibanamachine:backport/9.3/pr-261510

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.3:

Questions ?

Please refer to the Backport tool documentation

## Summary

Closes elastic/appex-qa-team#700

This PR enables Scout selective testing as a _default test execution for
every PR targeting tracked branch_ (e.g. `main`).

### What selective testing means for kibana-contributors?

- When a PR build runs, `list_affected` uses git diff against the merge
base to find which `@kbn/` modules have changed files (including
downstream dependents) This produces a JSON array of affected module
IDs.

- Scout CLI uses this file to find all the matching test configs: each
Scout module's config path is resolved to its `@kbn/` ID via
`kibana.jsonc`. Scout config discovery filters down to only the affected
modules — so CI only creates Buildkite steps for Scout tests belonging
to changed modules (packages and plugins)

- PR builds run only the Scout tests scoped to the changed modules,
cutting wall-to-wall build time.

**Critical files bypass**
A new `resolve_selective_testing.ts` script runs before config
discovery. In a single git invocation it:

1. Computes the affected modules and writes the JSON file consumed by
`discover-playwright-configs`.
2. Checks whether any critical Scout files were touched (e.g.
package.json, yarn.lock, Scout runtime packages, the CI pipeline scripts
themselves) using touchedCriticalFiles against a new
`CRITICAL_FILES_SCOUT` constant — following the same pattern already
used for Jest unit and integration tests.

If critical files are detected, selective testing is bypassed and the
full suite runs. The affected-module labels on Buildkite steps are
always applied regardless, since `--affected-modules` is passed
unconditionally and `--selective-testing` is a separate flag.

<img width="1833" height="665" alt="Screenshot 2026-04-07 at 14 17 28"
src="https://github.com/user-attachments/assets/918ad0f8-28c4-471d-93fe-577264cf85f1"
/>

**Note**: The `scout:run-all-tests` label enforces the full test matrix
while still showing which modules were affected.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit b3c3317)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Apr 14, 2026
@kibanamachine kibanamachine enabled auto-merge (squash) April 14, 2026 08:01
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #12 / Cloud Security Posture - Group 2 Test adding Cloud Security Posture Integrations CSPM AWS CIS_AWS Organization Manual Direct Access CIS_AWS Organization Manual Direct Access Workflow

Metrics [docs]

✅ unchanged

cc @dmlemeshko

@dmlemeshko dmlemeshko merged commit 454c1df into elastic:9.3 Apr 14, 2026
15 checks passed
dmlemeshko added a commit that referenced this pull request Apr 16, 2026
…3086)

# Backport

This will backport the following commits from `main` to `9.2`:
- [Scout: enable Selective testing in Pull Requests
(#261510)](#261510)

<!--- Backport version: 10.2.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Dzmitry
Lemechko","email":"dzmitry.lemechko@elastic.co"},"sourceCommit":{"committedDate":"2026-04-14T07:51:52Z","message":"Scout:
enable Selective testing in Pull Requests (#261510)\n\n##
Summary\n\nCloses
https://github.com/elastic/appex-qa-team/issues/700\n\nThis PR enables
Scout selective testing as a _default test execution for\nevery PR
targeting tracked branch_ (e.g. `main`).\n\n### What selective testing
means for kibana-contributors?\n\n- When a PR build runs,
`list_affected` uses git diff against the merge\nbase to find which
`@kbn/` modules have changed files (including\ndownstream dependents)
This produces a JSON array of affected module\nIDs.\n\n- Scout CLI uses
this file to find all the matching test configs: each\nScout module's
config path is resolved to its `@kbn/` ID via\n`kibana.jsonc`. Scout
config discovery filters down to only the affected\nmodules — so CI only
creates Buildkite steps for Scout tests belonging\nto changed modules
(packages and plugins)\n\n- PR builds run only the Scout tests scoped to
the changed modules,\ncutting wall-to-wall build time.\n\n**Critical
files bypass**\nA new `resolve_selective_testing.ts` script runs before
config\ndiscovery. In a single git invocation it:\n\n1. Computes the
affected modules and writes the JSON file consumed
by\n`discover-playwright-configs`.\n2. Checks whether any critical Scout
files were touched (e.g.\npackage.json, yarn.lock, Scout runtime
packages, the CI pipeline scripts\nthemselves) using
touchedCriticalFiles against a new\n`CRITICAL_FILES_SCOUT` constant —
following the same pattern already\nused for Jest unit and integration
tests.\n\nIf critical files are detected, selective testing is bypassed
and the\nfull suite runs. The affected-module labels on Buildkite steps
are\nalways applied regardless, since `--affected-modules` is
passed\nunconditionally and `--selective-testing` is a separate
flag.\n\n\n\n<img width=\"1833\" height=\"665\" alt=\"Screenshot
2026-04-07 at 14 17
28\"\nsrc=\"https://github.com/user-attachments/assets/918ad0f8-28c4-471d-93fe-577264cf85f1\"\n/>\n\n\n**Note**:
The `scout:run-all-tests` label enforces the full test matrix\nwhile
still showing which modules were
affected.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"b3c331750e67222a9c0f48f15f2b829d9c71e28e","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:QA","release_note:skip","backport:all-open","test:scout","v9.4.0","v9.5.0","v9.3.4"],"title":"Scout:
enable Selective testing in Pull
Requests","number":261510,"url":"https://github.com/elastic/kibana/pull/261510","mergeCommit":{"message":"Scout:
enable Selective testing in Pull Requests (#261510)\n\n##
Summary\n\nCloses
https://github.com/elastic/appex-qa-team/issues/700\n\nThis PR enables
Scout selective testing as a _default test execution for\nevery PR
targeting tracked branch_ (e.g. `main`).\n\n### What selective testing
means for kibana-contributors?\n\n- When a PR build runs,
`list_affected` uses git diff against the merge\nbase to find which
`@kbn/` modules have changed files (including\ndownstream dependents)
This produces a JSON array of affected module\nIDs.\n\n- Scout CLI uses
this file to find all the matching test configs: each\nScout module's
config path is resolved to its `@kbn/` ID via\n`kibana.jsonc`. Scout
config discovery filters down to only the affected\nmodules — so CI only
creates Buildkite steps for Scout tests belonging\nto changed modules
(packages and plugins)\n\n- PR builds run only the Scout tests scoped to
the changed modules,\ncutting wall-to-wall build time.\n\n**Critical
files bypass**\nA new `resolve_selective_testing.ts` script runs before
config\ndiscovery. In a single git invocation it:\n\n1. Computes the
affected modules and writes the JSON file consumed
by\n`discover-playwright-configs`.\n2. Checks whether any critical Scout
files were touched (e.g.\npackage.json, yarn.lock, Scout runtime
packages, the CI pipeline scripts\nthemselves) using
touchedCriticalFiles against a new\n`CRITICAL_FILES_SCOUT` constant —
following the same pattern already\nused for Jest unit and integration
tests.\n\nIf critical files are detected, selective testing is bypassed
and the\nfull suite runs. The affected-module labels on Buildkite steps
are\nalways applied regardless, since `--affected-modules` is
passed\nunconditionally and `--selective-testing` is a separate
flag.\n\n\n\n<img width=\"1833\" height=\"665\" alt=\"Screenshot
2026-04-07 at 14 17
28\"\nsrc=\"https://github.com/user-attachments/assets/918ad0f8-28c4-471d-93fe-577264cf85f1\"\n/>\n\n\n**Note**:
The `scout:run-all-tests` label enforces the full test matrix\nwhile
still showing which modules were
affected.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"b3c331750e67222a9c0f48f15f2b829d9c71e28e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/262960","number":262960,"state":"MERGED","mergeCommit":{"sha":"f6504aed0dc507f3e7efbea70c9d52ab81771bbe","message":"[9.4]
Scout: enable Selective testing in Pull Requests (#261510)
(#262960)\n\n# Backport\n\nThis will backport the following commits from
`main` to `9.4`:\n- [Scout: enable Selective testing in Pull
Requests\n(#261510)](https://github.com/elastic/kibana/pull/261510)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by:
Dzmitry Lemechko
<dzmitry.lemechko@elastic.co>"}},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/261510","number":261510,"mergeCommit":{"message":"Scout:
enable Selective testing in Pull Requests (#261510)\n\n##
Summary\n\nCloses
https://github.com/elastic/appex-qa-team/issues/700\n\nThis PR enables
Scout selective testing as a _default test execution for\nevery PR
targeting tracked branch_ (e.g. `main`).\n\n### What selective testing
means for kibana-contributors?\n\n- When a PR build runs,
`list_affected` uses git diff against the merge\nbase to find which
`@kbn/` modules have changed files (including\ndownstream dependents)
This produces a JSON array of affected module\nIDs.\n\n- Scout CLI uses
this file to find all the matching test configs: each\nScout module's
config path is resolved to its `@kbn/` ID via\n`kibana.jsonc`. Scout
config discovery filters down to only the affected\nmodules — so CI only
creates Buildkite steps for Scout tests belonging\nto changed modules
(packages and plugins)\n\n- PR builds run only the Scout tests scoped to
the changed modules,\ncutting wall-to-wall build time.\n\n**Critical
files bypass**\nA new `resolve_selective_testing.ts` script runs before
config\ndiscovery. In a single git invocation it:\n\n1. Computes the
affected modules and writes the JSON file consumed
by\n`discover-playwright-configs`.\n2. Checks whether any critical Scout
files were touched (e.g.\npackage.json, yarn.lock, Scout runtime
packages, the CI pipeline scripts\nthemselves) using
touchedCriticalFiles against a new\n`CRITICAL_FILES_SCOUT` constant —
following the same pattern already\nused for Jest unit and integration
tests.\n\nIf critical files are detected, selective testing is bypassed
and the\nfull suite runs. The affected-module labels on Buildkite steps
are\nalways applied regardless, since `--affected-modules` is
passed\nunconditionally and `--selective-testing` is a separate
flag.\n\n\n\n<img width=\"1833\" height=\"665\" alt=\"Screenshot
2026-04-07 at 14 17
28\"\nsrc=\"https://github.com/user-attachments/assets/918ad0f8-28c4-471d-93fe-577264cf85f1\"\n/>\n\n\n**Note**:
The `scout:run-all-tests` label enforces the full test matrix\nwhile
still showing which modules were
affected.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"b3c331750e67222a9c0f48f15f2b829d9c71e28e"}},{"branch":"9.3","label":"v9.3.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/262959","number":262959,"state":"MERGED","mergeCommit":{"sha":"454c1dff03f1fd64247bff4e457bd6b332914018","message":"[9.3]
Scout: enable Selective testing in Pull Requests (#261510)
(#262959)\n\n# Backport\n\nThis will backport the following commits from
`main` to `9.3`:\n- [Scout: enable Selective testing in Pull
Requests\n(#261510)](https://github.com/elastic/kibana/pull/261510)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by:
Dzmitry Lemechko
<dzmitry.lemechko@elastic.co>"}},{"url":"https://github.com/elastic/kibana/pull/263016","number":263016,"branch":"8.19","state":"OPEN"}]}]
BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants