Skip to content

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

generate-test-ci [options]

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:

generate-test-ci

Search only .test.js files:

generate-test-ci -p "test/**/*.test.js" --ignore "**/fixtures/**"

Write to a custom output path:

generate-test-ci -o .github/workflows/ci.yml -p "src/**/*.test.ts" --ignore "**/node_modules/**"

How it works

  1. Collect: All files matching the given glob patterns are collected using the glob library.
  2. Filter: Files not tracked by git are skipped (so untracked files don't end up in the committed action).
  3. Classify: Each file is categorized by extension (.mjstest-esm, .cjstest-cjs, .tsjest directly, others → npm test).
  4. Generate workflow: A GitHub Actions workflow YAML is produced, with each test file as a separate run step.
  5. Write workflow: The workflow YAML is written to the specified output path (default .github/workflows/test.yml).
  6. 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.