Skip to the content.

GitHub Action for Adaptive Tests

ℹ️ Status: The GitHub Action ships as a lightweight composite action. It installs the npm package and runs the same commands you use locally. Use the manual setup if you need tighter control over the workflow.

Action Status

Quick Start

Use this manual setup (recommended):

steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-node@v5
    with:
      node-version: '20'
      cache: 'npm'
  - run: npm ci
  - run: npm run test:adaptive

The action automatically detects your project type and runs adaptive tests.

Installation

name: Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v5
        with:
          node-version: '20'
          cache: 'npm'
      - run: npm ci
      - run: npm run test:adaptive

Option 2: With Coverage Reporting

steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-node@v5
    with:
      node-version: '20'
      cache: 'npm'
  - run: npm ci
  - run: npm run test:adaptive -- --coverage
  - uses: actions/upload-artifact@v3
    with:
      name: coverage-report
      path: coverage/

Option 3: Multiple Commands

steps:
  # Run tests
  - uses: adaptive-tests-action/adaptive-tests@v1
    with:
      command: test

  # Validate discoveries
  - uses: adaptive-tests-action/adaptive-tests@v1
    with:
      command: validate

  # Auto-scaffold new tests
  - uses: adaptive-tests-action/adaptive-tests@v1
    with:
      command: scaffold

Features

πŸ§ͺ Test Running

Automatically runs all adaptive tests and reports results:

- uses: adaptive-tests-action/adaptive-tests@v1
  with:
    command: test
    test-pattern: '**/*.adaptive.test.js'
    coverage: true

πŸ” Component Discovery

Discover components in your codebase:

- uses: adaptive-tests-action/adaptive-tests@v1
  with:
    command: discover
    language: javascript
    discovery-signature: |
      {
        "type": "component",
        "framework": "react"
      }

πŸ—οΈ Test Scaffolding

Automatically create tests for new components:

- uses: adaptive-tests-action/adaptive-tests@v1
  with:
    command: scaffold
    language: typescript

βœ… Discovery Validation

Ensure all discovered components still exist:

- uses: adaptive-tests-action/adaptive-tests@v1
  with:
    command: validate
    fail-on-missing: true

Configuration

Inputs

Input Description Default Required
command Command to run (test, discover, scaffold, validate) test No
working-directory Working directory . No
config-file Path to config file adaptive-tests.config.js No
test-pattern Test file pattern **/*.adaptive.test.js No
coverage Generate coverage report false No
fail-on-missing Fail if components missing true No
language Language for discovery javascript No
node-version Node.js version 18 No
cache Cache node_modules true No

Outputs

Output Description
test-results Test results in JSON format
coverage-report Path to coverage report
discovered-components List of discovered components

Examples

React Application

name: React Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: adaptive-tests-action/adaptive-tests@v1
        with:
          test-pattern: 'src/**/*.adaptive.test.{js,jsx}'
          coverage: true

Python Project

name: Python Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - uses: adaptive-tests-action/adaptive-tests@v1
        with:
          language: python
          test-pattern: 'tests/**/test_*.py'

Monorepo

name: Monorepo Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        package:
          - packages/frontend
          - packages/backend
          - packages/shared

    steps:
      - uses: actions/checkout@v4

      - uses: adaptive-tests-action/adaptive-tests@v1
        with:
          working-directory: $
          coverage: true

Pull Request Comments

The action automatically comments on pull requests with test results:

- uses: adaptive-tests-action/adaptive-tests@v1
  with:
    command: test
    coverage: true
  # Results automatically posted to PR!

Example comment:

πŸ§ͺ Adaptive Tests Results

Status: βœ… Passed Total Tests: 42 Passed: 42 Failed: 0 Duration: 1,234ms

Advanced Usage

Matrix Testing

Test across multiple Node versions:

strategy:
  matrix:
    node-version: [16, 18, 20]

steps:
  - uses: adaptive-tests-action/adaptive-tests@v1
    with:
      node-version: $

Conditional Scaffolding

Only scaffold on PRs:

- uses: adaptive-tests-action/adaptive-tests@v1
  if: github.event_name == 'pull_request'
  with:
    command: scaffold

Custom Install Command

Use yarn or pnpm:

- uses: adaptive-tests-action/adaptive-tests@v1
  with:
    install-command: yarn install --frozen-lockfile

Discovery with Custom Signature

- uses: adaptive-tests-action/adaptive-tests@v1
  with:
    command: discover
    discovery-signature: |
      {
        "type": "service",
        "patterns": ["@Injectable", "@Service"],
        "methods": ["findAll", "findOne"]
      }

Comparison with Traditional Test Actions

Feature Adaptive Tests Action Jest Action Mocha Action
Survives refactoring βœ… ❌ ❌
Auto-discovery βœ… ❌ ❌
Multi-language βœ… ❌ ❌
Zero config βœ… ❌ ❌
PR comments βœ… ⚠️ ⚠️
Coverage βœ… βœ… βœ…

Troubleshooting

Action fails with β€œadaptive-tests not found”

The action automatically installs adaptive-tests if not present. If this fails:

- run: npm install adaptive-tests --save-dev
- uses: adaptive-tests-action/adaptive-tests@v1

Tests pass locally but fail in CI

Check that your discovery signatures match the CI environment:

- uses: adaptive-tests-action/adaptive-tests@v1
  with:
    command: validate
    fail-on-missing: false  # Set to false for debugging

Coverage reports not generated

Ensure coverage is enabled:

- uses: adaptive-tests-action/adaptive-tests@v1
  with:
    command: test
    coverage: true

Migration from Existing CI

From Jest

# Before (Jest)
- run: npm test

# After (Adaptive Tests)
- uses: adaptive-tests-action/adaptive-tests@v1

From Custom Scripts

# Before
- run: |
    npm install
    npm run test:unit
    npm run test:integration

# After
- uses: adaptive-tests-action/adaptive-tests@v1
  with:
    test-pattern: '**/*.{unit,integration}.test.js'

Contributing

We welcome contributions! See our Contributing Guide.

License

MIT - See LICENSE for details.

Support


Ready to make your tests refactoring-proof? Add the action to your workflow now:

- uses: adaptive-tests-action/adaptive-tests@v1