-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspecs-validate-with-openspec.yml
More file actions
135 lines (116 loc) · 4.98 KB
/
Copy pathspecs-validate-with-openspec.yml
File metadata and controls
135 lines (116 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Validate All Specs with OpenSpec (Static Validation)
on:
push:
branches: [main]
paths:
- "openspec/**"
- "packages/specs-guardrails/validate-specs-with-openspec/**"
- ".github/workflows/specs-validate-with-openspec.yml"
workflow_dispatch:
jobs:
specs-validate-with-openspec:
name: Validate Specs with OpenSpec (Static Validation)
runs-on: ubuntu-latest
outputs:
validation-status: ${{ steps.parse-result.outputs.success }}
validation-summary-json: ${{ steps.expose-validation-summary-json.outputs.validation_summary_json }}
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Ensure jq is available
run: |
if ! command -v jq >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y jq
fi
- name: Install dev dependencies
run: bun install --only dev
- name: Run OpenSpec validation
id: validation
run: |
mkdir -p .specs-validation/openspec
bun packages/specs-guardrails/validate-specs-with-openspec/index.ts --rootDir $(pwd)/openspec/specs > .specs-validation/openspec/result.json || true
- name: Parse validation result
id: parse-result
run: |
SUCCESS=$(jq -r '.success' .specs-validation/openspec/result.json)
EXIT_CODE=$(jq -r '.exitCode' .specs-validation/openspec/result.json)
TOTAL_ITEMS=$(jq -r '.summary.totals.items' .specs-validation/openspec/result.json)
PASSED=$(jq -r '.summary.totals.passed' .specs-validation/openspec/result.json)
FAILED=$(jq -r '.summary.totals.failed' .specs-validation/openspec/result.json)
echo "success=$SUCCESS" >> "$GITHUB_OUTPUT"
echo "exit_code=$EXIT_CODE" >> "$GITHUB_OUTPUT"
echo "total_items=$TOTAL_ITEMS" >> "$GITHUB_OUTPUT"
echo "passed=$PASSED" >> "$GITHUB_OUTPUT"
echo "failed=$FAILED" >> "$GITHUB_OUTPUT"
- name: Render validation summary
if: always()
run: |
{
echo "# 📋 OpenSpec Validation Result"
echo ""
echo "| Metric | Value |"
echo "|-------|-------|"
echo "| Status | **${{ steps.parse-result.outputs.success }}** |"
echo "| Total items | ${{ steps.parse-result.outputs.total_items }} |"
echo "| Passed | ✅ ${{ steps.parse-result.outputs.passed }} |"
echo "| Failed | ❌ ${{ steps.parse-result.outputs.failed }} |"
echo ""
} >> "$GITHUB_STEP_SUMMARY"
- name: Render validation results
if: always()
run: |
echo "## 📋 All Validated Specs" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Spec ID | Status | Message |" >> "$GITHUB_STEP_SUMMARY"
echo "|---------|-------|---------|" >> "$GITHUB_STEP_SUMMARY"
jq -r '.items[] |
if .valid then
"| \(.id) | ✅ Valid | No issues found |"
else
.id as $id | .issues[] | "| \($id) | \(.level) | \(.message | gsub("\n"; " ")) |"
end
' .specs-validation/openspec/result.json >> "$GITHUB_STEP_SUMMARY"
- name: Expose validation result JSON (as base64)
id: expose-validation-summary-json
run: |
SUMMARY_B64=$(base64 < .specs-validation/openspec/result.json | tr -d '\n')
echo "validation_summary_json=$SUMMARY_B64" >> "$GITHUB_OUTPUT"
- name: Report validation failure
if: steps.parse-result.outputs.success == 'false'
continue-on-error: true
run: |
echo "❌ OpenSpec validation failed! Please review the validation summary above and address the issues."
echo "🤖 You can trigger the AI fix by approving the 'Fix Specs Approval (OpenSpec)' job below."
exit 1
specs-fix-with-ai-approval:
name: Fix Specs with AI Approval
needs: specs-validate-with-openspec
if: always() && needs.specs-validate-with-openspec.outputs.validation-status == 'false'
runs-on: ubuntu-latest
environment:
name: specs-fix-with-ai-approval
steps:
- name: Approval granted
run: echo "Approval granted for fixing OpenSpec validation issues with AI"
specs-fix-with-ai:
name: Fix Specs with AI
needs: [specs-validate-with-openspec, specs-fix-with-ai-approval]
if: always() && needs.specs-validate-with-openspec.outputs.validation-status == 'false' && needs.specs-fix-with-ai-approval.result == 'success'
uses: ./.github/workflows/specs-fix-with-ai.yml
secrets: inherit
permissions:
contents: write
pull-requests: write
with:
summary: ${{ needs.specs-validate-with-openspec.outputs.validation-summary-json }}