Skip to content

feat(ci): add path-based conditional CI and update copilot instructions#594

Merged
imran-siddique merged 5 commits intomicrosoft:mainfrom
imran-siddique:feat/ci-optimization-and-instructions
Mar 30, 2026
Merged

feat(ci): add path-based conditional CI and update copilot instructions#594
imran-siddique merged 5 commits intomicrosoft:mainfrom
imran-siddique:feat/ci-optimization-and-instructions

Conversation

@imran-siddique
Copy link
Copy Markdown
Member

No description provided.

CI Optimization:
- Add dorny/paths-filter to ci.yml to detect which areas changed
- Python lint/test/security: only run when packages/*/src changes
- .NET test: only run when agent-governance-dotnet/ changes
- TS tests: only run when TS/copilot files change
- Integration tests: only on integration package changes
- Workflow security audit: only on .github/workflows/ changes
- Dependency scan: always runs (security gate)
- ClusterFuzzLite: add path filter for packages/*/src + fuzz/
- Security scan: add path filter for packages/ + scripts/

This means docs-only PRs skip all builds/tests, and language-specific
changes only trigger their relevant test suites.

Copilot Instructions:
- Add PR Merge Workflow section (update branch -> approve workflows ->
  approve PR -> auto-merge -> move to next)
- Add CI Optimization section documenting path filter behavior
- Expand registered packages list (PyPI, npm, crates.io)
- Add MIT license header requirement as check microsoft#8
- Add Docker image pinning rule
- Add Rust unwrap() rule
- Add per-language header format examples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Agent: code-reviewer

Review Summary

This pull request introduces path-based conditional execution for CI workflows, which is a significant improvement for optimizing CI/CD pipelines. It ensures that only relevant jobs run based on the files modified in a pull request. Additionally, it updates the Copilot instructions to include detailed guidelines for PR merging, security checks, and CI optimization.

Below is a detailed review of the changes, categorized into critical issues, warnings, and suggestions.


🔴 CRITICAL

  1. SHA-Pinning for GitHub Actions

    • The workflows use SHA-pinned versions for GitHub Actions (actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 and dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36), which is good. However, these SHAs should be verified against the official repositories to ensure they correspond to the intended versions. This is critical to prevent supply chain attacks.

    Action: Verify the SHAs against the official repositories and document the verification process in the repository.

  2. Dependency Confusion Scan

    • The dependency confusion scan in dependency-scan and workflow-security jobs is a critical security measure. However, the scan logic for pip install commands in notebooks (dependency-scan job) does not account for multi-line pip install commands or commands with additional flags (e.g., pip install package-name --upgrade). This could lead to false negatives.

    Action: Update the dependency-scan job to handle multi-line pip install commands and additional flags. Consider using a Python script with regex patterns to parse and validate all pip install commands more robustly.

  3. Hardcoded Secrets

    • While the PR does not introduce any hardcoded secrets, the updated Copilot instructions should explicitly mention scanning for secrets in all files, including YAML workflows, scripts, and configuration files.

    Action: Update the Copilot instructions to include scanning for hardcoded secrets in YAML workflows, scripts, and configuration files.


🟡 WARNING

  1. Backward Compatibility

    • The introduction of path-based conditional execution in CI workflows could potentially lead to scenarios where certain tests or checks are inadvertently skipped due to misconfigured path filters. This could result in undetected issues being merged into the main branch.

    Action: Add a fallback mechanism to ensure that all jobs run if the path filters fail or are misconfigured. For example, include a condition that runs all jobs if no paths match.

  2. Potential Breaking Changes in CI Behavior

    • The ci.yml workflow now relies on the changes job to determine which jobs to run. If the changes job fails or is misconfigured, it could block the execution of all dependent jobs.

    Action: Add error handling or fallback logic to ensure that the CI pipeline does not fail entirely if the changes job encounters an issue.


💡 SUGGESTIONS

  1. Improve Path Filters

    • The path filters in the ci.yml workflow are well-defined, but they could be further refined to avoid unnecessary job executions. For example:
      • The python filter includes scripts/**, but this could trigger Python-related jobs even for non-Python scripts. Consider narrowing this filter to scripts/**/*.py.
      • The docs-only filter includes docs/** and notebooks/**, but it might be worth excluding files like README.md that are unlikely to affect the documentation build.

    Action: Refine the path filters to minimize unnecessary job executions.

  2. Test Coverage for Path-Based CI

    • The new path-based CI logic introduces complexity that should be tested to ensure correctness. For example, you could add a test workflow that simulates changes to different file paths and verifies that the correct jobs are triggered.

    Action: Create a test workflow to validate the behavior of the path-based CI logic.

  3. Documentation Improvements

    • The updated Copilot instructions are comprehensive, but they could benefit from additional clarity:
      • Include an example of a properly formatted MIT license header for each supported language.
      • Provide a brief explanation of why path-based CI is being introduced and how it improves efficiency.

    Action: Update the Copilot instructions with examples of license headers and a rationale for path-based CI.

  4. Thread Safety in Concurrent Execution

    • The CI pipeline now includes multiple jobs that may run concurrently. While this is not directly related to the application code, it is worth ensuring that any shared resources (e.g., test databases, temporary files) are properly isolated to avoid race conditions.

    Action: Review the test and build scripts to ensure they are thread-safe and do not rely on shared state.

  5. Security Rules for Docker Images

    • The Copilot instructions mention that Docker images must use pinned version tags or SHA digests. However, there is no automated check for this in the CI workflows.

    Action: Add a job to the CI pipeline that scans for unpinned Docker image tags in YAML workflows and other configuration files.


Summary of Actions

Critical

  • Verify SHA-pinning for GitHub Actions and document the process.
  • Enhance the dependency confusion scan to handle multi-line pip install commands and additional flags.
  • Update Copilot instructions to include scanning for hardcoded secrets in YAML workflows, scripts, and configuration files.

Warning

  • Add a fallback mechanism to ensure all jobs run if path filters fail.
  • Add error handling or fallback logic for the changes job in the CI workflow.

Suggestions

  • Refine path filters to minimize unnecessary job executions.
  • Create a test workflow to validate path-based CI logic.
  • Update Copilot instructions with examples of license headers and a rationale for path-based CI.
  • Review test and build scripts for thread safety in concurrent execution.
  • Add a CI job to scan for unpinned Docker image tags.

This PR is a significant improvement for CI/CD efficiency, but addressing the critical issues and warnings is necessary to ensure security and robustness.

@github-actions github-actions bot added size/M Medium PR (< 200 lines) documentation Improvements or additions to documentation ci/cd CI/CD and workflows labels Mar 30, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

🤖 AI Agent: security-scanner — Security Review of PR: feat(ci): add path-based conditional CI and update copilot instructions

Security Review of PR: feat(ci): add path-based conditional CI and update copilot instructions

This PR introduces path-based conditional CI workflows and updates the Copilot instructions. Below is a security analysis of the changes made in this PR:


Findings

1. Prompt Injection Defense Bypass

  • Risk: None identified in this PR. The changes are limited to CI/CD workflows and documentation updates, which do not directly interact with user-provided inputs or prompts.
  • Rating: 🔵 LOW
  • Recommendation: No action needed.

2. Policy Engine Circumvention

  • Risk: None identified in this PR. The changes do not affect the policy engine or its enforcement mechanisms.
  • Rating: 🔵 LOW
  • Recommendation: No action needed.

3. Trust Chain Weaknesses

  • Risk: The GitHub Actions used in the workflows (e.g., actions/checkout and dorny/paths-filter) are pinned to specific SHA hashes, which mitigates the risk of supply chain attacks via compromised or malicious updates. However, the safety tool used in the security job is not pinned to a specific version, which could lead to potential issues if a malicious or vulnerable version is published.
  • Rating: 🟡 MEDIUM
  • Attack Vector: If the safety tool is updated with malicious code or a vulnerability, it could compromise the CI pipeline.
  • Recommendation: Pin the safety tool to a specific version in the security job. For example:
    pip install safety==1.10.3

4. Credential Exposure

  • Risk: None identified in this PR. No credentials or secrets are exposed in the changes.
  • Rating: 🔵 LOW
  • Recommendation: No action needed.

5. Sandbox Escape

  • Risk: None identified in this PR. The changes do not introduce any new code execution paths or sandboxing mechanisms.
  • Rating: 🔵 LOW
  • Recommendation: No action needed.

6. Deserialization Attacks

  • Risk: None identified in this PR. The changes do not involve deserialization of untrusted data.
  • Rating: 🔵 LOW
  • Recommendation: No action needed.

7. Race Conditions

  • Risk: The ci-complete job introduced in the ci.yml workflow uses the needs.*.result context to check the results of all dependent jobs. However, if any job is skipped or fails to report its status, it could lead to an incomplete or incorrect evaluation of the CI pipeline's overall status.
  • Rating: 🟠 HIGH
  • Attack Vector: An attacker could potentially exploit this by introducing a malicious job that manipulates the needs.*.result context or by causing a legitimate job to fail silently, leading to an incorrect "success" status for the pipeline.
  • Recommendation: Use a more robust mechanism to ensure that all required jobs have completed successfully. For example, explicitly list all required jobs in the needs array of the ci-complete job and verify their statuses individually.

8. Supply Chain

  • Risk: The dependency-scan job checks for dependency confusion vulnerabilities by verifying that all pip install commands reference registered PyPI packages. However, the list of registered package names is hardcoded in the copilot-instructions.md file, which could lead to inconsistencies or omissions over time.
  • Rating: 🟡 MEDIUM
  • Attack Vector: If a new package is added to the project but not included in the hardcoded list, it could be vulnerable to dependency confusion attacks.
  • Recommendation: Automate the generation of the list of registered package names by querying the package registry (e.g., PyPI) or maintaining a centralized, version-controlled source of truth.

Summary of Findings

Category Risk Details Recommendation
Prompt Injection Defense 🔵 LOW No prompt injection risks identified. No action needed.
Policy Engine Circumvention 🔵 LOW No policy circumvention risks identified. No action needed.
Trust Chain Weaknesses 🟡 MEDIUM safety tool not pinned to a specific version. Pin safety to a specific version.
Credential Exposure 🔵 LOW No credentials or secrets exposed. No action needed.
Sandbox Escape 🔵 LOW No sandboxing mechanisms affected. No action needed.
Deserialization Attacks 🔵 LOW No deserialization risks identified. No action needed.
Race Conditions 🟠 HIGH Potential for incorrect CI status due to skipped or failed jobs. Explicitly verify statuses of all required jobs in the ci-complete job.
Supply Chain 🟡 MEDIUM Hardcoded list of registered package names may become outdated. Automate the generation of the list of registered package names.

Overall Rating: 🟡 MEDIUM

While the changes improve CI/CD efficiency, there are some areas that could introduce potential risks, particularly around race conditions and supply chain security. Addressing these issues will strengthen the security posture of the repository.

Let me know if you need further clarification or assistance!

@imran-siddique imran-siddique enabled auto-merge (squash) March 30, 2026 18:21
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Agent: code-reviewer

Review Summary

This PR introduces path-based conditional CI workflows to optimize the execution of jobs based on the files modified in a pull request. It also updates the Copilot instructions to reflect these changes and adds additional guidelines for PR reviews and security practices. The changes are well-structured and aim to improve CI efficiency and documentation clarity. However, there are some areas that require attention to ensure correctness, security, and maintainability.


🔴 CRITICAL

  1. SHA-Pinning for GitHub Actions

    • The actions/checkout and dorny/paths-filter actions are SHA-pinned, which is good. However, the comments for these pins should include the version number for clarity and maintainability. For example:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
      Ensure that the version number is accurate and matches the SHA.
  2. Dependency Confusion Scan

    • The dependency confusion scan in dependency-scan is a critical security gate. However, it currently only checks pip install commands in notebooks. This leaves other files (e.g., Dockerfile, requirements.txt, or scripts) unverified. Extend the scan to cover all files where dependencies might be declared.
  3. Workflow Security Audit

    • The workflow-security job checks for unpinned actions but does not enforce the use of permissions: in workflows. Add a step to verify that all workflows define permissions: explicitly, as per the security rules in copilot-instructions.md.
  4. Hardcoded Secrets

    • Ensure that no secrets (e.g., API keys, tokens, or credentials) are hardcoded in the workflows or scripts. While this is mentioned in the copilot-instructions.md, it is not explicitly enforced in the CI workflows. Consider adding a step to scan for hardcoded secrets using tools like truffleHog or git-secrets.

🟡 WARNING

  1. Potential Breaking Changes

    • The introduction of path-based conditional CI may inadvertently skip necessary tests if the path filters are not comprehensive. For example:
      • Changes to shared configurations or dependencies (e.g., pyproject.toml, requirements/**) may not trigger all relevant jobs.
      • Changes to scripts/** may affect multiple packages but are not explicitly linked to any specific job.
    • Suggestion: Add a fallback job that runs all tests if no specific path filter matches or if critical shared files are modified.
  2. Backward Compatibility

    • The updated copilot-instructions.md introduces new mandatory steps (e.g., enabling auto-merge, updating branches). Ensure that these changes are communicated to all contributors to avoid confusion or delays in the PR process.

💡 SUGGESTIONS

  1. Documentation Improvements

    • The updated copilot-instructions.md is clear and well-structured. However, consider adding a table of contents for easier navigation, especially as the document grows.
    • Add a note explaining the rationale behind path-based CI optimizations, e.g., reducing CI runtime and resource usage.
  2. Testing Path-Based CI

    • Ensure that the path-based CI logic is thoroughly tested. For example:
      • Verify that changes to packages/agent-os/** trigger the Python lint and test jobs.
      • Verify that changes to .github/workflows/** trigger the workflow-security job.
      • Verify that changes to docs/** or notebooks/** skip all build/test jobs.
  3. Error Handling in CI Jobs

    • In the security job, the safety check command is allowed to fail silently with a warning. Consider failing the job explicitly if safety check encounters issues, as this is a security-critical step.
  4. Consistency in Path Filters

    • Ensure consistency in path filters across workflows. For example:
      • The ci.yml file includes requirements/** in the python filter, but this is not included in the cflite.yml or security-scan.yml workflows. Align these filters to avoid discrepancies.
  5. Future Consideration: Monorepo Dependency Graph

    • As this is a monorepo, consider implementing a dependency graph to determine the impact of changes more accurately. Tools like Nx or custom scripts can help identify which packages are affected by a change, even if the change is in a shared dependency or configuration file.

Conclusion

This PR introduces valuable optimizations and documentation updates, but there are critical security and potential backward compatibility concerns that need to be addressed before merging. Once the identified issues are resolved, the changes will significantly improve the efficiency and security posture of the CI/CD pipeline.

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Agent: code-reviewer

Review Summary

This pull request introduces path-based conditional CI workflows to optimize the CI/CD pipeline by running only relevant jobs based on the files modified in a pull request. It also updates the copilot-instructions.md file to include new guidelines for PR merging and CI optimizations. The changes are well-structured and aim to improve the efficiency of the CI/CD process.

Below is the detailed review of the changes:


🔴 CRITICAL

  1. SHA Pinning for GitHub Actions

    • The actions/checkout action is pinned to a specific SHA (11bd71901bbe5b1630ceea73d27597364c9af683), which is good practice. However, the dorny/paths-filter action is also used but is not pinned to a specific SHA. Instead, it is pinned to a version (v3.0.2). This is a security risk because versions can be updated or compromised.
      • Action: Replace dorny/paths-filter@v3.0.2 with a specific SHA. For example, dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36.
  2. Dependency Confusion Scan

    • The dependency confusion scan in dependency-scan is implemented as a Python script. However, it does not verify the integrity of the packages (e.g., by checking hashes or signatures). This could allow malicious actors to inject compromised packages with the same name.
      • Action: Enhance the dependency scan to verify package integrity using hashes or signatures (e.g., pip hash or pip download --no-deps --no-binary :all:).

🟡 WARNING

  1. Potential Breaking Changes in CI/CD

    • The introduction of path-based conditional workflows may inadvertently skip critical tests if the path filters are not comprehensive. For example:
      • Changes to shared configuration files (e.g., pyproject.toml, requirements/) might affect multiple packages but may not trigger all relevant jobs.
      • Changes to non-code files (e.g., .md files) might still require full CI runs in some cases (e.g., if they affect documentation tests or examples).
      • Action: Add a fallback job that runs all tests if no specific path filter matches. This ensures that critical tests are not skipped unintentionally.
  2. Backward Compatibility of CI/CD

    • The ci.yml workflow now relies on the changes job to determine which jobs to run. If the changes job fails for any reason (e.g., an issue with the paths-filter action), all dependent jobs will be skipped.
      • Action: Add a fallback mechanism to ensure that critical jobs (e.g., dependency-scan, workflow-security) run even if the changes job fails.

💡 SUGGESTIONS

  1. Documentation Improvements

    • The updated copilot-instructions.md file is clear and detailed. However, consider adding a note about the importance of reviewing path filters in CI workflows when adding new files or directories to the repository. This will help prevent future issues where changes are not tested due to missing path filters.
  2. Test Coverage for Path Filters

    • To ensure the correctness of the path-based conditional workflows, consider adding a test or validation step that verifies the path filters are working as expected. For example, you could use a script to simulate changes in various paths and ensure the correct jobs are triggered.
  3. Workflow Security Audit

    • The workflow-security job checks for unpinned actions but does not explicitly check for other common security issues, such as the use of untrusted third-party actions or insecure permissions. Consider enhancing this job to include additional checks, such as:
      • Verifying that all actions come from trusted sources (e.g., GitHub or a specific organization).
      • Ensuring that workflows do not grant excessive permissions (e.g., contents: write).
  4. CI/CD Optimization

    • While the path-based conditional workflows improve efficiency, consider adding a periodic full CI run (e.g., weekly) to catch issues that might be missed due to path filters. This can be implemented using a schedule trigger.
  5. Explicit Documentation for Path Filters

    • The path filters in the ci.yml workflow are well-defined, but their purpose and scope are not documented in the copilot-instructions.md file. Consider adding a section explaining the path filters and how they map to specific jobs.

General Observations

  • The changes are well-structured and follow best practices for CI/CD optimization.
  • The documentation updates are clear and provide valuable guidance for contributors.
  • The use of dorny/paths-filter is a good choice for implementing path-based conditional workflows, but the lack of SHA pinning is a critical issue.
  • The dependency confusion scan and workflow security audit could be further enhanced to improve security.

Summary of Actions

  1. 🔴 Critical: Pin the dorny/paths-filter action to a specific SHA.
  2. 🔴 Critical: Enhance the dependency confusion scan to verify package integrity.
  3. 🟡 Warning: Add a fallback job to run all tests if no path filter matches.
  4. 🟡 Warning: Add a fallback mechanism for critical jobs if the changes job fails.
  5. 💡 Suggestion: Add documentation about reviewing path filters when adding new files or directories.
  6. 💡 Suggestion: Add a test or validation step for path filters.
  7. 💡 Suggestion: Enhance the workflow-security job to include additional security checks.
  8. 💡 Suggestion: Add a periodic full CI run to catch issues missed by path filters.
  9. 💡 Suggestion: Document the purpose and scope of path filters in copilot-instructions.md.

Let me know if you need further clarification or assistance!

@imran-siddique imran-siddique disabled auto-merge March 30, 2026 21:41
@imran-siddique imran-siddique enabled auto-merge (squash) March 30, 2026 21:42
Add streamlit, plotly, networkx, aioredis, pypdf, spacy, pyproject,
ESRP to .cspell-repo-terms.txt to fix spell-check CI on updated
copilot-instructions.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@imran-siddique imran-siddique force-pushed the feat/ci-optimization-and-instructions branch from 4078bef to 7a62b34 Compare March 30, 2026 21:44
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Agent: code-reviewer

Review Summary

This PR introduces path-based conditional CI workflows to optimize the CI/CD pipeline by running only relevant jobs based on file changes. It also updates the Copilot instructions to reflect the new CI process and adds more details for PR reviews and security checks. Overall, this PR improves the efficiency of the CI pipeline and enhances documentation for contributors.


🔴 CRITICAL

  1. SHA Pinning for GitHub Actions:

    • The workflows use SHA-pinned actions, which is good, but the actions/checkout action is pinned to a specific SHA (11bd71901bbe5b1630ceea73d27597364c9af683). This SHA corresponds to version v4.2.2, but there is no comment indicating the version. This could lead to confusion and potential security risks if the SHA is updated in the future without proper tracking.
      • Action: Add a comment next to the SHA pin, e.g., # v4.2.2, to indicate the version being used. This will make it easier to track and update in the future.
  2. Dependency Confusion Scan:

    • The dependency confusion scan in dependency-scan only checks pip install commands in notebooks. However, other files (e.g., Dockerfile, requirements.txt, or scripts) could also contain pip install commands that need to be scanned.
      • Action: Extend the dependency scan to include all files in the repository, not just notebooks.

🟡 WARNING

  1. Backward Compatibility:
    • The introduction of path-based conditional workflows changes the behavior of the CI pipeline. While this is an optimization, it could lead to unintended consequences if certain changes are missed due to incorrect path filters.
      • Action: Carefully review and test the dorny/paths-filter configuration to ensure all relevant paths are covered. For example:
        • Are there any Python files outside packages/ that should trigger Python jobs?
        • Are there any .md files in non-standard locations that should trigger the docs-only job?
      • Consider adding a fallback job that runs all tests if no specific paths are matched, to ensure nothing is missed.

💡 SUGGESTIONS

  1. Documentation Improvements:

    • The updated Copilot instructions are clear and detailed, but they could benefit from a table of contents for easier navigation.
      • Action: Add a table of contents to .github/copilot-instructions.md for quick access to sections like "PR Merge Workflow," "PR Review," "Security Rules," etc.
  2. CI Optimization:

    • The test-integrations job runs if either integrations or python files change. This could lead to unnecessary runs if python changes are unrelated to integrations.
      • Action: Split the test-integrations job into two separate jobs: one for integrations changes and another for python changes. This will allow more granular control over which tests are run.
  3. Security Rules:

    • The security rules in .github/copilot-instructions.md are comprehensive, but they could include additional checks for:
      • Action: Add rules for:
        • Ensuring that sensitive data (e.g., secrets) is not logged in CI/CD workflows.
        • Verifying that all external dependencies are scanned for known vulnerabilities (e.g., using safety or npm audit).
  4. Testing Path Filters:

    • The dorny/paths-filter configuration is critical to the success of this PR. However, there is no indication that the path filters have been tested.
      • Action: Add a test workflow or script to validate the paths-filter configuration. This could include running the filter against a set of test PRs with known file changes to ensure the correct jobs are triggered.
  5. Code Comments:

    • The ci.yml file has been significantly updated, but the new sections lack comments explaining their purpose.
      • Action: Add comments to the ci.yml file to explain the purpose of each job and the logic behind the path filters.

Final Assessment

This PR is a well-thought-out improvement to the CI/CD pipeline and documentation. However, the following issues need to be addressed before merging:

  • 🔴 Critical: Add comments for SHA-pinned actions and extend the dependency confusion scan to cover all files.
  • 🟡 Warning: Ensure that the path filters are comprehensive and tested to avoid missing critical jobs.
  • 💡 Suggestions: Improve documentation, refine CI optimization, and add comments to the CI configuration for better maintainability.

Let me know if you need further clarification or assistance!

nandhagopalv19
nandhagopalv19 previously approved these changes Mar 30, 2026
Copy link
Copy Markdown
Collaborator

@nandhagopalv19 nandhagopalv19 left a comment

Choose a reason for hiding this comment

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

Approving the changes

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Agent: code-reviewer

Review Summary

This pull request introduces path-based conditional CI workflows to optimize the execution of CI jobs based on the files modified in a given PR. Additionally, it updates the Copilot instructions to reflect the new CI workflow and includes minor documentation updates. While the changes are generally well-structured and improve the CI/CD pipeline's efficiency, there are a few areas that require attention.


🔴 CRITICAL

  1. SHA-Pinning for GitHub Actions

    • The actions/checkout and dorny/paths-filter actions are pinned to specific SHA hashes. While this is a good practice, the associated version tags (e.g., v4.2.2 for actions/checkout) are included as comments. This could lead to confusion if the SHA and the version tag do not match in the future. Ensure that the SHAs are updated whenever the version tag changes.
    • Action: Regularly verify that the SHAs match the intended version tags. Consider automating this verification using a tool like Dependabot or a custom script.
  2. Dependency Confusion Risk

    • The dependency-scan job checks for unregistered package names in pip install commands. However, this does not cover dependencies declared in pyproject.toml or requirements.txt. This creates a potential attack vector for dependency confusion.
    • Action: Integrate a tool like PyPI audit or Checkmarx SCA to scan pyproject.toml and requirements.txt for unregistered or malicious packages.

🟡 WARNING

  1. Potential Breaking Change in CI Workflow

    • The introduction of path-based filtering in the CI workflows (e.g., if: needs.changes.outputs.python == 'true') could lead to scenarios where certain jobs are unintentionally skipped due to misconfigured or incomplete path filters.
    • Action: Test the path filters thoroughly to ensure that all relevant files are covered. Consider adding a fallback job that runs if no specific path filter matches, to ensure no critical checks are skipped.
  2. Backward Compatibility of CI/CD Behavior

    • The new path-based conditional CI changes the behavior of the pipeline. Previously, all jobs would run for every PR, but now only specific jobs will run based on the modified files. This could lead to unexpected behavior for contributors who are used to the old workflow.
    • Action: Clearly communicate this change to contributors, and ensure that the updated Copilot instructions are prominently visible. Consider adding a note in the PR template to remind contributors about the new behavior.

💡 SUGGESTIONS

  1. Test Coverage for Path-Based Filtering

    • While the path-based filtering is a great optimization, it would be helpful to add a test or validation step to ensure that the filters are working as expected. For example, you could add a job that logs the matched paths and the triggered jobs for each PR.
    • Action: Add a debug step to the changes job to log the matched paths and outputs for verification.
  2. Documentation Enhancements

    • The updated Copilot instructions are clear and detailed, but they could benefit from a table or visual diagram to illustrate the new CI workflow and path-based filtering.
    • Action: Add a diagram or table summarizing the path filters and their corresponding jobs to make the documentation more accessible.
  3. Security Scan Workflow

    • The security-scan.yml workflow now includes path filters for packages/**, scripts/**, and requirements/**. However, it does not include .github/workflows/**, which could contain security-sensitive changes.
    • Action: Add .github/workflows/** to the path filters in security-scan.yml.
  4. License Header Enforcement

    • The Copilot instructions emphasize the importance of MIT license headers in new source files. However, there is no automated check in the CI pipeline to enforce this.
    • Action: Add a CI job to validate the presence of MIT license headers in new or modified source files.
  5. Concurrency and Resource Optimization

    • The current CI workflow runs multiple jobs in parallel, which is efficient but could lead to resource contention in large repositories with many contributors.
    • Action: Consider using the concurrency key in GitHub Actions to limit the number of concurrent runs for certain jobs, especially resource-intensive ones like test and test-dotnet.

Final Assessment

The changes in this PR are well-thought-out and improve the efficiency of the CI/CD pipeline. However, there are critical security concerns related to dependency confusion and SHA-pinning that must be addressed. Additionally, the potential breaking changes in CI behavior should be communicated clearly to contributors. With these adjustments, the PR will be ready for merging.

@imran-siddique imran-siddique disabled auto-merge March 30, 2026 22:19
@imran-siddique imran-siddique enabled auto-merge (squash) March 30, 2026 22:21
@imran-siddique imran-siddique force-pushed the feat/ci-optimization-and-instructions branch from 1c158a1 to a277eeb Compare March 30, 2026 23:11
When path-filters skip jobs (e.g. docs-only PRs skip Python tests),
those jobs report 'skipped' which doesn't satisfy org-level required
status checks. This caused PRs to be stuck with '4 of 5 required
status checks are expected.'

Add ci-complete gate job that:
- Always runs (if: always())
- Depends on all other jobs
- Fails only if any job failed or was cancelled
- Reports success when jobs passed OR were correctly skipped

The org can point required status checks at 'ci-complete' as the
single gate instead of individual job names.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Agent: code-reviewer

Review Summary

This pull request introduces significant changes to the CI/CD pipeline for the microsoft/agent-governance-toolkit repository. The primary focus is on optimizing CI workflows by introducing path-based conditional execution, updating Copilot instructions, and enhancing security and dependency management practices. The changes are well-structured and aim to improve efficiency and maintainability.

Below is a detailed review of the changes, categorized into Critical Issues, Warnings, and Suggestions.


🔴 CRITICAL

  1. SHA-Pinning for GitHub Actions

    • The actions/checkout and dorny/paths-filter actions are SHA-pinned, which is good. However, the # vX.Y.Z comment for the pinned SHA is missing for actions/checkout. This is required as per the updated Copilot instructions.
    • Action: Add the version comment for actions/checkout:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  2. Dependency Confusion Risks

    • The list of registered package names in the Copilot instructions has been updated, but it is unclear if this list is exhaustive. Any missing package names could lead to dependency confusion attacks.
    • Action: Verify that the list of registered package names is complete and includes all internal and external dependencies used in the project.
  3. CI Gate Job Logic

    • The ci-complete job uses toJSON(needs.*.result) to check job statuses. However, this approach could fail silently if a new job is added to the workflow but not included in the needs array.
    • Action: Dynamically generate the needs array or add a validation step to ensure all jobs are accounted for.

🟡 WARNING

  1. Potential Breaking Changes in CI Behavior

    • The introduction of path-based conditional execution may inadvertently skip jobs for certain edge cases (e.g., changes that affect multiple areas but are not explicitly covered by the filters).
    • Action: Test the path filters thoroughly to ensure no critical jobs are skipped unintentionally.
  2. Backward Compatibility of Copilot Instructions

    • The updated Copilot instructions introduce stricter rules (e.g., MIT license headers, SHA-pinning). These changes may conflict with existing practices in the repository.
    • Action: Communicate these changes clearly to all contributors and update any existing PRs to comply with the new rules.

💡 SUGGESTIONS

  1. Enhanced Documentation

    • The updated Copilot instructions are comprehensive but could benefit from examples for common scenarios (e.g., how to handle dependency confusion scans or add new path filters).
    • Action: Add examples or a FAQ section to the Copilot instructions.
  2. Path Filter Optimization

    • The path filters for python, dotnet, typescript, etc., are well-defined but could be further optimized by grouping related paths. For example:
      python:
        - 'packages/**/src/**'
        - 'scripts/**'
        - 'requirements/**'
      This reduces redundancy and makes the filters easier to maintain.
  3. Security Scan Workflow

    • The security-scan.yml workflow now includes path filters, which is a good improvement. However, consider adding a step to validate that all dependencies are pinned to specific versions (e.g., no * or >= in requirements.txt).
    • Action: Add a dependency pinning check to the security-scan.yml workflow.
  4. CI Gate Job Naming

    • The ci-complete job name is somewhat generic. Consider renaming it to something more descriptive, like ci-status-gate, to better reflect its purpose.
    • Action: Rename the job for clarity.
  5. Testing Path-Based CI

    • While the path-based CI optimization is a great addition, it is crucial to test it thoroughly with various PR scenarios (e.g., single-file changes, multi-package changes, etc.) to ensure it behaves as expected.
    • Action: Create a set of test PRs to validate the new CI behavior before merging.
  6. Future Consideration: Workflow Templates

    • As the repository grows, managing multiple workflows with similar structures might become cumbersome. Consider using reusable workflows or templates to reduce duplication and improve maintainability.
    • Action: Explore GitHub Actions reusable workflows to consolidate common logic across workflows.

Summary of Actions

Critical

  • Add version comment for actions/checkout SHA pinning.
  • Verify the completeness of the registered package names list.
  • Ensure all jobs are accounted for in the ci-complete job.

Warning

  • Test path filters to ensure no critical jobs are skipped.
  • Communicate new Copilot instructions to contributors and update existing PRs.

Suggestions

  • Add examples or a FAQ section to Copilot instructions.
  • Optimize path filters for maintainability.
  • Add a dependency pinning check to the security-scan.yml workflow.
  • Rename ci-complete job to a more descriptive name.
  • Test the new path-based CI with various PR scenarios.
  • Consider using reusable workflows for future CI/CD improvements.

Let me know if you need further clarification or assistance!

@imran-siddique imran-siddique disabled auto-merge March 30, 2026 23:20
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Agent: code-reviewer

Review Summary

This pull request introduces path-based conditional CI workflows to optimize the CI/CD pipeline by running only the relevant jobs based on the files changed in a PR. It also updates the GitHub Copilot instructions to reflect the new CI process and includes minor updates to the .cspell-repo-terms.txt file.

The changes are well-structured and aim to improve the efficiency of the CI pipeline while maintaining security and correctness. However, there are a few areas that require attention, including potential security concerns, suggestions for improvement, and a warning about backward compatibility.


🔴 CRITICAL

  1. SHA-Pinning for GitHub Actions

    • The actions/checkout and dorny/paths-filter actions are pinned to specific SHA hashes, which is good practice. However, the # vX.Y.Z comment is missing for actions/checkout. This comment is crucial for maintainability, as it helps developers understand which version the SHA corresponds to.
      • Action: Add the version comment for actions/checkout (e.g., # v4.2.2) to align with the repository's security guidelines.
  2. Dependency Confusion Risk

    • The dependency-scan job checks for unregistered package names in pip install commands, but it does not explicitly verify the integrity of the dependencies (e.g., via hashes or signatures).
      • Action: Consider integrating a tool like pip-audit or enabling hash verification for pip install commands to ensure the integrity of dependencies.

🟡 WARNING

  1. Backward Compatibility
    • The introduction of path-based conditional CI workflows changes the behavior of the CI pipeline. If any paths are misconfigured or omitted, critical tests or checks could be skipped unintentionally, leading to potential regressions or security vulnerabilities.
      • Action: Thoroughly test the path filters to ensure that all relevant files trigger the appropriate jobs. Consider adding a fallback mechanism to run all tests if the path filters fail.

💡 SUGGESTIONS

  1. CI Gate Job

    • The ci-complete job is a good addition to handle skipped jobs and ensure a single required status check. However, the grep command used to check for failures or cancellations could be replaced with a more robust approach, such as parsing the JSON output of needs.*.result using jq.

      • Suggestion: Use jq to parse the JSON output for better reliability and readability.
      results='${{ toJSON(needs.*.result) }}'
      echo "Job results: $results"
      if echo "$results" | jq -e 'to_entries[] | select(.value == "failure" or .value == "cancelled")'; then
          echo "One or more required jobs failed or were cancelled"
          exit 1
      fi
      echo "All jobs passed or were correctly skipped"
  2. Documentation Updates

    • The updated Copilot instructions are clear and comprehensive. However, consider adding a note about the importance of testing the path filters when adding new files or directories to the repository.
      • Suggestion: Add a section in the Copilot instructions to remind contributors to update and test the path filters when introducing new files or directories.
  3. Path Filters

    • The path filters in the ci.yml and security-scan.yml workflows are comprehensive, but they may not cover all possible scenarios (e.g., changes to shared configuration files or scripts).
      • Suggestion: Add a catch-all filter for any changes outside the specified paths to trigger a minimal set of jobs (e.g., linting and security checks) to ensure no critical updates are missed.
  4. Security Scan Workflow

    • The security-scan.yml workflow uses path filters to trigger scans only when certain files are changed. While this is efficient, it may miss security issues introduced by indirect changes (e.g., changes in shared dependencies or configurations).
      • Suggestion: Consider running a periodic full security scan (e.g., weekly or monthly) to catch issues that might not be detected by path-based triggers.
  5. License Headers

    • The Copilot instructions emphasize adding MIT license headers to new files. However, there is no automated check in the CI pipeline to enforce this.
      • Suggestion: Add a CI job to verify that all source files contain the required MIT license header.
  6. Concurrency and Thread Safety

    • While this PR does not directly introduce concurrency-related changes, the path-based conditional workflows could lead to scenarios where multiple jobs run concurrently on shared resources (e.g., integration tests).
      • Suggestion: Ensure that shared resources are properly isolated or synchronized to avoid race conditions during concurrent job execution.

Final Assessment

The PR is a well-thought-out improvement to the CI/CD pipeline, focusing on efficiency and maintainability. However, the identified critical issues and warnings should be addressed to ensure the robustness and security of the pipeline. Additionally, the suggested improvements can further enhance the quality and reliability of the repository.

  • Approval Status: 🚧 Changes Required
  • Priority: High (due to critical security concerns and potential backward compatibility issues)

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Agent: code-reviewer

Review Summary

This PR introduces path-based conditional CI workflows to optimize the CI/CD pipeline by running only relevant jobs based on file changes. It also updates the Copilot instructions to reflect these changes and improve clarity. The changes are well-structured and aim to improve efficiency while maintaining security and correctness.

Below is a detailed review of the changes, focusing on the specified areas of concern.


🔴 CRITICAL Issues

  1. SHA-Pinning for GitHub Actions

    • The actions/checkout and dorny/paths-filter actions are SHA-pinned, which is good. However, the ClusterFuzzLite workflow (cflite.yml) does not include SHA-pinning for its actions. This violates the security rule mentioned in the updated copilot-instructions.md.
    • Action: Ensure all GitHub Actions in cflite.yml are SHA-pinned.
  2. Dependency Confusion in dependency-scan Job

    • The dependency-scan job in ci.yml uses a Python script to check for unregistered packages but does not validate against the expanded list of registered PyPI, npm, and crates.io packages added in copilot-instructions.md.
    • Action: Update the dependency-scan job to validate against the full list of registered packages, including local-only PyPI packages and common dependencies.

🟡 WARNING: Potential Breaking Changes

  1. Path-Based CI Skipping

    • The introduction of path-based conditional CI may inadvertently skip jobs for PRs that modify files outside the specified paths. For example, changes to configuration files or scripts outside the specified paths might not trigger the necessary jobs.
    • Action: Add a fallback mechanism or a manual override to ensure critical jobs can still run when needed.
  2. CI Gate Job (ci-complete)

    • The ci-complete job enforces a single required status check but relies on all skipped jobs reporting "skipped" correctly. If any job fails to report its status, this could block PR merges.
    • Action: Test the behavior of the ci-complete job extensively to ensure it handles edge cases like missing job statuses.

💡 Suggestions for Improvement

  1. Documentation Clarity

    • The updated copilot-instructions.md is clear and comprehensive, but the section on "CI Optimization" could benefit from an explicit example of how path filters work (e.g., a table mapping file paths to triggered jobs).
    • Action: Add an example or table to illustrate the path-based filtering logic.
  2. Test Coverage for Path Filters

    • The path filters in ci.yml and other workflows are well-defined, but there is no automated test to validate their correctness.
    • Action: Add a test script or workflow to verify that changes to specific paths trigger the expected jobs.
  3. Centralized Configuration for Registered Packages

    • The list of registered packages appears in both copilot-instructions.md and the dependency-scan job. This duplication increases the risk of inconsistencies.
    • Action: Move the list of registered packages to a centralized configuration file (e.g., registered-packages.json) and reference it in both places.
  4. Error Reporting in ci-complete

    • The ci-complete job currently outputs job results as a JSON string. This could be difficult to parse in case of errors.
    • Action: Enhance the error reporting to provide a more human-readable summary of failed or skipped jobs.
  5. ClusterFuzzLite Path Filters

    • The cflite.yml workflow uses path filters for packages/*/src/** and fuzz/**. However, it is unclear if this covers all relevant files for fuzz testing.
    • Action: Review the path filters to ensure they include all files that could impact fuzz testing.
  6. Consistency in Workflow Naming

    • The job names in ci.yml are inconsistent in their use of capitalization and formatting (e.g., test-dotnet vs. test-integrations-ts).
    • Action: Standardize job names for consistency and readability.

Final Assessment

This PR introduces valuable optimizations and updates to the CI/CD pipeline and documentation. However, there are critical security issues and potential breaking changes that need to be addressed before merging. Once resolved, these changes will significantly enhance the efficiency and maintainability of the repository's workflows.

Priority Actions:

  1. Address SHA-pinning in cflite.yml.
  2. Update the dependency-scan job to validate against the full list of registered packages.
  3. Add a fallback mechanism for path-based CI skipping.
  4. Test the ci-complete job for edge cases.

Let me know if you need further clarification or assistance!

@imran-siddique imran-siddique merged commit 5364b5f into microsoft:main Mar 30, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd CI/CD and workflows documentation Improvements or additions to documentation size/M Medium PR (< 200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants