@eduardbar/drift 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gga +50 -0
- package/.github/actions/drift-review/README.md +62 -0
- package/.github/actions/drift-review/action.yml +148 -0
- package/.github/actions/drift-scan/README.md +28 -32
- package/.github/actions/drift-scan/action.yml +78 -14
- package/.github/workflows/publish-vscode.yml +1 -3
- package/.github/workflows/publish.yml +8 -0
- package/.github/workflows/quality.yml +15 -0
- package/.github/workflows/reusable-quality-checks.yml +95 -0
- package/.github/workflows/review-pr.yml +33 -41
- package/AGENTS.md +75 -251
- package/CHANGELOG.md +41 -0
- package/README.md +177 -43
- package/benchmarks/fixtures/critical/drift.config.ts +21 -0
- package/benchmarks/fixtures/critical/src/app/user-service.ts +30 -0
- package/benchmarks/fixtures/critical/src/domain/entities.ts +19 -0
- package/benchmarks/fixtures/critical/src/domain/policies.ts +22 -0
- package/benchmarks/fixtures/critical/src/index.ts +10 -0
- package/benchmarks/fixtures/critical/src/infra/memory-user-repo.ts +14 -0
- package/benchmarks/perf-budget.v1.json +27 -0
- package/dist/benchmark.d.ts +1 -1
- package/dist/benchmark.js +83 -52
- package/dist/cli.js +243 -8
- package/dist/config.js +16 -2
- package/dist/diff.js +42 -50
- package/dist/doctor.d.ts +26 -0
- package/dist/doctor.js +140 -0
- package/dist/format.d.ts +17 -0
- package/dist/format.js +45 -0
- package/dist/guard-baseline.d.ts +12 -0
- package/dist/guard-baseline.js +57 -0
- package/dist/guard-metrics.d.ts +6 -0
- package/dist/guard-metrics.js +39 -0
- package/dist/guard-types.d.ts +58 -0
- package/dist/guard-types.js +2 -0
- package/dist/guard.d.ts +16 -0
- package/dist/guard.js +178 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +4 -1
- package/dist/init.d.ts +15 -0
- package/dist/init.js +273 -0
- package/dist/map-cycles.d.ts +2 -0
- package/dist/map-cycles.js +34 -0
- package/dist/map-svg.d.ts +19 -0
- package/dist/map-svg.js +97 -0
- package/dist/map.js +78 -138
- package/dist/metrics.js +70 -55
- package/dist/output-metadata.d.ts +15 -0
- package/dist/output-metadata.js +19 -0
- package/dist/plugins-capabilities.d.ts +4 -0
- package/dist/plugins-capabilities.js +21 -0
- package/dist/plugins-messages.d.ts +10 -0
- package/dist/plugins-messages.js +16 -0
- package/dist/plugins-rules.d.ts +9 -0
- package/dist/plugins-rules.js +137 -0
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +45 -142
- package/dist/reporter-constants.d.ts +16 -0
- package/dist/reporter-constants.js +39 -0
- package/dist/reporter.d.ts +3 -3
- package/dist/reporter.js +35 -55
- package/dist/review.d.ts +2 -1
- package/dist/review.js +2 -1
- package/dist/rules/phase3-configurable.js +23 -15
- package/dist/saas/constants.d.ts +15 -0
- package/dist/saas/constants.js +48 -0
- package/dist/saas/dashboard.d.ts +8 -0
- package/dist/saas/dashboard.js +132 -0
- package/dist/saas/errors.d.ts +19 -0
- package/dist/saas/errors.js +37 -0
- package/dist/saas/helpers.d.ts +21 -0
- package/dist/saas/helpers.js +110 -0
- package/dist/saas/ingest.d.ts +3 -0
- package/dist/saas/ingest.js +249 -0
- package/dist/saas/organization.d.ts +5 -0
- package/dist/saas/organization.js +82 -0
- package/dist/saas/plan-change.d.ts +10 -0
- package/dist/saas/plan-change.js +15 -0
- package/dist/saas/store.d.ts +21 -0
- package/dist/saas/store.js +159 -0
- package/dist/saas/types.d.ts +191 -0
- package/dist/saas/types.js +2 -0
- package/dist/saas.d.ts +8 -218
- package/dist/saas.js +7 -761
- package/dist/sarif.d.ts +74 -0
- package/dist/sarif.js +122 -0
- package/dist/trust-advanced.d.ts +14 -0
- package/dist/trust-advanced.js +65 -0
- package/dist/trust-kpi-fs.d.ts +3 -0
- package/dist/trust-kpi-fs.js +141 -0
- package/dist/trust-kpi-parse.d.ts +7 -0
- package/dist/trust-kpi-parse.js +186 -0
- package/dist/trust-kpi-types.d.ts +16 -0
- package/dist/trust-kpi-types.js +2 -0
- package/dist/trust-kpi.d.ts +1 -3
- package/dist/trust-kpi.js +6 -266
- package/dist/trust-policy.d.ts +32 -0
- package/dist/trust-policy.js +160 -0
- package/dist/trust-render.d.ts +9 -0
- package/dist/trust-render.js +54 -0
- package/dist/trust-scoring.d.ts +9 -0
- package/dist/trust-scoring.js +208 -0
- package/dist/trust.d.ts +5 -32
- package/dist/trust.js +29 -432
- package/dist/types/app.d.ts +30 -0
- package/dist/types/app.js +2 -0
- package/dist/types/config.d.ts +25 -0
- package/dist/types/config.js +2 -0
- package/dist/types/core.d.ts +100 -0
- package/dist/types/core.js +2 -0
- package/dist/types/diff.d.ts +55 -0
- package/dist/types/diff.js +2 -0
- package/dist/types/plugin.d.ts +41 -0
- package/dist/types/plugin.js +2 -0
- package/dist/types/trust.d.ts +120 -0
- package/dist/types/trust.js +2 -0
- package/dist/types.d.ts +8 -365
- package/docs/AGENTS.md +1 -1
- package/docs/release-notes-draft.md +40 -0
- package/docs/rules-catalog.md +49 -0
- package/docs/trust-core-release-checklist.md +37 -5
- package/package.json +11 -4
- package/packages/vscode-drift/src/code-actions.ts +1 -1
- package/schemas/drift-ai-output.v1.json +162 -0
- package/schemas/drift-doctor.v1.json +57 -0
- package/schemas/drift-guard.v1.json +298 -0
- package/schemas/drift-report.v1.json +151 -0
- package/schemas/drift-trust.v1.json +131 -0
- package/scripts/check-docs-drift.mjs +154 -0
- package/scripts/check-performance-budget.mjs +360 -0
- package/scripts/check-runtime-policy.mjs +66 -0
- package/scripts/smoke-repo.mjs +394 -0
- package/src/benchmark.ts +92 -53
- package/src/cli.ts +285 -13
- package/src/config.ts +19 -2
- package/src/diff.ts +57 -48
- package/src/doctor.ts +185 -0
- package/src/format.ts +81 -0
- package/src/guard-baseline.ts +74 -0
- package/src/guard-metrics.ts +52 -0
- package/src/guard-types.ts +66 -0
- package/src/guard.ts +248 -0
- package/src/index.ts +36 -0
- package/src/init.ts +298 -0
- package/src/map-cycles.ts +38 -0
- package/src/map-svg.ts +124 -0
- package/src/map.ts +111 -142
- package/src/metrics.ts +78 -59
- package/src/output-metadata.ts +32 -0
- package/src/plugins-capabilities.ts +36 -0
- package/src/plugins-messages.ts +35 -0
- package/src/plugins-rules.ts +296 -0
- package/src/plugins.ts +76 -283
- package/src/reporter-constants.ts +46 -0
- package/src/reporter.ts +64 -65
- package/src/review.ts +4 -2
- package/src/rules/phase3-configurable.ts +39 -26
- package/src/saas/constants.ts +56 -0
- package/src/saas/dashboard.ts +172 -0
- package/src/saas/errors.ts +45 -0
- package/src/saas/helpers.ts +140 -0
- package/src/saas/ingest.ts +278 -0
- package/src/saas/organization.ts +99 -0
- package/src/saas/plan-change.ts +19 -0
- package/src/saas/store.ts +172 -0
- package/src/saas/types.ts +216 -0
- package/src/saas.ts +49 -1031
- package/src/sarif.ts +232 -0
- package/src/trust-advanced.ts +99 -0
- package/src/trust-kpi-fs.ts +169 -0
- package/src/trust-kpi-parse.ts +219 -0
- package/src/trust-kpi-types.ts +19 -0
- package/src/trust-kpi.ts +8 -316
- package/src/trust-policy.ts +246 -0
- package/src/trust-render.ts +61 -0
- package/src/trust-scoring.ts +231 -0
- package/src/trust.ts +62 -576
- package/src/types/app.ts +30 -0
- package/src/types/config.ts +27 -0
- package/src/types/core.ts +105 -0
- package/src/types/diff.ts +61 -0
- package/src/types/plugin.ts +46 -0
- package/src/types/trust.ts +134 -0
- package/src/types.ts +79 -409
- package/tests/ci-quality-matrix.test.ts +37 -0
- package/tests/ci-smoke-gate.test.ts +26 -0
- package/tests/ci-version-alignment.test.ts +93 -0
- package/tests/cli-sarif.test.ts +92 -0
- package/tests/docs-drift-check.test.ts +115 -0
- package/tests/format.test.ts +157 -0
- package/tests/new-features.test.ts +11 -3
- package/tests/perf-budget-check.test.ts +146 -0
- package/tests/phase1-init-doctor-guard.test.ts +301 -0
- package/tests/runtime-policy-alignment.test.ts +46 -0
- package/tests/sarif.test.ts +160 -0
- package/tests/trust-kpi.test.ts +31 -4
- package/tests/trust.test.ts +18 -0
- package/vitest.config.ts +2 -0
package/.gga
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Gentleman Guardian Angel Configuration
|
|
2
|
+
# https://github.com/your-org/gga
|
|
3
|
+
|
|
4
|
+
# AI Provider (required)
|
|
5
|
+
# Options: claude, gemini, codex, opencode, ollama:<model>, lmstudio[:model], github:<model>
|
|
6
|
+
# Examples:
|
|
7
|
+
# PROVIDER="claude"
|
|
8
|
+
# PROVIDER="gemini"
|
|
9
|
+
# PROVIDER="codex"
|
|
10
|
+
# PROVIDER="opencode"
|
|
11
|
+
# PROVIDER="opencode:anthropic/claude-opus-4-5"
|
|
12
|
+
# PROVIDER="ollama:llama3.2"
|
|
13
|
+
# PROVIDER="ollama:codellama"
|
|
14
|
+
# PROVIDER="lmstudio"
|
|
15
|
+
# PROVIDER="lmstudio:qwen2.5-coder-7b-instruct"
|
|
16
|
+
# PROVIDER="github:gpt-4o"
|
|
17
|
+
# PROVIDER="github:deepseek-r1"
|
|
18
|
+
PROVIDER="claude"
|
|
19
|
+
|
|
20
|
+
# File patterns to include in review (comma-separated)
|
|
21
|
+
# Default: * (all files)
|
|
22
|
+
# Examples:
|
|
23
|
+
# FILE_PATTERNS="*.ts,*.tsx"
|
|
24
|
+
# FILE_PATTERNS="*.py"
|
|
25
|
+
# FILE_PATTERNS="*.go,*.mod"
|
|
26
|
+
FILE_PATTERNS="*.ts,*.tsx,*.js,*.jsx"
|
|
27
|
+
|
|
28
|
+
# File patterns to exclude from review (comma-separated)
|
|
29
|
+
# Default: none
|
|
30
|
+
# Examples:
|
|
31
|
+
# EXCLUDE_PATTERNS="*.test.ts,*.spec.ts"
|
|
32
|
+
# EXCLUDE_PATTERNS="*_test.go,*.mock.ts"
|
|
33
|
+
EXCLUDE_PATTERNS="*.test.ts,*.spec.ts,*.test.tsx,*.spec.tsx,*.d.ts"
|
|
34
|
+
|
|
35
|
+
# File containing code review rules
|
|
36
|
+
# Default: AGENTS.md
|
|
37
|
+
RULES_FILE="AGENTS.md"
|
|
38
|
+
|
|
39
|
+
# Strict mode: fail if AI response is ambiguous
|
|
40
|
+
# Default: true
|
|
41
|
+
STRICT_MODE="true"
|
|
42
|
+
|
|
43
|
+
# Timeout in seconds for AI provider response
|
|
44
|
+
# Default: 300 (5 minutes)
|
|
45
|
+
# Increase for large changesets or slow connections
|
|
46
|
+
TIMEOUT="300"
|
|
47
|
+
|
|
48
|
+
# Base branch for --pr-mode (auto-detects main/master/develop if empty)
|
|
49
|
+
# Default: auto-detect
|
|
50
|
+
# PR_BASE_BRANCH="main"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# drift-review Action
|
|
2
|
+
|
|
3
|
+
Composite action for PR workflows that wraps `drift trust`, optional `drift review`, and `drift trust-gate`.
|
|
4
|
+
|
|
5
|
+
The action runs drift via `npm exec` with an isolated prefix under `$RUNNER_TEMP/drift-cli` to avoid local bin resolution conflicts when workflows execute inside the `@eduardbar/drift` repository.
|
|
6
|
+
|
|
7
|
+
If the requested `version` is not published on npm yet (for example, release-prep PRs), the action falls back to the local repository CLI (`npx --no-install tsx ./src/cli.ts`) so PR checks can still run.
|
|
8
|
+
|
|
9
|
+
## Why this action exists
|
|
10
|
+
|
|
11
|
+
The repository workflow (`.github/workflows/review-pr.yml`) uses trust as the merge gate and review markdown as complementary context. This action packages that flow as a reusable contract:
|
|
12
|
+
|
|
13
|
+
1. Generate trust markdown + JSON
|
|
14
|
+
2. Optionally generate review markdown
|
|
15
|
+
3. Extract stable trust outputs for downstream jobs/comments
|
|
16
|
+
4. Enforce trust gate when configured
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```yaml
|
|
21
|
+
- name: Drift trust/review
|
|
22
|
+
id: drift_review
|
|
23
|
+
uses: ./.github/actions/drift-review
|
|
24
|
+
with:
|
|
25
|
+
path: .
|
|
26
|
+
base-ref: origin/${{ github.base_ref }}
|
|
27
|
+
version: 1.5.0
|
|
28
|
+
min-trust: 40
|
|
29
|
+
max-risk: HIGH
|
|
30
|
+
fail-on-gate: true
|
|
31
|
+
include-review: true
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Inputs
|
|
35
|
+
|
|
36
|
+
| Input | Description | Default |
|
|
37
|
+
|-------|-------------|---------|
|
|
38
|
+
| `path` | Path to analyze | `.` |
|
|
39
|
+
| `base-ref` | Base git ref for diff-aware trust/review | `origin/main` |
|
|
40
|
+
| `version` | drift version for `npm exec` execution | `1.5.0` |
|
|
41
|
+
| `min-trust` | Failing threshold for trust score | `45` |
|
|
42
|
+
| `max-risk` | Failing threshold for merge risk | `HIGH` |
|
|
43
|
+
| `fail-on-gate` | Enforce trust gate failure | `true` |
|
|
44
|
+
| `include-review` | Generate review markdown file | `true` |
|
|
45
|
+
|
|
46
|
+
## Outputs
|
|
47
|
+
|
|
48
|
+
| Output | Description |
|
|
49
|
+
|--------|-------------|
|
|
50
|
+
| `trust-score` | `trust_score` from trust JSON |
|
|
51
|
+
| `merge-risk` | `merge_risk` from trust JSON |
|
|
52
|
+
| `new-issues` | New issue count from `diff_context` or `n/a` |
|
|
53
|
+
| `resolved-issues` | Resolved issue count from `diff_context` or `n/a` |
|
|
54
|
+
| `trust-json` | Trust JSON file path |
|
|
55
|
+
| `trust-markdown` | Trust markdown file path |
|
|
56
|
+
| `review-markdown` | Review markdown file path |
|
|
57
|
+
|
|
58
|
+
## Failure behavior
|
|
59
|
+
|
|
60
|
+
- Parsing failures on trust JSON fail the step.
|
|
61
|
+
- Gate violations fail when `fail-on-gate=true`.
|
|
62
|
+
- No `|| true` paths are used for critical scan/trust/gate commands.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
name: 'Drift — Trust + Review for PRs'
|
|
2
|
+
description: 'Generate trust/review artifacts and enforce trust gate for pull requests'
|
|
3
|
+
author: 'eduardbar'
|
|
4
|
+
|
|
5
|
+
branding:
|
|
6
|
+
icon: 'shield'
|
|
7
|
+
color: 'blue'
|
|
8
|
+
|
|
9
|
+
inputs:
|
|
10
|
+
path:
|
|
11
|
+
description: 'Path to analyze'
|
|
12
|
+
required: false
|
|
13
|
+
default: '.'
|
|
14
|
+
base-ref:
|
|
15
|
+
description: 'Git base ref used by trust/review diff context'
|
|
16
|
+
required: false
|
|
17
|
+
default: 'origin/main'
|
|
18
|
+
version:
|
|
19
|
+
description: 'Version of @eduardbar/drift to use'
|
|
20
|
+
required: false
|
|
21
|
+
default: '1.5.0'
|
|
22
|
+
min-trust:
|
|
23
|
+
description: 'Fail gate if trust score is below this threshold'
|
|
24
|
+
required: false
|
|
25
|
+
default: '45'
|
|
26
|
+
max-risk:
|
|
27
|
+
description: 'Fail gate if merge risk exceeds this level (LOW|MEDIUM|HIGH|CRITICAL)'
|
|
28
|
+
required: false
|
|
29
|
+
default: 'HIGH'
|
|
30
|
+
fail-on-gate:
|
|
31
|
+
description: 'Whether to enforce trust-gate failure'
|
|
32
|
+
required: false
|
|
33
|
+
default: 'true'
|
|
34
|
+
include-review:
|
|
35
|
+
description: 'Whether to generate drift review markdown'
|
|
36
|
+
required: false
|
|
37
|
+
default: 'true'
|
|
38
|
+
|
|
39
|
+
outputs:
|
|
40
|
+
trust-score:
|
|
41
|
+
description: 'Trust score from drift trust JSON'
|
|
42
|
+
value: ${{ steps.extract.outputs.trust_score }}
|
|
43
|
+
merge-risk:
|
|
44
|
+
description: 'Merge risk from drift trust JSON'
|
|
45
|
+
value: ${{ steps.extract.outputs.merge_risk }}
|
|
46
|
+
new-issues:
|
|
47
|
+
description: 'New issues compared to base ref when available'
|
|
48
|
+
value: ${{ steps.extract.outputs.new_issues }}
|
|
49
|
+
resolved-issues:
|
|
50
|
+
description: 'Resolved issues compared to base ref when available'
|
|
51
|
+
value: ${{ steps.extract.outputs.resolved_issues }}
|
|
52
|
+
trust-json:
|
|
53
|
+
description: 'Generated trust JSON file path'
|
|
54
|
+
value: ${{ steps.files.outputs.trust_json }}
|
|
55
|
+
trust-markdown:
|
|
56
|
+
description: 'Generated trust markdown file path'
|
|
57
|
+
value: ${{ steps.files.outputs.trust_md }}
|
|
58
|
+
review-markdown:
|
|
59
|
+
description: 'Generated review markdown file path (if include-review=true)'
|
|
60
|
+
value: ${{ steps.files.outputs.review_md }}
|
|
61
|
+
|
|
62
|
+
runs:
|
|
63
|
+
using: 'composite'
|
|
64
|
+
steps:
|
|
65
|
+
- name: Prepare artifact file paths
|
|
66
|
+
id: files
|
|
67
|
+
shell: bash
|
|
68
|
+
run: |
|
|
69
|
+
set -euo pipefail
|
|
70
|
+
trust_json="$RUNNER_TEMP/drift-trust.json"
|
|
71
|
+
trust_md="$RUNNER_TEMP/drift-trust.md"
|
|
72
|
+
review_md="$RUNNER_TEMP/drift-review.md"
|
|
73
|
+
echo "trust_json=$trust_json" >> "$GITHUB_OUTPUT"
|
|
74
|
+
echo "trust_md=$trust_md" >> "$GITHUB_OUTPUT"
|
|
75
|
+
echo "review_md=$review_md" >> "$GITHUB_OUTPUT"
|
|
76
|
+
|
|
77
|
+
- name: Generate trust artifacts
|
|
78
|
+
shell: bash
|
|
79
|
+
run: |
|
|
80
|
+
set -euo pipefail
|
|
81
|
+
EXEC_PREFIX="$RUNNER_TEMP/drift-cli"
|
|
82
|
+
mkdir -p "$EXEC_PREFIX"
|
|
83
|
+
VERSION="${{ inputs.version }}"
|
|
84
|
+
if npm view "@eduardbar/drift@$VERSION" version >/dev/null 2>&1; then
|
|
85
|
+
npm exec --yes --prefix "$EXEC_PREFIX" --package="@eduardbar/drift@$VERSION" -- drift --version
|
|
86
|
+
npm exec --yes --prefix "$EXEC_PREFIX" --package="@eduardbar/drift@$VERSION" -- drift trust "${{ inputs.path }}" --base "${{ inputs.base-ref }}" --markdown --json-output "${{ steps.files.outputs.trust_json }}" > "${{ steps.files.outputs.trust_md }}"
|
|
87
|
+
else
|
|
88
|
+
echo "::notice::@eduardbar/drift@$VERSION is not published yet; using local CLI fallback"
|
|
89
|
+
npx --no-install tsx ./src/cli.ts --version
|
|
90
|
+
npx --no-install tsx ./src/cli.ts trust "${{ inputs.path }}" --base "${{ inputs.base-ref }}" --markdown --json-output "${{ steps.files.outputs.trust_json }}" > "${{ steps.files.outputs.trust_md }}"
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
- name: Generate review markdown
|
|
94
|
+
if: inputs.include-review == 'true'
|
|
95
|
+
shell: bash
|
|
96
|
+
run: |
|
|
97
|
+
set -euo pipefail
|
|
98
|
+
EXEC_PREFIX="$RUNNER_TEMP/drift-cli"
|
|
99
|
+
mkdir -p "$EXEC_PREFIX"
|
|
100
|
+
VERSION="${{ inputs.version }}"
|
|
101
|
+
if npm view "@eduardbar/drift@$VERSION" version >/dev/null 2>&1; then
|
|
102
|
+
npm exec --yes --prefix "$EXEC_PREFIX" --package="@eduardbar/drift@$VERSION" -- drift review --base "${{ inputs.base-ref }}" --comment > "${{ steps.files.outputs.review_md }}"
|
|
103
|
+
else
|
|
104
|
+
npx --no-install tsx ./src/cli.ts review --base "${{ inputs.base-ref }}" --comment > "${{ steps.files.outputs.review_md }}"
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
- name: Extract trust outputs
|
|
108
|
+
id: extract
|
|
109
|
+
shell: bash
|
|
110
|
+
run: |
|
|
111
|
+
set -euo pipefail
|
|
112
|
+
TRUST_JSON_PATH="${{ steps.files.outputs.trust_json }}" GITHUB_OUTPUT_PATH="$GITHUB_OUTPUT" node --input-type=module <<'NODE'
|
|
113
|
+
import fs from 'node:fs'
|
|
114
|
+
|
|
115
|
+
const payload = JSON.parse(fs.readFileSync(process.env.TRUST_JSON_PATH, 'utf8'))
|
|
116
|
+
const trust = payload.trust_score
|
|
117
|
+
const risk = payload.merge_risk
|
|
118
|
+
const diff = payload.diff_context ?? {}
|
|
119
|
+
|
|
120
|
+
if (typeof trust !== 'number') {
|
|
121
|
+
throw new Error('drift trust JSON missing numeric trust_score')
|
|
122
|
+
}
|
|
123
|
+
if (typeof risk !== 'string') {
|
|
124
|
+
throw new Error('drift trust JSON missing merge_risk')
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const lines = [
|
|
128
|
+
`trust_score=${trust}`,
|
|
129
|
+
`merge_risk=${risk}`,
|
|
130
|
+
`new_issues=${diff.newIssues ?? 'n/a'}`,
|
|
131
|
+
`resolved_issues=${diff.resolvedIssues ?? 'n/a'}`,
|
|
132
|
+
]
|
|
133
|
+
fs.appendFileSync(process.env.GITHUB_OUTPUT_PATH, lines.join('\n') + '\n')
|
|
134
|
+
NODE
|
|
135
|
+
|
|
136
|
+
- name: Enforce trust gate
|
|
137
|
+
if: inputs.fail-on-gate == 'true'
|
|
138
|
+
shell: bash
|
|
139
|
+
run: |
|
|
140
|
+
set -euo pipefail
|
|
141
|
+
EXEC_PREFIX="$RUNNER_TEMP/drift-cli"
|
|
142
|
+
mkdir -p "$EXEC_PREFIX"
|
|
143
|
+
VERSION="${{ inputs.version }}"
|
|
144
|
+
if npm view "@eduardbar/drift@$VERSION" version >/dev/null 2>&1; then
|
|
145
|
+
npm exec --yes --prefix "$EXEC_PREFIX" --package="@eduardbar/drift@$VERSION" -- drift trust-gate "${{ steps.files.outputs.trust_json }}" --min-trust "${{ inputs.min-trust }}" --max-risk "${{ inputs.max-risk }}"
|
|
146
|
+
else
|
|
147
|
+
npx --no-install tsx ./src/cli.ts trust-gate "${{ steps.files.outputs.trust_json }}" --min-trust "${{ inputs.min-trust }}" --max-risk "${{ inputs.max-risk }}"
|
|
148
|
+
fi
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
# drift-scan Action
|
|
1
|
+
# drift-scan Action (v2 contract)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Composite action to run `drift scan` in CI without global installs.
|
|
4
|
+
|
|
5
|
+
## Contract highlights
|
|
6
|
+
|
|
7
|
+
- Runtime strategy: `npm exec --yes --prefix "$RUNNER_TEMP/drift-cli" --package=@eduardbar/drift@<version> -- drift ...` (no `npm install -g`)
|
|
8
|
+
- Uses isolated `--prefix` under `$RUNNER_TEMP` to avoid bin resolution conflicts in self-hosting repository workflows
|
|
9
|
+
- Default drift version is pinned (`1.5.0`) for deterministic runs
|
|
10
|
+
- Uses `drift scan --json` and extracts typed outputs
|
|
11
|
+
- Critical command/parse failures are not silenced (step fails immediately)
|
|
4
12
|
|
|
5
13
|
## Usage
|
|
6
14
|
|
|
7
15
|
```yaml
|
|
8
16
|
- name: Check drift score
|
|
9
|
-
|
|
17
|
+
id: drift_scan
|
|
18
|
+
uses: ./.github/actions/drift-scan
|
|
10
19
|
with:
|
|
11
20
|
path: ./src
|
|
12
21
|
min-score: 60
|
|
22
|
+
fail-on-threshold: true
|
|
23
|
+
version: 1.5.0
|
|
13
24
|
```
|
|
14
25
|
|
|
15
26
|
## Inputs
|
|
@@ -19,7 +30,7 @@ Scan your TypeScript project for AI-generated technical debt in CI.
|
|
|
19
30
|
| `path` | Path to scan | `.` |
|
|
20
31
|
| `min-score` | Fail if score exceeds this | `80` |
|
|
21
32
|
| `fail-on-threshold` | Whether to fail on threshold | `true` |
|
|
22
|
-
| `version` | drift version
|
|
33
|
+
| `version` | drift version for `npm exec` execution | `1.5.0` |
|
|
23
34
|
|
|
24
35
|
## Outputs
|
|
25
36
|
|
|
@@ -27,35 +38,20 @@ Scan your TypeScript project for AI-generated technical debt in CI.
|
|
|
27
38
|
|--------|-------------|
|
|
28
39
|
| `score` | Project drift score (0-100) |
|
|
29
40
|
| `grade` | Grade: CLEAN / LOW / MODERATE / HIGH / CRITICAL |
|
|
41
|
+
| `errors` | Error-level issue count |
|
|
42
|
+
| `warnings` | Warning-level issue count |
|
|
43
|
+
| `infos` | Info-level issue count |
|
|
44
|
+
| `total-issues` | Total issue count |
|
|
45
|
+
| `files-affected` | Files with at least one issue |
|
|
46
|
+
| `top-rules` | Top 3 rules as `rule:count` CSV |
|
|
30
47
|
|
|
31
|
-
## Example:
|
|
48
|
+
## Example: consume outputs
|
|
32
49
|
|
|
33
50
|
```yaml
|
|
34
|
-
name:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
steps:
|
|
41
|
-
- uses: actions/checkout@v4
|
|
42
|
-
- uses: eduardbar/drift@v1
|
|
43
|
-
with:
|
|
44
|
-
path: ./src
|
|
45
|
-
min-score: 60
|
|
46
|
-
fail-on-threshold: true
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Example: capture outputs
|
|
50
|
-
|
|
51
|
-
```yaml
|
|
52
|
-
- name: Scan drift
|
|
53
|
-
id: drift
|
|
54
|
-
uses: eduardbar/drift@v1
|
|
55
|
-
with:
|
|
56
|
-
path: ./src
|
|
57
|
-
fail-on-threshold: false
|
|
58
|
-
|
|
59
|
-
- name: Print results
|
|
60
|
-
run: echo "Score ${{ steps.drift.outputs.score }}/100 — ${{ steps.drift.outputs.grade }}"
|
|
51
|
+
- name: Print drift outputs
|
|
52
|
+
run: |
|
|
53
|
+
echo "Score: ${{ steps.drift_scan.outputs.score }}"
|
|
54
|
+
echo "Grade: ${{ steps.drift_scan.outputs.grade }}"
|
|
55
|
+
echo "Errors/Warnings/Infos: ${{ steps.drift_scan.outputs.errors }}/${{ steps.drift_scan.outputs.warnings }}/${{ steps.drift_scan.outputs.infos }}"
|
|
56
|
+
echo "Top rules: ${{ steps.drift_scan.outputs.top-rules }}"
|
|
61
57
|
```
|
|
@@ -22,7 +22,7 @@ inputs:
|
|
|
22
22
|
version:
|
|
23
23
|
description: 'Version of @eduardbar/drift to use'
|
|
24
24
|
required: false
|
|
25
|
-
default: '
|
|
25
|
+
default: '1.5.0'
|
|
26
26
|
|
|
27
27
|
outputs:
|
|
28
28
|
score:
|
|
@@ -31,33 +31,97 @@ outputs:
|
|
|
31
31
|
grade:
|
|
32
32
|
description: 'The drift grade (CLEAN / LOW / MODERATE / HIGH / CRITICAL)'
|
|
33
33
|
value: ${{ steps.scan.outputs.grade }}
|
|
34
|
+
errors:
|
|
35
|
+
description: 'Total error-level issues in the scan'
|
|
36
|
+
value: ${{ steps.scan.outputs.errors }}
|
|
37
|
+
warnings:
|
|
38
|
+
description: 'Total warning-level issues in the scan'
|
|
39
|
+
value: ${{ steps.scan.outputs.warnings }}
|
|
40
|
+
infos:
|
|
41
|
+
description: 'Total info-level issues in the scan'
|
|
42
|
+
value: ${{ steps.scan.outputs.infos }}
|
|
43
|
+
total-issues:
|
|
44
|
+
description: 'Total number of issues in the scan'
|
|
45
|
+
value: ${{ steps.scan.outputs.total_issues }}
|
|
46
|
+
files-affected:
|
|
47
|
+
description: 'Number of files that contain at least one issue'
|
|
48
|
+
value: ${{ steps.scan.outputs.files_affected }}
|
|
49
|
+
top-rules:
|
|
50
|
+
description: 'Top 3 rules as comma-separated pairs rule:count'
|
|
51
|
+
value: ${{ steps.scan.outputs.top_rules }}
|
|
34
52
|
|
|
35
53
|
runs:
|
|
36
54
|
using: 'composite'
|
|
37
55
|
steps:
|
|
38
|
-
- name: Install drift
|
|
39
|
-
shell: bash
|
|
40
|
-
run: npm install -g @eduardbar/drift@${{ inputs.version }}
|
|
41
|
-
|
|
42
56
|
- name: Run drift scan
|
|
43
57
|
id: scan
|
|
44
58
|
shell: bash
|
|
45
59
|
run: |
|
|
60
|
+
set -euo pipefail
|
|
46
61
|
TMPFILE=$(mktemp)
|
|
62
|
+
EXEC_PREFIX="$RUNNER_TEMP/drift-cli"
|
|
63
|
+
mkdir -p "$EXEC_PREFIX"
|
|
47
64
|
|
|
48
|
-
|
|
49
|
-
drift scan ${{ inputs.path }} --
|
|
65
|
+
npm exec --yes --prefix "$EXEC_PREFIX" --package=@eduardbar/drift@${{ inputs.version }} -- drift --version
|
|
66
|
+
npm exec --yes --prefix "$EXEC_PREFIX" --package=@eduardbar/drift@${{ inputs.version }} -- drift scan "${{ inputs.path }}" --json > "$TMPFILE"
|
|
50
67
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
GRADE=$(node -e "const d=JSON.parse(require('fs').readFileSync('$TMPFILE','utf8')); console.log(d.summary.grade)")
|
|
68
|
+
TMPFILE_PATH="$TMPFILE" GITHUB_OUTPUT_PATH="$GITHUB_OUTPUT" node --input-type=module -e "
|
|
69
|
+
import fs from 'node:fs'
|
|
54
70
|
|
|
55
|
-
|
|
71
|
+
const payload = JSON.parse(fs.readFileSync(process.env.TMPFILE_PATH, 'utf8'))
|
|
72
|
+
const score = payload.totalScore
|
|
73
|
+
if (typeof score !== 'number') {
|
|
74
|
+
throw new Error('drift scan JSON did not include numeric totalScore')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const grade = score === 0
|
|
78
|
+
? 'CLEAN'
|
|
79
|
+
: score <= 19
|
|
80
|
+
? 'LOW'
|
|
81
|
+
: score <= 44
|
|
82
|
+
? 'MODERATE'
|
|
83
|
+
: score <= 69
|
|
84
|
+
? 'HIGH'
|
|
85
|
+
: 'CRITICAL'
|
|
86
|
+
|
|
87
|
+
const summary = payload.summary ?? {}
|
|
88
|
+
const errors = Number(summary.errors ?? 0)
|
|
89
|
+
const warnings = Number(summary.warnings ?? 0)
|
|
90
|
+
const infos = Number(summary.infos ?? 0)
|
|
91
|
+
const totalIssues = Number(payload.totalIssues ?? 0)
|
|
92
|
+
const filesAffected = Array.isArray(payload.files) ? payload.files.length : 0
|
|
56
93
|
|
|
57
|
-
|
|
58
|
-
|
|
94
|
+
const byRule = summary.byRule && typeof summary.byRule === 'object' ? summary.byRule : {}
|
|
95
|
+
const topRules = Object.entries(byRule)
|
|
96
|
+
.sort((a, b) => Number(b[1]) - Number(a[1]))
|
|
97
|
+
.slice(0, 3)
|
|
98
|
+
.map(([rule, count]) => `${rule}:${count}`)
|
|
99
|
+
.join(',')
|
|
59
100
|
|
|
60
|
-
|
|
101
|
+
const lines = [
|
|
102
|
+
`score=${score}`,
|
|
103
|
+
`grade=${grade}`,
|
|
104
|
+
`errors=${errors}`,
|
|
105
|
+
`warnings=${warnings}`,
|
|
106
|
+
`infos=${infos}`,
|
|
107
|
+
`total_issues=${totalIssues}`,
|
|
108
|
+
`files_affected=${filesAffected}`,
|
|
109
|
+
`top_rules=${topRules}`,
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
fs.appendFileSync(process.env.GITHUB_OUTPUT_PATH, lines.join('\\n') + '\\n')
|
|
113
|
+
console.log(`Drift Score: ${score}/100 (${grade})`)
|
|
114
|
+
console.log(`Issue summary: errors=${errors} warnings=${warnings} infos=${infos} total=${totalIssues}`)
|
|
115
|
+
console.log(`Top rules: ${topRules || 'n/a'}`)
|
|
116
|
+
"
|
|
117
|
+
|
|
118
|
+
SCORE=$(TMPFILE_PATH="$TMPFILE" node --input-type=module -e "
|
|
119
|
+
import fs from 'node:fs'
|
|
120
|
+
const payload = JSON.parse(fs.readFileSync(process.env.TMPFILE_PATH, 'utf8'))
|
|
121
|
+
process.stdout.write(String(payload.totalScore))
|
|
122
|
+
")
|
|
123
|
+
|
|
124
|
+
rm "$TMPFILE"
|
|
61
125
|
|
|
62
126
|
if [ "${{ inputs.fail-on-threshold }}" = "true" ] && [ "$SCORE" -gt "${{ inputs.min-score }}" ]; then
|
|
63
127
|
echo "::error::Drift score $SCORE/100 exceeds threshold of ${{ inputs.min-score }}"
|
|
@@ -3,8 +3,6 @@ name: Publish VS Code Extension
|
|
|
3
3
|
on:
|
|
4
4
|
release:
|
|
5
5
|
types: [published]
|
|
6
|
-
tags:
|
|
7
|
-
- 'vscode-v*'
|
|
8
6
|
workflow_dispatch:
|
|
9
7
|
inputs:
|
|
10
8
|
version:
|
|
@@ -17,6 +15,7 @@ permissions:
|
|
|
17
15
|
|
|
18
16
|
jobs:
|
|
19
17
|
publish:
|
|
18
|
+
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/vscode-v') }}
|
|
20
19
|
runs-on: ubuntu-latest
|
|
21
20
|
defaults:
|
|
22
21
|
run:
|
|
@@ -36,7 +35,6 @@ jobs:
|
|
|
36
35
|
cache-dependency-path: packages/vscode-drift/package-lock.json
|
|
37
36
|
|
|
38
37
|
- name: Verify version matches tag
|
|
39
|
-
if: github.event_name == 'release'
|
|
40
38
|
run: |
|
|
41
39
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
42
40
|
TAG_VERSION="${{ inputs.version }}"
|
|
@@ -14,7 +14,15 @@ permissions:
|
|
|
14
14
|
contents: read
|
|
15
15
|
|
|
16
16
|
jobs:
|
|
17
|
+
release-verify:
|
|
18
|
+
name: Release Verify
|
|
19
|
+
uses: ./.github/workflows/reusable-quality-checks.yml
|
|
20
|
+
with:
|
|
21
|
+
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/v{0}', inputs.tag) || github.ref }}
|
|
22
|
+
coverage_artifact_prefix: release-coverage
|
|
23
|
+
|
|
17
24
|
publish:
|
|
25
|
+
needs: release-verify
|
|
18
26
|
runs-on: ubuntu-latest
|
|
19
27
|
steps:
|
|
20
28
|
- name: Checkout
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
name: Reusable Quality Checks
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_call:
|
|
5
|
+
inputs:
|
|
6
|
+
ref:
|
|
7
|
+
description: Git ref to checkout before running checks
|
|
8
|
+
required: false
|
|
9
|
+
type: string
|
|
10
|
+
default: ''
|
|
11
|
+
node_versions:
|
|
12
|
+
description: JSON array of Node.js versions for matrix execution
|
|
13
|
+
required: false
|
|
14
|
+
type: string
|
|
15
|
+
default: '["20", "22"]'
|
|
16
|
+
coverage_artifact_prefix:
|
|
17
|
+
description: Prefix used for uploaded coverage artifacts
|
|
18
|
+
required: false
|
|
19
|
+
type: string
|
|
20
|
+
default: coverage
|
|
21
|
+
|
|
22
|
+
permissions:
|
|
23
|
+
contents: read
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
quality:
|
|
27
|
+
name: Quality (Node ${{ matrix.node }})
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
strategy:
|
|
30
|
+
fail-fast: false
|
|
31
|
+
matrix:
|
|
32
|
+
node: ${{ fromJson(inputs.node_versions) }}
|
|
33
|
+
|
|
34
|
+
steps:
|
|
35
|
+
- name: Checkout
|
|
36
|
+
uses: actions/checkout@v5
|
|
37
|
+
with:
|
|
38
|
+
ref: ${{ inputs.ref != '' && inputs.ref || github.ref }}
|
|
39
|
+
|
|
40
|
+
- name: Setup Node.js
|
|
41
|
+
uses: actions/setup-node@v5
|
|
42
|
+
with:
|
|
43
|
+
node-version: ${{ matrix.node }}
|
|
44
|
+
cache: npm
|
|
45
|
+
|
|
46
|
+
- name: Install dependencies
|
|
47
|
+
run: npm ci
|
|
48
|
+
|
|
49
|
+
- name: Validate runtime policy contract
|
|
50
|
+
run: npm run check:runtime-policy
|
|
51
|
+
|
|
52
|
+
- name: Validate docs/source-of-truth drift contract
|
|
53
|
+
run: npm run check:docs-drift
|
|
54
|
+
|
|
55
|
+
- name: Run tests
|
|
56
|
+
run: npm test
|
|
57
|
+
|
|
58
|
+
- name: Run coverage
|
|
59
|
+
run: npm run test:coverage -- --testTimeout=45000
|
|
60
|
+
|
|
61
|
+
- name: Build
|
|
62
|
+
run: npm run build
|
|
63
|
+
|
|
64
|
+
- name: Run CLI smoke E2E
|
|
65
|
+
run: npm run smoke:repo -- --base HEAD --out .drift-smoke/ci-node-${{ matrix.node }}
|
|
66
|
+
|
|
67
|
+
- name: Run performance regression gate
|
|
68
|
+
if: matrix.node == '20'
|
|
69
|
+
run: npm run check:perf-budget -- --out .drift-perf/ci-node-${{ matrix.node }}/benchmark-latest.json
|
|
70
|
+
|
|
71
|
+
- name: Upload coverage artifact
|
|
72
|
+
uses: actions/upload-artifact@v4
|
|
73
|
+
with:
|
|
74
|
+
name: ${{ inputs.coverage_artifact_prefix }}-node-${{ matrix.node }}-run-${{ github.run_id }}-${{ github.run_attempt }}
|
|
75
|
+
path: coverage/
|
|
76
|
+
if-no-files-found: error
|
|
77
|
+
retention-days: 14
|
|
78
|
+
|
|
79
|
+
- name: Upload smoke E2E artifacts
|
|
80
|
+
if: always()
|
|
81
|
+
uses: actions/upload-artifact@v4
|
|
82
|
+
with:
|
|
83
|
+
name: smoke-e2e-node-${{ matrix.node }}-run-${{ github.run_id }}-${{ github.run_attempt }}
|
|
84
|
+
path: .drift-smoke/ci-node-${{ matrix.node }}/
|
|
85
|
+
if-no-files-found: warn
|
|
86
|
+
retention-days: 14
|
|
87
|
+
|
|
88
|
+
- name: Upload perf gate artifacts
|
|
89
|
+
if: always() && matrix.node == '20'
|
|
90
|
+
uses: actions/upload-artifact@v4
|
|
91
|
+
with:
|
|
92
|
+
name: perf-gate-node-${{ matrix.node }}-run-${{ github.run_id }}-${{ github.run_attempt }}
|
|
93
|
+
path: .drift-perf/ci-node-${{ matrix.node }}/
|
|
94
|
+
if-no-files-found: warn
|
|
95
|
+
retention-days: 14
|