Skip to content

Commit 972eb95

Browse files
feat(ci): add path-based conditional CI and update copilot instructions
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 #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>
1 parent fa4176d commit 972eb95

File tree

4 files changed

+114
-4
lines changed

4 files changed

+114
-4
lines changed

.github/copilot-instructions.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,74 @@
11
# Copilot Instructions for agent-governance-toolkit
22

3+
## PR Merge Workflow
4+
5+
When merging PRs, follow this sequence for EACH PR (do not batch):
6+
7+
1. **Review** — run all mandatory checks below
8+
2. **Update branch** — merge latest main into the PR branch (`update-branch` API or UI button)
9+
3. **Approve pending workflows** — fork PRs may have `pull_request_target` workflows waiting for maintainer approval; approve them in the Actions tab
10+
4. **Approve the PR** — submit an approving review
11+
5. **Enable auto-merge** — set squash auto-merge so it merges once CI passes
12+
6. **Move to next PR** — don't wait; auto-merge handles the rest
13+
14+
This prevents PRs from stacking in the merge queue behind stale branches.
15+
316
## PR Review — Mandatory Before Merge
417

518
NEVER merge a PR without thorough code review. CI passing is NOT sufficient.
619

720
Before approving or merging ANY PR, verify ALL of the following:
821

922
1. **Read the actual diff** — don't rely on PR description alone
10-
2. **Dependency confusion scan** — check every `pip install`, `npm install` command in docs/code for unregistered package names. The registered names are: `agent-os-kernel`, `agentmesh-platform`, `agent-hypervisor`, `agentmesh-runtime`, `agent-sre`, `agent-governance-toolkit`, `agentmesh-lightning`, `agentmesh-marketplace`
23+
2. **Dependency confusion scan** — check every `pip install`, `npm install`, `cargo add` command in docs/code for unregistered package names. The registered names are:
24+
- **PyPI:** `agent-os-kernel`, `agentmesh-platform`, `agent-hypervisor`, `agentmesh-runtime`, `agent-sre`, `agent-governance-toolkit`, `agentmesh-lightning`, `agentmesh-marketplace`
25+
- **PyPI (local-only, not published):** `agent-governance-dotnet`, `agentmesh-integrations`, `agent-primitives`, `emk`
26+
- **PyPI (common deps):** `streamlit`, `plotly`, `pandas`, `networkx`, `aioredis`, `pypdf`, `spacy`, `slack-sdk`, `docker`, `langchain-openai`
27+
- **npm:** `@microsoft/agent-os-kernel`
28+
- **crates.io:** `agentmesh`
1129
3. **New Python modules** — verify `__init__.py` exists in any new package directory
1230
4. **Dependencies declared** — any new `import` must have the package in `pyproject.toml` dependencies (not just transitive)
1331
5. **No hardcoded secrets** — no API keys, tokens, passwords, connection strings in code or docs
1432
6. **No plaintext config in pipelines** — ESRP Client IDs, Key Vault names, cert names go in secrets, not YAML
1533
7. **Verify PR has actual changes** — check `additions > 0` before merging (empty PRs have happened)
34+
8. **MIT license headers** — every new source file (`.py`, `.ts`, `.js`, `.rs`, `.go`, `.cs`, `.sh`) must have the license header. This is the #1 most common review finding.
1635

1736
## Security Rules
1837

1938
- All `pip install` commands must reference registered PyPI packages
2039
- All security patterns must be in YAML config, not hardcoded
21-
- All GitHub Actions must be SHA-pinned
40+
- All GitHub Actions must be SHA-pinned (use `action@<sha> # vX.Y.Z` format, never bare tags like `@v46`)
2241
- All workflows must define `permissions:`
2342
- Use `yaml.safe_load()`, never `yaml.load()`
2443
- No `pickle.loads`, `eval()`, `exec()`, `shell=True` in production code
2544
- No `innerHTML` — use safe DOM APIs
45+
- No `unwrap()` in non-test Rust code paths (use `?` or explicit error handling)
46+
- Docker images must use pinned version tags or SHA digests (never `:latest`)
2647

2748
## Code Style
2849

2950
- Use conventional commits (feat:, fix:, docs:, etc.)
3051
- Run tests before committing
31-
- MIT license headers on all source files
52+
- MIT license headers on all source files:
53+
- Python/Shell: `# Copyright (c) Microsoft Corporation.\n# Licensed under the MIT License.`
54+
- TypeScript/JavaScript/Rust/C#/Go: `// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.`
3255
- Author: Microsoft Corporation, email: agentgovtoolkit@microsoft.com
3356
- All packages prefixed with "Public Preview" in descriptions
3457

58+
## CI Optimization
59+
60+
CI workflows use path filters so only relevant checks run per PR:
61+
- **Python changes** (`packages/agent-mesh/`, `packages/agent-os/`, etc.) → lint + test for that package only
62+
- **TypeScript changes** (`sdks/typescript/`, `extensions/copilot/`) → TS lint + test only
63+
- **Rust changes** (`sdks/rust/`) → cargo test only
64+
- **.NET changes** (`agent-governance-dotnet/`) → dotnet test only
65+
- **Go changes** (`sdks/go/`) → go test only
66+
- **Docs-only changes** (`.md`, `notebooks/`) → link check only, skip all builds/tests
67+
- **Workflow changes** (`.github/workflows/`) → workflow-security audit only
68+
3569
## Publishing
3670

37-
- PyPI/npm/NuGet publishing goes through ESRP Release (ADO pipelines), NOT GitHub Actions
71+
- PyPI/npm/NuGet/crates.io publishing goes through ESRP Release (ADO pipelines), NOT GitHub Actions
3872
- All ESRP config values must be in pipeline secrets, never plaintext in YAML
3973
- Package names must NOT start with `microsoft` or `windows` (reserved by Python team)
4074
- npm packages use `@microsoft` scope only

.github/workflows/cflite.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ name: ClusterFuzzLite
33
on:
44
push:
55
branches: [main]
6+
paths:
7+
- 'packages/*/src/**'
8+
- 'fuzz/**'
69
pull_request:
710
branches: [main]
11+
paths:
12+
- 'packages/*/src/**'
13+
- 'fuzz/**'
814
schedule:
915
- cron: "0 6 * * 0" # Weekly batch fuzzing
1016

.github/workflows/ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,50 @@ permissions:
1010
contents: read
1111

1212
jobs:
13+
# ── Path detection — determines which jobs to run ─────────────────────
14+
changes:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
python: ${{ steps.filter.outputs.python }}
18+
dotnet: ${{ steps.filter.outputs.dotnet }}
19+
typescript: ${{ steps.filter.outputs.typescript }}
20+
integrations: ${{ steps.filter.outputs.integrations }}
21+
workflows: ${{ steps.filter.outputs.workflows }}
22+
docs-only: ${{ steps.filter.outputs.docs-only }}
23+
steps:
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
26+
id: filter
27+
with:
28+
filters: |
29+
python:
30+
- 'packages/agent-os/**'
31+
- 'packages/agent-mesh/**'
32+
- 'packages/agent-hypervisor/**'
33+
- 'packages/agent-sre/**'
34+
- 'packages/agent-compliance/**'
35+
- 'scripts/**'
36+
- 'requirements/**'
37+
dotnet:
38+
- 'packages/agent-governance-dotnet/**'
39+
typescript:
40+
- 'packages/agent-mesh/sdks/typescript/**'
41+
- 'packages/agent-os/extensions/**'
42+
- 'packages/agentmesh-integrations/mastra-agentmesh/**'
43+
- 'packages/agentmesh-integrations/copilot-governance/**'
44+
integrations:
45+
- 'packages/agentmesh-integrations/**'
46+
workflows:
47+
- '.github/workflows/**'
48+
docs-only:
49+
- '**/*.md'
50+
- 'notebooks/**'
51+
- 'docs/**'
52+
53+
# ── Python lint + test (only when Python files change) ────────────────
1354
lint:
55+
needs: changes
56+
if: needs.changes.outputs.python == 'true'
1457
runs-on: ubuntu-latest
1558
strategy:
1659
matrix:
@@ -25,7 +68,10 @@ jobs:
2568
- name: Lint ${{ matrix.package }}
2669
run: ruff check packages/${{ matrix.package }}/src/ --select E,F,W --ignore E501
2770

71+
# ── Python test (only when Python files change) ───────────────────────
2872
test:
73+
needs: changes
74+
if: needs.changes.outputs.python == 'true'
2975
runs-on: ubuntu-latest
3076
strategy:
3177
fail-fast: false
@@ -46,7 +92,10 @@ jobs:
4692
working-directory: packages/${{ matrix.package }}
4793
run: pytest tests/ -q --tb=short
4894

95+
# ── Python dependency safety (only when Python files change) ──────────
4996
security:
97+
needs: changes
98+
if: needs.changes.outputs.python == 'true'
5099
runs-on: ubuntu-latest
51100
steps:
52101
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -68,7 +117,10 @@ jobs:
68117
done
69118
safety check 2>/dev/null || echo "Safety check completed with warnings"
70119
120+
# ── .NET build + test (only when C# files change) ────────────────────
71121
test-dotnet:
122+
needs: changes
123+
if: needs.changes.outputs.dotnet == 'true'
72124
runs-on: ubuntu-latest
73125
steps:
74126
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -82,7 +134,10 @@ jobs:
82134
working-directory: packages/agent-governance-dotnet
83135
run: dotnet test --configuration Release --verbosity normal --no-build
84136

137+
# ── Integration tests (only when integration packages change) ────────
85138
test-integrations:
139+
needs: changes
140+
if: needs.changes.outputs.integrations == 'true' || needs.changes.outputs.python == 'true'
86141
runs-on: ubuntu-latest
87142
strategy:
88143
fail-fast: false
@@ -153,6 +208,7 @@ jobs:
153208
echo "No tests/ directory — smoke import passed"
154209
fi
155210
211+
# ── Dependency confusion scan (always runs — security gate) ──────────
156212
dependency-scan:
157213
runs-on: ubuntu-latest
158214
steps:
@@ -204,7 +260,10 @@ jobs:
204260
print(f'OK: All notebook pip install packages are registered')
205261
"
206262
263+
# ── Workflow security audit (only when workflows change) ─────────────
207264
workflow-security:
265+
needs: changes
266+
if: needs.changes.outputs.workflows == 'true'
208267
runs-on: ubuntu-latest
209268
steps:
210269
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -226,7 +285,10 @@ jobs:
226285
done
227286
if [ $UNSAFE -eq 1 ]; then exit 1; fi
228287
288+
# ── TypeScript integration tests (only when TS files change) ─────────
229289
test-integrations-ts:
290+
needs: changes
291+
if: needs.changes.outputs.typescript == 'true'
230292
runs-on: ubuntu-latest
231293
steps:
232294
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

.github/workflows/security-scan.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ name: Security Scan
33
on:
44
push:
55
branches: [main]
6+
paths:
7+
- 'packages/**'
8+
- 'scripts/**'
9+
- 'requirements/**'
610
pull_request:
711
branches: [main]
12+
paths:
13+
- 'packages/**'
14+
- 'scripts/**'
15+
- 'requirements/**'
816

917
permissions:
1018
contents: read

0 commit comments

Comments
 (0)