Skip to content
Merged
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
43 changes: 43 additions & 0 deletions .github/prompts/analyze-for-docs.prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Analyze Commit and Create Documentation Issue

Analyze commit `{COMMIT_SHA}` in repository `{REPOSITORY}` using the GitHub MCP server.

## Your Task

1. **Examine the commit** using MCP to access:
- Commit diff and changed files
- Current documentation structure
- Project context

2. **Decide if documentation is needed** based on these criteria:

### ✅ Document These:
- Public APIs/Interfaces (functions, classes, endpoints)
- Complex logic requiring explanation
- Architectural or workflow changes
- Breaking changes
- New dependencies or integrations
- Security/performance changes
- Database schemas or data models
- Unit tests

### ❌ Skip These:
- Minor refactoring or formatting
- Internal helpers
- Trivial typo fixes
- Code moves without logic changes
- Patch dependency updates
in the current repository
Comment on lines +29 to +30
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

Line 30 contains a fragment "in the current repository" that appears disconnected from the surrounding context. This line should either be removed or integrated into the previous bullet point about patch dependency updates.

Suggested change
- Patch dependency updates
in the current repository
- Patch dependency updates in the current repository

Copilot uses AI. Check for mistakes.
- Add labels: `documentation`, `automated`
3. **If documentation is needed:**
- Use the GitHub MCP server to create a GitHub issue with title: "📚 Documentation needed for commit test"
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The hardcoded issue title "Documentation needed for commit test" should use a dynamic placeholder that reflects the actual commit content, such as "Documentation needed for commit {COMMIT_SHA}" or include a brief description of the changes.

Suggested change
- Use the GitHub MCP server to create a GitHub issue with title: "📚 Documentation needed for commit test"
- Use the GitHub MCP server to create a GitHub issue with title: "📚 Documentation needed for commit {COMMIT_SHA}"

Copilot uses AI. Check for mistakes.
- Use assign_copilot_to_issue tool to assign @copilot to issue.
- In the issue body, explain:
- What changed and why it needs documentation
- Which documentation files should be updated
- Any breaking changes or migration notes needed
- Confirm if all steps succeeded or not.

4. **If documentation is NOT needed:**
- Simply explain why in a brief response (no issue needed)

126 changes: 126 additions & 0 deletions .github/prompts/analyze-for-tests.prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Analyze Commit for Unit Test Coverage

Analyze commit `{COMMIT_SHA}` in repository `{REPOSITORY}` using the GitHub MCP server to determine if unit tests are missing or need to be added.

## Your Task

1. **Examine the commit** using MCP to access:
- Commit diff and all changed files
- Existing test files in the repository
- Project structure and testing patterns

2. **Identify testable code changes** - Look for:
- New functions, methods, or classes
- Modified business logic
- New API endpoints or routes
- Data validation or transformation logic
- Error handling paths
- Edge cases in algorithms

3. **Check for corresponding tests** using these language-agnostic patterns:

### Common Test File Patterns:
| Source File | Expected Test File Patterns |
|-------------|----------------------------|
| `src/foo.ts` | `src/foo.test.ts`, `src/foo.spec.ts`, `test/foo.test.ts`, `tests/foo.test.ts` |
| `src/foo.py` | `src/test_foo.py`, `tests/test_foo.py`, `src/foo_test.py` |
| `src/Foo.java` | `src/FooTest.java`, `test/FooTest.java` |
| `src/foo.go` | `src/foo_test.go` |
| `src/foo.rs` | `src/foo_test.rs`, `tests/foo.rs` |
| `src/foo.rb` | `spec/foo_spec.rb`, `test/foo_test.rb` |
| `src/foo.cs` | `src/FooTests.cs`, `tests/FooTests.cs` |
| `lib/foo.js` | `lib/foo.test.js`, `test/foo.test.js` |

### Common Test Directories:
- `test/`, `tests/`, `spec/`, `__tests__/`
- `src/__tests__/`, `src/test/`
- Language-specific: `pytest/`, `jest/`, `rspec/`

4. **Evaluate test coverage need** based on:

### ✅ Tests Likely Needed:
- New public functions/methods without corresponding test additions
- Complex conditional logic (if/else, switch) added
- New error handling or exception paths
- Data parsing, validation, or transformation
- New API endpoints or route handlers
- Database queries or data access logic
- Security-related code (auth, encryption, sanitization)
- Business rules or domain logic
- Integration points with external services

### ❌ Tests Likely NOT Needed:
- Pure configuration file changes
- Documentation or comment-only changes
- Type definitions or interfaces only
- Simple constant definitions
- Dependency version updates only
- CSS/styling changes only
- Trivial getter/setter additions
- Test file changes themselves (tests testing tests)
- Generated or auto-generated code
- Migration scripts that are run once

5. **Calculate a confidence score** (0-100) for whether tests are needed:
- 80-100: Tests definitely needed - significant untested logic added
- 60-79: Tests recommended - meaningful code without test coverage
- 40-59: Tests optional - minor changes that could use tests
- 0-39: Tests not needed - trivial or already covered

6. **If tests are recommended (score >= 60):**

Create a GitHub issue using MCP with:

**Title:** `🧪 Unit tests needed for: [brief description of changes]`

**Body should include:**
```markdown
## Test Coverage Analysis

**Commit:** {COMMIT_SHA}
**Confidence Score:** [X]/100

### Files Needing Tests

| Source File | Status | Suggested Test File |
|-------------|--------|---------------------|
| `path/to/file.ext` | ⚠️ No tests found | `path/to/file.test.ext` |

### Recommended Test Cases

For each file, list specific functions/methods and suggested test scenarios:

#### `filename.ext`
- [ ] Test `functionName()` - happy path
- [ ] Test `functionName()` - error handling
- [ ] Test `functionName()` - edge cases (null, empty, boundary values)

### Why Tests Are Needed

[Explain the risk of not having tests for this code]

### Testing Hints

- Framework detected: [Jest/Pytest/JUnit/etc. or "Unknown"]
- Existing test patterns: [Describe patterns found in repo]
- Mock/stub suggestions: [If external dependencies need mocking]

---
*Auto-generated by test coverage workflow*
```

- Add labels: `testing`, `automated`, `unit-tests`
- Use assign_copilot_to_issue tool to assign @copilot to the issue

7. **If tests are NOT needed (score < 60):**
- Provide a brief explanation of why tests aren't necessary
- No issue creation needed

## Important Guidelines

- Be language-agnostic - detect the language from file extensions
- Consider the project's existing testing conventions
- Don't flag test files as needing tests
- Consider that some projects use different testing philosophies
- Account for integration tests vs unit tests
- Be specific about WHAT should be tested, not just that tests are needed
27 changes: 27 additions & 0 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Copilot Setup Steps"

# Allows you to test the setup steps from your repository's "Actions" tab
on: workflow_dispatch

jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot
copilot-setup-steps:
runs-on: ubuntu-latest
# Set the permissions to the lowest permissions possible needed for *your steps*. Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
contents: read
# You can define any steps you want, and they will run before the agent starts.
# If you do not check out your code, Copilot will do this for you.
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"

- name: Install JavaScript dependencies
run: npm ci
47 changes: 47 additions & 0 deletions .github/workflows/copilot.generate-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Generate Documentation with Copilot

on:
push:
paths-ignore:
- 'docs/**'
- '**.md'

jobs:
generate-docs:
runs-on: ubuntu-latest
permissions:
contents: read # Required to read repository content and commit diffs
issues: write # Required to create GitHub issues for documentation recommendations

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install GitHub Copilot CLI
env:
GH_TOKEN: ${{ secrets.COPILOT_CLI_TOKEN }}
run: |
curl -fsSL https://gh.io/copilot-install | bash
echo "Installed Copilot CLI version:"
copilot --version

- name: Analyze and delegate to Copilot
env:
GH_TOKEN: ${{ secrets.COPILOT_CLI_TOKEN }}
run: |
echo "Analyzing commit ${{ github.sha }}"
echo "Loading documentation criteria from prompt..."

PROMPT=$(cat .github/prompts/analyze-for-docs.prompt.md)
PROMPT="${PROMPT//\{COMMIT_SHA\}/${{ github.sha }}}"
PROMPT="${PROMPT//\{REPOSITORY\}/${{ github.repository }}}"

echo "Delegating to GitHub Copilot..."
echo "- Copilot will use MCP to examine the commit"
echo "- Copilot will decide if documentation is needed"
echo "- Copilot will create an issue and assign it to itself if needed"
echo ""

copilot -p "$PROMPT" --enable-all-github-mcp-tools --allow-all-tools
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The copilot.generate-docs.yml workflow is missing the --no-ask-user flag that is present in copilot.generate-tests.yml. For consistency in automated workflows, both should include this flag to prevent interactive prompts that could cause the workflow to hang.

Suggested change
copilot -p "$PROMPT" --enable-all-github-mcp-tools --allow-all-tools
copilot -p "$PROMPT" --enable-all-github-mcp-tools --allow-all-tools --no-ask-user

Copilot uses AI. Check for mistakes.
55 changes: 55 additions & 0 deletions .github/workflows/copilot.generate-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Generate Tests with Copilot

on:
push:
paths-ignore:
- 'docs/**'
- '**.md'
- '.github/workflows/**'
- '.gitignore'
- 'LICENSE'
- '*.config.js'
- '*.config.ts'

jobs:
generate-tests:
runs-on: ubuntu-latest
permissions:
contents: read # Required to read repository content and commit diffs
issues: write # Required to create GitHub issues for test coverage recommendations

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install GitHub Copilot CLI
env:
GH_TOKEN: ${{ secrets.COPILOT_CLI_TOKEN }}
run: |
curl -fsSL https://gh.io/copilot-install | bash
echo "Installed Copilot CLI version:"
copilot --version

- name: Analyze and generate tests with Copilot
env:
GH_TOKEN: ${{ secrets.COPILOT_CLI_TOKEN }}
run: |
echo "Analyzing commit ${{ github.sha }} for test coverage..."
echo "Source files changed: ${{ steps.changes.outputs.source_count }}"
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The workflow references steps.changes.outputs.source_count but there is no step with id 'changes' defined in this workflow. This will output an empty value and could cause confusion during debugging.

Copilot uses AI. Check for mistakes.
echo ""

# Load the prompt template
PROMPT=$(cat .github/prompts/analyze-for-tests.prompt.md)
PROMPT="${PROMPT//\{COMMIT_SHA\}/${{ github.sha }}}"
PROMPT="${PROMPT//\{REPOSITORY\}/${{ github.repository }}}"

echo "Delegating to GitHub Copilot for test analysis..."
echo "- Copilot will examine the commit diff"
echo "- Copilot will check for corresponding test files"
echo "- Copilot will assess if new tests are needed"
echo "- Copilot will create an issue if tests are recommended"
echo ""

copilot -p "$PROMPT" --enable-all-github-mcp-tools --allow-all-tools --no-ask-user
Loading
Loading