-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (87 loc) · 3.25 KB
/
Copy pathvalidate-specs.yml
File metadata and controls
104 lines (87 loc) · 3.25 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
name: Validate Specs
on:
pull_request:
paths:
- "specs/**/*.spec.md"
- "packages/validate-specs/**"
- ".github/workflows/validate-specs.yml"
push:
branches: [ main ]
paths:
- "specs/**/*.spec.md"
- "packages/validate-specs/**"
- ".github/workflows/validate-specs.yml"
jobs:
validate-specs:
name: Validate Specs
runs-on: self-hosted
permissions:
contents: read
env:
DIAL_KEY: ${{ secrets.DIAL_KEY }}
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 dependencies
run: bun install
- name: Run specs validation
run: |
mkdir -p .specs-validation
touch .specs-validation/result.json
bun run validate-specs > .specs-validation/result.json
- name: Parse validation result
id: validation
run: |
RESULT=$(jq -r '.result' .specs-validation/result.json)
INVALID_COUNT=$(jq '[.violations[] | select(.severity=="INVALID")] | length' .specs-validation/result.json)
CONDITIONAL_COUNT=$(jq '[.violations[] | select(.severity=="CONDITIONAL")] | length' .specs-validation/result.json)
echo "result=$RESULT" >> "$GITHUB_OUTPUT"
echo "invalid_count=$INVALID_COUNT" >> "$GITHUB_OUTPUT"
echo "conditional_count=$CONDITIONAL_COUNT" >> "$GITHUB_OUTPUT"
- name: Render validation summary
if: always()
run: |
{
echo "# 📋 Specs Validation Result"
echo ""
echo "| Metric | Value |"
echo "|-------|-------|"
echo "| Result | **${{ steps.validation.outputs.result }}** |"
echo "| Critical violations | ${{ steps.validation.outputs.invalid_count }} |"
echo "| Conditional violations | ${{ steps.validation.outputs.conditional_count }} |"
echo ""
} >> "$GITHUB_STEP_SUMMARY"
- name: Render validation violations
if: steps.validation.outputs.result != 'VALID'
run: |
echo "## ❌ Violations" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Spec | Rule | Severity | Description |" >> "$GITHUB_STEP_SUMMARY"
echo "|------|------|----------|-------------|" >> "$GITHUB_STEP_SUMMARY"
jq -r '.violations[] |
"| \(.spec_id // "global") | \(.rule) | **\(.severity)** | \(.description) |"
' .specs-validation/result.json >> "$GITHUB_STEP_SUMMARY"
- name: Initiate spec fix pipeline
# if: steps.validation.outputs.result == 'INVALID'
uses: ./.github/workflows/fix-specs.yml
with:
summary: $GITHUB_STEP_SUMMARY
- name: Fail pipeline on failed validation
if: steps.validation.outputs.result == 'INVALID'
run: |
echo "❌ Specs validation failed"
exit 1