Skip to content

Add change detection logic to 'unit-tests.yaml' workflow to skip unit tests when unaffected #11282

@brooke-hamilton

Description

@brooke-hamilton

Area for Improvement

The 'unit-tests.yaml' workflow does not have logic to detect when code changes do not affect unit tests. Currently, unit tests always run even if the files changed in a PR do not require those tests.

Observed behavior

Functional test workflows (noncloud and cloud) use a change detection mechanism to skip running tests if only docs, markdown, or unrelated files are changed. The unit test workflow is missing this, leading to unnecessary test runs.

Desired behavior

Implement the same change detection logic in 'unit-tests.yaml' as seen in 'functional-test-cloud.yaml' and 'functional-test-noncloud.yaml'. The unit tests should only run on PRs if at least one changed file falls outside the excluded patterns (documentation, markdown, etc.), or otherwise be skipped.

Proposed Fix

  1. Review the change detection logic used in functional tests:
    • Both 'functional-test-noncloud.yaml' and 'functional-test-cloud.yaml' call the '.github/workflows/__changes.yml' reusable workflow for change detection. See:
    • These workflows use the output 'only_changed' from the reusable 'changes' job to conditionally execute tests.
  2. Apply the same pattern to 'unit-tests.yaml':
    • Add a job to call '.github/workflows/__changes.yml' for change detection.
    • Use the output (e.g., needs.changes.outputs.only_changed) to conditionally run or skip the unit tests job.
    • Ensure patterns match those for functional tests (docs, markdown, etc.).
  3. Confirm the workflow handles PRs, pushes, and other triggers as needed.

Links to reference logic:

rad Version

edge

Operating system

No response

Additional context

No response

Metadata

Metadata

Labels

maintenanceIssue is a non-user-facing task like updating tests, improving automation, etc..

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions