Skip to content
Closed
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
205 changes: 205 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# Copilot Instructions for GitHub Copilot for Azure

## Repository Overview

This repository contains agent skills for GitHub Copilot's Azure integration. Skills provide specialized capabilities for deployment, validation, diagnostics, and Azure service management.

---

## Directory Structure

```
plugin/
└── skills/
└── <skill-name>/
├── SKILL.md # Skill definition (required)
└── reference/ # Reference guides (optional)

tests/
├── detection/ # App type detection tests (264 tests)
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

Line 19 states there are 264 tests in the detection suite, but the PR description and multiple other places in the documentation (line 96, tests/README.md line 96, tests/detection/README.md line 45) state 181 tests. This inconsistency should be corrected to match the actual test count.

Copilot uses AI. Check for mistakes.
│ ├── __tests__/
│ ├── fixtures/
│ ├── src/
│ └── package.json
├── nodejs-production/ # Node.js production readiness tests (83 tests)
│ ├── __tests__/
│ ├── fixtures/
│ ├── src/
│ └── package.json
├── validation/ # Azure validation tests (165 tests)
│ ├── __tests__/
│ ├── fixtures/
│ ├── src/
│ └── package.json
└── README.md

.github/
├── agents/ # Custom agent definitions
├── workflows/ # CI/CD workflows
└── ISSUE_TEMPLATE/
```

---

## Skill Development

### Skill File Format

Every skill requires a `SKILL.md` file with YAML frontmatter:

```markdown
---
name: skill-name
description: Brief description of what the skill does. Include trigger phrases.
---

## Skill content and instructions...
```

### Key Guidelines

- **Use `azd` for deployments** - Azure Developer CLI, not `az` CLI
Copy link
Member

Choose a reason for hiding this comment

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

We might need stronger guidance to use approved templates documented in skills and MCP tools first. but ok to wait on that.

- **Reference guides** - Place detailed service-specific docs in `reference/` subdirectory
- **MCP tools** - Document which Azure MCP tools the skill uses
- **Detection logic** - If the skill involves app detection, follow patterns in `azure-deploy`

---

## Testing

### Test Structure

Tests are organized into focused suites, each with its own `package.json`:

| Suite | Location | Tests | Purpose |
|-------|----------|-------|---------|
| **Detection** | `tests/detection/` | 264 | App type detection, service selection |
| **Node.js Production** | `tests/nodejs-production/` | 83 | Production readiness validation |
| **Validation** | `tests/validation/` | 165 | Azure resource validation, Bicep, preflight |

### Running Tests

```bash
# Detection tests
cd tests/detection && npm test

# Node.js production tests
cd tests/nodejs-production && npm test

# Validation tests
cd tests/validation && npm test
```

### Test Expectations

- **Detection tests**: 264+ tests, all should pass
- **Node.js production tests**: 83+ tests
- **Validation tests**: 165+ tests

---

## Adding Tests

### ⚠️ IMPORTANT: Only Add Tests to Existing Suites

**DO NOT create new test suites or test areas.** Add tests only to existing coverage areas:

- `tests/__tests__/detection/` - Detection logic tests
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The copilot-instructions.md file references incorrect paths for test directories. Line 107 mentions tests/__tests__/detection/ but the actual structure is tests/detection/__tests__/. This will cause confusion when developers try to follow these instructions.

This issue also appears in the following locations of the same file:

  • line 128
  • line 145
Suggested change
- `tests/__tests__/detection/` - Detection logic tests
- `tests/detection/__tests__/` - Detection logic tests

Copilot uses AI. Check for mistakes.
- `tests/nodejs-production/` - Node.js production readiness
- `tests/validation/` - Azure validation (naming, Bicep, preflight)

### When to Add Tests

Add tests when:
- ✅ A new skill is added that affects detection logic
- ✅ A new function is added to an existing tested module
- ✅ A bug is fixed in tested code
- ✅ A new framework or service needs detection

Do NOT add tests when:
- ❌ The change is in an untested area (e.g., AI skills, database skills)
- ❌ Creating a new test suite would be required
- ❌ The skill doesn't have detection or validation logic

### Adding Detection Tests

1. **Add fixture** (if testing a new project type):
```bash
mkdir -p tests/fixtures/projects/my-new-framework
# Add minimal config files for detection
```

2. **Update expectations** in `tests/fixtures/expectations.json`:
```json
{
"my-new-framework": {
"service": "app-service",
"skill": "azure-deploy",
"confidence": "MEDIUM",
"framework": "MyFramework"
}
}
```

3. **Update detection logic** (if new pattern):
- `tests/src/detection/filePatterns.js` - Add file patterns
- `tests/src/detection/appTypeDetector.js` - Add detection logic

4. **Run tests** to verify:
```bash
cd tests && npm test
```

### Adding Validation Tests

Add to existing test files in `tests/validation/__tests__/`:
- `resourceNameValidator.test.js` - Azure resource naming
- `bicepValidator.test.js` - Bicep file validation
- `preflightValidator.test.js` - Preflight checks
- `integration.test.js` - End-to-end scenarios

### Keeping Tests Updated

When making changes to skills or detection logic:

1. **Check if tests exist** for the affected area
2. **Update tests** to match new behavior
3. **Update expectations.json** if service mappings change
4. **Run all test suites** before committing:
```bash
cd tests && npm test
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

Lines 168-172 show incorrect commands for running test suites. The commands reference just cd tests && npm test but the tests are organized into separate suites (detection, nodejs-production, validation) each with their own package.json. The correct commands should be cd tests/detection && npm test, etc., as shown correctly in lines 82-90.

Suggested change
cd tests && npm test
cd tests/detection && npm test

Copilot uses AI. Check for mistakes.
cd tests/nodejs-production && npm test
cd tests/validation && npm test
```

---

## Skill Routing

All deployment scenarios route to `azure-deploy` skill with reference guides:

| Detection Signal | Service | Reference Guide |
|------------------|---------|-----------------|
| `azure.yaml` | Azure Developer CLI | - |
| `Dockerfile`, `docker-compose.yml` | Container Apps | `reference/container-apps.md` |
| `host.json`, `function.json` | Azure Functions | `reference/functions.md` |
| `staticwebapp.config.json` | Static Web Apps | `reference/static-web-apps.md` |
| Express, Flask, Django, etc. | App Service | `reference/app-service.md` |

---

## Code Style

- **JavaScript/Node.js** - Use ES modules, Jest for testing
- **Markdown** - Use ATX-style headers (`#`), fenced code blocks
- **YAML** - 2-space indentation
- **Avoid over-commenting** - Code should be self-documenting

---

## Pull Requests

- Include test updates when changing detection or validation logic
- Verify all existing tests pass
- Update README files if adding new test coverage
- Reference related issues or PRs in commit messages
90 changes: 90 additions & 0 deletions .github/workflows/test-detection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Detection Tests

on:
push:
branches: [main]
paths:
- 'plugin/skills/azure-deploy/**'
- 'tests/detection/**'
pull_request:
branches: [main]
paths:
- 'plugin/skills/azure-deploy/**'
- 'tests/detection/**'
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20, 22]
Copy link
Member

Choose a reason for hiding this comment

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

at some point later might need to move this to an overall config for actions/workflows so the runners consistently use the rright latest versions.


defaults:
run:
working-directory: tests/detection

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: tests/detection/package-lock.json

- name: Install dependencies
run: npm ci || npm install

- name: Run tests
run: npm test

- name: Run tests with coverage
run: npm run test:coverage

- name: Upload coverage to Codecov
if: matrix.node-version == 20
uses: codecov/codecov-action@v4
with:
directory: tests/detection/coverage
flags: detection
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

lint:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
name: Lint
runs-on: ubuntu-latest

defaults:
run:
working-directory: tests/detection

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: tests/detection/package-lock.json

- name: Install dependencies
run: npm ci || npm install

- name: Check fixture/expectation sync
run: |
node -e "
const { validateFixturesHaveExpectations } = require('./utils/fixture-loader');
const result = validateFixturesHaveExpectations();
if (!result.valid) {
if (result.missing.length) console.error('Missing expectations:', result.missing);
if (result.extra.length) console.error('Extra expectations:', result.extra);
process.exit(1);
}
console.log('✓ All fixtures have expectations');
"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
56 changes: 56 additions & 0 deletions .github/workflows/test-nodejs-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Node.js Production Tests

on:
push:
branches: [main]
paths:
- 'plugin/skills/azure-nodejs-production/**'
- 'tests/nodejs-production/**'
pull_request:
branches: [main]
paths:
- 'plugin/skills/azure-nodejs-production/**'
- 'tests/nodejs-production/**'
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20, 22]

defaults:
run:
working-directory: tests/nodejs-production

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: tests/nodejs-production/package-lock.json

- name: Install dependencies
run: npm ci || npm install

- name: Run tests
run: npm test

- name: Run tests with coverage
run: npm run test:coverage

- name: Upload coverage to Codecov
if: matrix.node-version == 20
uses: codecov/codecov-action@v4
with:
directory: tests/nodejs-production/coverage
flags: nodejs-production
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Loading
Loading