Merge branch 'main' of github.com:mrbalov/strava-activity-image-gener… #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate Specs (OpenSpec) | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "openspec/**" | |
| - "packages/validate-specs/validate-specs-with-openspec/**" | |
| - ".github/workflows/validate-specs-openspec.yml" | |
| jobs: | |
| validate-specs-openspec: | |
| name: Validate Specs (OpenSpec) | |
| 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 dependencies | |
| run: bun install | |
| - name: Run OpenSpec validation | |
| id: validation | |
| run: | | |
| mkdir -p .specs-validation/openspec | |
| bun packages/validate-specs/validate-specs-with-openspec/index.ts --rootDir $(pwd) > .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 failures | |
| if: steps.parse-result.outputs.failed != '0' | |
| run: | | |
| echo "## ❌ Validation Issues" >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "| Spec ID | Level | Message |" >> "$GITHUB_STEP_SUMMARY" | |
| echo "|---------|-------|---------|" >> "$GITHUB_STEP_SUMMARY" | |
| jq -r '.items[] | select(.valid == false) | .id as $id | | |
| .issues[] | "| \($id) | \(.level) | \(.message | gsub("\n"; " ")) |" | |
| ' .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 | |
| fix-specs-approval: | |
| name: Fix Specs Approval (OpenSpec) | |
| needs: validate-specs-openspec | |
| if: always() && needs.validate-specs-openspec.outputs.validation-status == 'false' | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: fix-specs-approval | |
| steps: | |
| - name: Approval granted | |
| run: echo "Approval granted for fixing OpenSpec validation issues" | |
| fix-specs: | |
| name: Fix Specs (OpenSpec) | |
| needs: [validate-specs-openspec, fix-specs-approval] | |
| if: always() && needs.validate-specs-openspec.outputs.validation-status == 'false' && needs.fix-specs-approval.result == 'success' | |
| uses: ./.github/workflows/fix-specs.yml | |
| secrets: inherit | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| with: | |
| summary: ${{ needs.validate-specs-openspec.outputs.validation-summary-json }} |