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
141 changes: 141 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Code Quality and Coverage

on:
push:
branches: [main, develop]
paths:
- "packages/**"
- "lib/**"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
- "package.json"
- "tsconfig.base.json"
- "eslint.shared.mjs"
- ".github/workflows/code-quality.yml"
pull_request:
branches: [main, develop]
paths:
- "packages/**"
- "lib/**"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
- "package.json"
- "tsconfig.base.json"
- "eslint.shared.mjs"
- ".github/workflows/code-quality.yml"
workflow_dispatch:

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
NODE_VERSION: "24"
PNPM_VERSION: "11.20.0"

jobs:
package-coverage:
name: Shared Packages Coverage Gate
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Harden runner
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Setup pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
with:
version: ${{ env.PNPM_VERSION }}

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline

# CLI compatibility tests execute lib/bin/generate-manifest.js, so the
# full dependency chain must be built before coverage is collected.
- name: Build shared packages and legacy collection tooling
run: pnpm --filter "@ai-primitives-hub/*" --filter "@prompt-registry/collection-scripts" build

- name: Run package tests with coverage thresholds
run: pnpm --filter "@ai-primitives-hub/*" run test:coverage

- name: Add coverage summary
if: always()
shell: bash
run: |
node <<'NODE'
const fs = require('node:fs');
const packages = ['core', 'infra', 'app', 'cli'];
const rows = [];
for (const name of packages) {
const file = `packages/${name}/coverage/coverage-summary.json`;
if (!fs.existsSync(file)) continue;
const total = JSON.parse(fs.readFileSync(file, 'utf8')).total;
rows.push(`| ${name} | ${total.statements.pct}% | ${total.branches.pct}% | ${total.functions.pct}% | ${total.lines.pct}% |`);
}
const summary = [
'## Shared package coverage',
'',
'| Package | Statements | Branches | Functions | Lines |',
'|---|---:|---:|---:|---:|',
...rows,
'',
'Coverage floors are enforced by each package\'s `vitest.config.mjs`.'
].join('\n');
fs.appendFileSync(process.env.GITHUB_STEP_SUMMARY, `${summary}\n`);
NODE

- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: shared-package-coverage
path: packages/*/coverage
if-no-files-found: warn
retention-days: 14

codeql:
name: CodeQL Analysis
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
security-events: write

steps:
- name: Harden runner
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Initialize CodeQL
uses: github/codeql-action/init@24c7eb380a2dc368f2d129e4c65e51d172983a1e # v4
with:
languages: javascript-typescript
queries: security-extended

- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@24c7eb380a2dc368f2d129e4c65e51d172983a1e # v4
with:
category: "/language:javascript-typescript"
3 changes: 2 additions & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
paths:
- '**/package.json'
- '**/package-lock.json'
- 'pnpm-lock.yaml'

jobs:
dependency-review:
Expand All @@ -21,7 +22,7 @@ jobs:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
pull-requests: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lib-collection-scripts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
uses: aquasecurity/trivy-action@a9c7b0f06e461e9d4b4d1711f154ee024b8d7ab8 # v0.36.0
with:
scan-type: "fs"
scan-ref: lib
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post-pr-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
if: github.event.workflow_run.event == 'pull_request'
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/vscode-extension-secure-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:

- name: Run Trivy vulnerability scanner
id: trivy_scan
uses: aquasecurity/trivy-action@master
uses: aquasecurity/trivy-action@a9c7b0f06e461e9d4b4d1711f154ee024b8d7ab8 # v0.36.0
with:
scan-type: "fs"
scan-ref: ${{ env.EXTENSION_DIR }}
Expand All @@ -115,7 +115,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down Expand Up @@ -177,7 +177,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down Expand Up @@ -327,7 +327,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down Expand Up @@ -395,7 +395,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/vscode-extension-secure-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
npm version ${{ steps.version.outputs.version }} --no-git-tag-version

- name: Run final security scan
uses: aquasecurity/trivy-action@master
uses: aquasecurity/trivy-action@a9c7b0f06e461e9d4b4d1711f154ee024b8d7ab8 # v0.36.0
with:
scan-type: "fs"
scan-ref: ${{ env.EXTENSION_DIR }}
Expand Down Expand Up @@ -185,7 +185,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down Expand Up @@ -301,7 +301,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit

Expand Down
19 changes: 19 additions & 0 deletions packages/app/vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
defineConfig,
} from 'vitest/config';

export default defineConfig({
test: {
coverage: {
provider: 'v8',
include: ['src/**/*.ts'],
reporter: ['text', 'html', 'json-summary'],
thresholds: {
statements: 85,
branches: 75,
functions: 85,
lines: 85
}
}
}
});
19 changes: 19 additions & 0 deletions packages/cli/vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
defineConfig,
} from 'vitest/config';

export default defineConfig({
test: {
coverage: {
provider: 'v8',
include: ['src/**/*.ts'],
reporter: ['text', 'html', 'json-summary'],
thresholds: {
statements: 65,
branches: 45,
functions: 55,
lines: 65
}
}
}
});
19 changes: 19 additions & 0 deletions packages/core/vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
defineConfig,
} from 'vitest/config';

export default defineConfig({
test: {
coverage: {
provider: 'v8',
include: ['src/**/*.ts'],
reporter: ['text', 'html', 'json-summary'],
thresholds: {
statements: 80,
branches: 75,
functions: 80,
lines: 80
}
}
}
});
19 changes: 19 additions & 0 deletions packages/infra/vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
defineConfig,
} from 'vitest/config';

export default defineConfig({
test: {
coverage: {
provider: 'v8',
include: ['src/**/*.ts'],
reporter: ['text', 'html', 'json-summary'],
thresholds: {
statements: 80,
branches: 70,
functions: 80,
lines: 80
}
}
}
});
Loading