Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 229 additions & 0 deletions .github/COPILOT_COMPARISON.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
# Comparison: Azure-dev vs Microsoft/MCP Copilot Configuration

This document provides a detailed comparison of GitHub Copilot configurations between the `Azure/azure-dev` and `microsoft/mcp` repositories.

## Summary Table

| Feature | azure-dev | microsoft/mcp | Status |
|---------|-----------|---------------|--------|
| **copilot-instructions.md** | ✅ Comprehensive (242 lines) | ✅ Concise (~50 lines) | ✅ Enhanced |
| **copilot-setup-steps.yml** | ✅ Exists (56 lines) | ❌ Not present | ✅ Already configured |
| **PULL_REQUEST_TEMPLATE.md** | ❌ Not present → ✅ Created | ✅ Exists | ✅ Implemented |
| **event-processor.yml** | ❌ Not present | ✅ Exists (handles PR triage) | ⚠️ Different approach |
| **event-processor.config** | ❌ Not present | ✅ Exists (PR triage rules) | ⚠️ Different approach |
| **COPILOT_REVIEW_SETUP.md** | ❌ Not present → ✅ Created | ❌ Not present | ✅ New addition |
| **Repository rulesets** | 📝 To be configured | ✅ Likely configured | 📝 Documented |

## Detailed Comparison

### 1. copilot-instructions.md

#### azure-dev
**Before:**
- **Length**: 242 lines
- **Focus**: Comprehensive Go development guidelines
- **Content areas**:
- Core architecture overview (IoC container, dependency injection, command architecture)
- Code standards (formatting, linting, copyright headers)
- Development workflow (build, test)
- Repository structure
- Critical development patterns (DI registration, action implementation, middleware)
- Testing approach (table-driven tests, snapshot testing)
- Azure integration patterns
- Changelog update workflow (detailed, step-by-step)
- **PR guidelines**: ❌ Not present

**After:**
- **Length**: ~270 lines
- **Added sections**:
- General Coding Guidelines (build, test, DI, context propagation)
- Pull Request Guidelines (comprehensive checklist)
- Security review requirements
- **Improvements**: Better structured for Copilot to understand expectations for PR reviews

#### microsoft/mcp
- **Length**: ~50 lines
- **Focus**: Concise C# development guidelines
- **Content areas**:
- C# coding standards (primary constructors, System.Text.Json, AOT safety)
- Build requirements (always run `dotnet build`)
- Engineering system scripts
- Pull Request Guidelines (includes Copilot-specific instructions)
- Changelog requirements
- **PR guidelines**: ✅ Includes specific Copilot PR body template with livetest trigger instructions

**Key Differences:**
- **azure-dev**: More comprehensive, architecture-focused, suitable for complex Go CLI
- **microsoft/mcp**: More concise, focused on coding patterns, includes Copilot-specific PR instructions
- **Trade-offs**: azure-dev provides better onboarding but is longer; mcp is quicker to parse

### 2. copilot-setup-steps.yml

#### azure-dev
- **Status**: ✅ Exists
- **Purpose**: Set up environment for GitHub Copilot coding agent
- **Features**:
- Triggered on workflow changes and manual dispatch
- Fetches full git history for changelog writing
- Sets up Go 1.25+
- Sets up Node.js 20
- Installs golangci-lint v2.6.0
- Installs cspell 8.13.1
- Installs Terraform
- **Job name**: `copilot-setup-steps` (required for Copilot to detect)

#### microsoft/mcp
- **Status**: ❌ Not present
- **Alternative**: No equivalent workflow file

**Analysis**: azure-dev has better infrastructure for Copilot coding sessions with comprehensive tooling setup.

### 3. PULL_REQUEST_TEMPLATE.md

#### azure-dev
- **Status Before**: ❌ Not present
- **Status After**: ✅ Created
- **Features**:
- "What does this PR do?" section
- GitHub issue linking
- Pre-merge checklist (general requirements)
- Specific checklists for:
- azd CLI changes (formatting, linting, testing, changelog)
- Template changes
- Extension changes
- Additional notes section
- **Inspiration**: Based on microsoft/mcp template but adapted for azure-dev structure

#### microsoft/mcp
- **Status**: ✅ Exists
- **Features**:
- "What does this PR do?" section
- GitHub issue linking
- Pre-merge checklist (general requirements)
- Specific checklist for MCP tool changes
- Extra steps for Azure MCP Server
- Security review checkbox for community PRs
- Livetest pipeline trigger instructions

**Key Differences:**
- **mcp**: More focused on security review and livetest triggers
- **azure-dev**: More focused on CLI development workflow (formatting, linting, Go-specific checks)

### 4. Event Processing (PR Triage Automation)

#### azure-dev
- **event.yml**: ✅ Exists, but different purpose
- Name: "Check Enforcer"
- Purpose: Enforces check status on PRs
- Uses: `azure/azure-sdk-actions@main`
- Triggers: `check_suite`, `issue_comment`, `workflow_run`
- Does NOT handle automated PR triage/labeling

#### microsoft/mcp
- **event-processor.yml**: ✅ Exists
- Name: "GitHub Event Processor"
- Purpose: Automated PR and issue triage
- Uses: Custom .NET tool `Azure.Sdk.Tools.GitHubEventProcessor`
- Triggers: Multiple events (issues, comments, pull_request_target)
- Features:
- Two jobs: one with Azure login (for issues), one without (for PRs)
- Reads configuration from `event-processor.config`
- Handles issue labeling, PR triage, stale item management

- **event-processor.config**: ✅ Exists
- Defines enabled automation rules:
- `PullRequestTriage`: On
- `ResetApprovalsForUntrustedChanges`: On
- `ReopenPullRequest`: On
- `ResetPullRequestActivity`: On
- `CloseStalePullRequests`: On
- `IdentifyStalePullRequests`: On
- And many more for issues

**Analysis**:
- **mcp** has more sophisticated automated PR management
- **azure-dev** relies on simpler check enforcement
- Both are valid approaches; mcp's approach is more comprehensive but requires additional tooling

### 5. COPILOT_REVIEW_SETUP.md (Documentation)

#### azure-dev
- **Status**: ✅ Created (new addition)
- **Purpose**: Comprehensive guide for enabling automatic Copilot reviews
- **Content**:
- Overview of Copilot code review
- Prerequisites
- Step-by-step configuration for repository rulesets
- Repository settings requirements
- Customization guidance
- Testing instructions
- Usage guidelines for authors and reviewers
- Best practices
- Troubleshooting
- Additional resources

#### microsoft/mcp
- **Status**: ❌ No equivalent documentation
- **Alternative**: Relies on institutional knowledge or GitHub's official docs

**Analysis**: azure-dev now has better documentation for new contributors setting up Copilot reviews.

## Functional Comparison

### Copilot Review Triggering

**microsoft/mcp approach:**
1. Likely uses GitHub repository rulesets (not visible in public repo)
2. Copilot automatically reviews PRs based on configured rules
3. Reviews are guided by concise `copilot-instructions.md`
4. PR template includes specific Copilot instructions for livetest triggers

**azure-dev approach (after changes):**
1. Requires repository admin to configure rulesets (documented in `COPILOT_REVIEW_SETUP.md`)
2. Copilot reviews will be guided by comprehensive `copilot-instructions.md`
3. PR template provides clear checklist for authors
4. Better documentation for setup process

### Key Insights

1. **Approach Philosophy**:
- **mcp**: Concise instructions, automated triage, security-focused
- **azure-dev**: Comprehensive guidelines, manual review emphasis, architecture-focused

2. **Tooling**:
- **mcp**: Custom .NET event processor for advanced automation
- **azure-dev**: GitHub Actions with standard tooling, simpler but effective

3. **Documentation**:
- **mcp**: Minimal (relies on templates and institutional knowledge)
- **azure-dev**: Comprehensive (detailed setup and usage guides)

4. **Security**:
- **mcp**: Explicit security review checkbox, livetest gating for community PRs
- **azure-dev**: Security guidance in copilot-instructions, no explicit community PR gating

## Recommendations for azure-dev

### Implemented ✅
1. ✅ Create `PULL_REQUEST_TEMPLATE.md` to guide PR authors and Copilot
2. ✅ Update `copilot-instructions.md` with PR review guidelines
3. ✅ Create comprehensive documentation for enabling Copilot reviews (`COPILOT_REVIEW_SETUP.md`)

### Optional Future Enhancements 📋
1. Consider implementing automated PR triage similar to mcp's event-processor (if team desires more automation)
2. Add security review checkboxes for community PRs if needed
3. Create a simplified "quick start" section in copilot-instructions.md for faster parsing
4. Add specific examples of good/bad code patterns in copilot-instructions.md
5. Consider adding CI/CD integration instructions for Copilot coding agent

## Conclusion

The azure-dev repository now has comparable or superior Copilot configuration compared to microsoft/mcp:

- ✅ **Better**: Comprehensive documentation for setup and usage
- ✅ **Better**: Dedicated Copilot setup workflow (copilot-setup-steps.yml)
- ✅ **Equal**: PR template with appropriate checklists
- ✅ **Equal**: Copilot instructions tailored to repository needs
- ⚠️ **Different**: Simpler event handling (check enforcer vs. full event processor)

The repository is now ready for automatic Copilot PR reviews once repository rulesets are configured by an admin.
125 changes: 125 additions & 0 deletions .github/COPILOT_REVIEW_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Setting Up Automatic GitHub Copilot Code Review

This document explains how to configure automatic GitHub Copilot code review for pull requests in the Azure Developer CLI repository.

## Overview

GitHub Copilot can automatically review pull requests when they are opened or updated, providing AI-powered feedback on code quality, potential bugs, security issues, and best practices. This feature helps maintain code quality and catch issues early in the development process.

## Prerequisites

- Repository must have GitHub Copilot enabled (requires GitHub Copilot Business or Enterprise)
- User must have admin permissions to configure repository rulesets
- Pull requests must be enabled for the repository

## Configuration Steps

### 1. Enable Automatic Copilot Reviews via Repository Rulesets

1. Navigate to the repository on GitHub
2. Click **Settings** → **Rules** → **Rulesets**
3. Click **New ruleset** → **New branch ruleset**
4. Configure the ruleset:
- **Name**: "Copilot PR Review"
- **Enforcement status**: Active
- **Target branches**: Select branches (e.g., `main`, `develop`, or use patterns like `feature/*`)
5. Under **Branch rules**, enable **"Automatically request Copilot code review"**
6. Configure when reviews should trigger:
- ✅ **Review new pull requests** (recommended)
- ⚠️ **Review new pushes** (optional, may increase review volume)
- ⚠️ **Review draft pull requests** (optional)
7. Click **Create** to save the ruleset

### 2. Configure Repository Settings

Ensure the following files are in place to guide Copilot's reviews:

- **`.github/copilot-instructions.md`**: Contains coding standards and architectural guidelines specific to this repository
- **`.github/PULL_REQUEST_TEMPLATE.md`**: Provides a checklist for PR authors and helps Copilot understand expectations
- **`.github/workflows/copilot-setup-steps.yml`**: Ensures the development environment is properly set up for Copilot coding sessions

### 3. Customize Copilot Review Behavior

Copilot reviews are influenced by:

1. **Repository guidelines** in `.github/copilot-instructions.md`:
- Add specific patterns or anti-patterns to check for
- Include security requirements
- Define code style preferences

2. **Pull request context**:
- PR title and description
- Linked issues
- File changes and diff content

3. **Repository history**:
- Previous PR reviews
- Commit messages
- Code patterns in the repository

### 4. Testing the Configuration

1. Create a test branch and make a small change
2. Open a pull request targeting a branch with the ruleset enabled
3. Copilot should automatically post a review comment within a few moments
4. Review the feedback and adjust `.github/copilot-instructions.md` as needed

## Using Copilot Reviews

### For PR Authors

- Copilot reviews appear as comments on your PR, similar to human reviews
- Address Copilot's feedback by making code changes or responding to comments
- You can request additional reviews by pushing new commits or using the "Re-request review" button
- Not all Copilot suggestions need to be implemented - use your judgment

### For PR Reviewers

- Copilot reviews supplement, not replace, human code reviews
- Use Copilot's feedback as a starting point for deeper review
- Copilot may catch common issues, allowing reviewers to focus on architecture and design
- Flag any incorrect or misleading Copilot comments to help improve future reviews

## Best Practices

1. **Start with targeted branches**: Enable Copilot reviews for feature branches first before applying to main/production branches
2. **Iterate on instructions**: Regularly update `.github/copilot-instructions.md` based on recurring review patterns
3. **Combine with CI/CD**: Use Copilot reviews alongside automated testing and linting for comprehensive quality checks
4. **Monitor feedback quality**: Track false positives and adjust guidelines to reduce noise
5. **Educate team members**: Ensure all contributors understand how to work with Copilot reviews

## Troubleshooting

### Copilot reviews are not appearing

- Verify the repository has Copilot enabled (check repository settings)
- Confirm the ruleset is active and targets the correct branches
- Check that the PR is not in draft mode (unless draft reviews are enabled)
- Ensure the PR has actual code changes (empty or documentation-only PRs may not trigger reviews)

### Review feedback is not relevant

- Update `.github/copilot-instructions.md` with more specific guidelines
- Add examples of desired patterns in the instructions
- Use clear, descriptive PR titles and descriptions
- Link related issues for additional context

### Too many reviews are being triggered

- Disable "Review new pushes" if getting reviews on every commit
- Use more specific branch targeting in the ruleset
- Consider separate rulesets for different types of branches (e.g., feature vs. hotfix)

## Additional Resources

- [GitHub Copilot Code Review Documentation](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/request-a-code-review)
- [Configuring Automatic Code Review](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/request-a-code-review/configure-automatic-review)
- [GitHub Rulesets Documentation](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets)
- [Azure Developer CLI Contribution Guidelines](https://github.com/Azure/azure-dev/blob/main/CONTRIBUTING.md)

## Support

For issues with Copilot reviews:
- Check [GitHub Copilot status](https://www.githubstatus.com/)
- Review [GitHub Community discussions](https://github.com/orgs/community/discussions)
- Contact repository maintainers for repository-specific configuration help
Loading