Generate Test CI Step¶
Scans the repository for test files using glob patterns and generates GitHub Actions YAML files from JS fixtures:
.github/workflows/test.yml— workflow with individual test steps for each detected file.github/actions/setup-environments/action.yml— composite action from the JS fixture
Untracked (non-git) test files are automatically skipped.
Usage¶
Aliases¶
This command is available under the following binary name:
generate-test-ci(default)
Options¶
| Flag | Type | Description |
|---|---|---|
-p, --pattern |
string[] |
Test file glob pattern(s) to search for (can be repeated; defaults: test/**/*.test.{js,cjs,mjs,ts}, test/**/*.spec.{js,cjs,mjs,ts}, tests/**/*.test.{js,cjs,mjs,ts}, tests/**/*.spec.{js,cjs,mjs,ts}) |
--ignore, --ex |
string[] |
Glob pattern(s) to exclude from results (can be repeated) |
-o, --output |
string |
Output YAML file path (default: .github/workflows/test.yml) |
-h, --help |
boolean |
Show help message |
Examples¶
Generate the default workflow YAML:
Search only .test.js files:
Write to a custom output path:
How it works¶
- Collect: All files matching the given glob patterns are collected using the
globlibrary. - Filter: Files not tracked by git are skipped (so untracked files don't end up in the committed action).
- Classify: Each file is categorized by extension (
.mjs→test-esm,.cjs→test-cjs,.ts→jestdirectly, others →npm test). - Generate workflow: A GitHub Actions workflow YAML is produced, with each test file as a separate
runstep. - Write workflow: The workflow YAML is written to the specified output path (default
.github/workflows/test.yml). - Generate action: The composite action fixture (
ci-yaml-fixtures/setup-environments-data.cjs) is serialized to.github/actions/setup-environments/action.yml, keeping the reusable action in sync with its JS source.
Source¶
See src/github-workflows/generate-test-ci-step-cli.mjs.