|
| 1 | +# @kbn/workflows-examples-cli |
| 2 | + |
| 3 | +Static validation for workflow YAML examples. |
| 4 | + |
| 5 | +Used in CI to detect when YAML parsing or basic schema constraints break the |
| 6 | +example workflows published in |
| 7 | +[`elastic/workflows`](https://github.com/elastic/workflows). Runs without |
| 8 | +booting Kibana. |
| 9 | + |
| 10 | +## Usage |
| 11 | + |
| 12 | +``` |
| 13 | +node scripts/validate_workflow_examples --dir <path-to-examples> [--junit-out <path>] |
| 14 | +``` |
| 15 | + |
| 16 | +- `--dir` (required): directory of `.yml`/`.yaml` files. Walked recursively; |
| 17 | + dotfiles and hidden directories are skipped. |
| 18 | +- `--junit-out` (optional): writes a JUnit XML report for Buildkite to pick up. |
| 19 | + When set, the CLI also fails if no YAML examples are found (CI misconfiguration guard). |
| 20 | + |
| 21 | +Exits non-zero on any failure. |
| 22 | + |
| 23 | +## What this CLI validates |
| 24 | + |
| 25 | +- YAML syntax errors (parser-level failures). |
| 26 | +- Examples exceeding `MAX_WORKFLOW_YAML_LENGTH`. |
| 27 | +- Structural schema regressions on the workflow definition — top-level `name`, |
| 28 | + `enabled`, `triggers`, `inputs`, `settings`, `steps` — using a schema built |
| 29 | + from: |
| 30 | + - **Static connectors** via `getAllStaticConnectors()` in `@kbn/workflows` |
| 31 | + (Elasticsearch/Kibana built-ins, stack connectors such as `slack`, `http`, |
| 32 | + `inference`, `jira`, etc., and connector-specs sub-actions such as |
| 33 | + `virustotal.*`). |
| 34 | + - **Extension steps** registered by platform plugins (`data.*`, `ai.*`, |
| 35 | + `cases.*`, `search.rerank`, `ai.agent`) via |
| 36 | + `getExtensionStepContracts()`. |
| 37 | + - Validation runs with `loose: true` (same mode as the YAML editor). |
| 38 | + |
| 39 | +## What this CLI does **not** validate strictly |
| 40 | + |
| 41 | +- **`security.*` steps** (`security.buildAlertEntityGraph`, |
| 42 | + `security.renderAlertNarrative`): included as permissive `z.any()` placeholders |
| 43 | + because the security solution plugin is not importable from this platform |
| 44 | + package. Param drift for those step types is not caught here. |
| 45 | +- **Dynamic connectors** resolved at runtime from the Actions client (only the |
| 46 | + static catalog is available offline). |
| 47 | +- **End-to-end execution** against a running Kibana stack. |
| 48 | + |
| 49 | +This CLI is a **merge gate** on workflow-schema changes: it catches the cheapest |
| 50 | +classes of regression without booting Kibana. It does not replace functional or |
| 51 | +API integration tests. |
| 52 | + |
| 53 | +## CI behavior |
| 54 | + |
| 55 | +On-merge validation (`.buildkite/scripts/steps/workflows/validate_examples.sh`) |
| 56 | +runs only when the merge commit touches workflow schema paths, unless |
| 57 | +`WORKFLOWS_VALIDATE_FORCE=true`. Upstream examples are cloned from the |
| 58 | +`main` branch of [`elastic/workflows`](https://github.com/elastic/workflows) |
| 59 | +at run time (no pinned ref). |
| 60 | + |
| 61 | +## Programmatic use |
| 62 | + |
| 63 | +```ts |
| 64 | +import { |
| 65 | + runValidation, |
| 66 | + validateExampleYaml, |
| 67 | + buildWorkflowSchema, |
| 68 | +} from '@kbn/workflows-examples-cli'; |
| 69 | +``` |
0 commit comments