Skip to content

Comments

Add change detection to unit-tests.yaml to skip tests on doc-only changes#11283

Open
Copilot wants to merge 2 commits intomainfrom
copilot/add-change-detection-logic
Open

Add change detection to unit-tests.yaml to skip tests on doc-only changes#11283
Copilot wants to merge 2 commits intomainfrom
copilot/add-change-detection-logic

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

unit-tests.yaml lacked the change detection logic already present in the functional test workflows, causing unit tests to run unnecessarily on PRs that only touch docs, markdown, or other unrelated files.

Changes

  • Added changes job calling the reusable .github/workflows/__changes.yml workflow — same pattern used by functional-test-noncloud.yaml and functional-test-cloud.yaml
  • Gated unit-tests job on needs.changes.outputs.only_changed != 'true'; the reusable workflow ensures tests still run unconditionally on non-PR events (pushes to main/release/*)
jobs:
  changes:
    name: Changes
    uses: ./.github/workflows/__changes.yml
    permissions:
      contents: read
      pull-requests: read

  unit-tests:
    needs: [changes]
    if: needs.changes.outputs.only_changed != 'true'
    ...

Type of change

  • This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional).

Contributor checklist

  • An overview of proposed schema changes is included in a linked GitHub issue.
    • Yes
    • Not applicable
  • A design document PR is created in the design-notes repository, if new APIs are being introduced.
    • Yes
    • Not applicable
  • The design document has been reviewed and approved by Radius maintainers/approvers.
    • Yes
    • Not applicable
  • A PR for the samples repository is created, if existing samples are affected by the changes in this PR.
    • Yes
    • Not applicable
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
    • Yes
    • Not applicable
  • A PR for the recipes repository is created, if existing recipes are affected by the changes in this PR.
    • Yes
    • Not applicable
Original prompt

This section details on the original issue you should resolve

<issue_title>Add change detection logic to 'unit-tests.yaml' workflow to skip unit tests when unaffected</issue_title>
<issue_description>### 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</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: brooke-hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Copilot AI changed the title [WIP] Add change detection logic to unit-tests.yaml workflow Add change detection to unit-tests.yaml to skip tests on doc-only changes Feb 20, 2026
Copilot AI temporarily deployed to external-contributor-approval February 20, 2026 22:07 Inactive
@brooke-hamilton brooke-hamilton marked this pull request as ready for review February 20, 2026 22:09
@brooke-hamilton brooke-hamilton requested review from a team as code owners February 20, 2026 22:09
Copilot AI review requested due to automatic review settings February 20, 2026 22:09
@radius-functional-tests
Copy link

radius-functional-tests bot commented Feb 20, 2026

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository radius-project/radius
Commit ref c230a2a
Unique ID func9844e9d090
Image tag pr-func9844e9d090
  • gotestsum 1.13.0
  • KinD: v0.29.0
  • Dapr: 1.14.4
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-func9844e9d090
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-func9844e9d090
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-func9844e9d090
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func9844e9d090
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func9844e9d090
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
❌ Test tool installation for corerp-cloud failed. Please check the logs for more details
❌ Failed to install Radius for corerp-cloud functional test. Please check the logs for more details
❌ Test tool installation for ucp-cloud failed. Please check the logs for more details
❌ Failed to install Radius for ucp-cloud functional test. Please check the logs for more details
❌ corerp-cloud functional test failed. Please check the logs for more details
❌ ucp-cloud functional test failed. Please check the logs for more details

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds change detection logic to the unit-tests.yaml workflow to skip unit test execution when only documentation or markdown files are modified in pull requests. The change aligns the unit test workflow with the existing pattern already used by functional test workflows, improving CI efficiency by avoiding unnecessary test runs while ensuring tests always execute on pushes to protected branches.

Changes:

  • Added changes job that calls the reusable __changes.yml workflow to detect if only docs/markdown files changed
  • Modified unit-tests job to depend on changes and conditionally skip when only_changed == 'true'
  • Added appropriate contents: read and pull-requests: read permissions to the changes job

@github-actions
Copy link

Unit Tests

4 783 tests   4 780 ✅  7m 46s ⏱️
  330 suites      3 💤
    1 files        0 ❌

Results for commit c230a2a.

@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.99%. Comparing base (209adb7) to head (c230a2a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11283      +/-   ##
==========================================
+ Coverage   50.98%   50.99%   +0.01%     
==========================================
  Files         679      679              
  Lines       43174    43174              
==========================================
+ Hits        22012    22017       +5     
+ Misses      19040    19036       -4     
+ Partials     2122     2121       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants