|
| 1 | +name: Specs CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + |
| 8 | +jobs: |
| 9 | + specs: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + |
| 17 | + - name: Setup Bun |
| 18 | + uses: oven-sh/setup-bun@v2 |
| 19 | + |
| 20 | + - name: Install dependencies |
| 21 | + run: bun install --frozen-lockfile |
| 22 | + |
| 23 | + - name: Spec lint |
| 24 | + run: bun scripts/lint.ts |
| 25 | + |
| 26 | + - name: Discover targets |
| 27 | + id: targets |
| 28 | + shell: bash |
| 29 | + run: | |
| 30 | + set -euo pipefail |
| 31 | + TARGETS="$(find targets -maxdepth 1 -name '*.md' -type f -exec basename {} .md \; | sort | tr '\n' ' ')" |
| 32 | + TARGETS="$(echo "$TARGETS" | xargs)" |
| 33 | + if [ -z "$TARGETS" ]; then |
| 34 | + echo "No targets found under targets/*.md" >&2 |
| 35 | + exit 1 |
| 36 | + fi |
| 37 | + echo "targets=$TARGETS" >> "$GITHUB_OUTPUT" |
| 38 | + echo "Discovered targets: $TARGETS" |
| 39 | +
|
| 40 | + - name: Compiler health (all targets) |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + set -euo pipefail |
| 44 | + for t in ${{ steps.targets.outputs.targets }}; do |
| 45 | + echo "== status: $t ==" |
| 46 | + bun scripts/compile.ts status --target "$t" |
| 47 | + done |
| 48 | +
|
| 49 | + - name: Prompt generation smoke test (all targets) |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + set -euo pipefail |
| 53 | + for t in ${{ steps.targets.outputs.targets }}; do |
| 54 | + echo "== prompt: $t ==" |
| 55 | + bun scripts/compile.ts prompt --target "$t" |
| 56 | + done |
| 57 | +
|
| 58 | + - name: No generated output committed |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + set -euo pipefail |
| 62 | + if git ls-files --error-unmatch dist >/dev/null 2>&1; then |
| 63 | + echo "dist/ is tracked but must remain generated-only." >&2 |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | + if git diff --name-only "origin/${{ github.base_ref || 'main' }}"...HEAD | grep -E '^dist/'; then |
| 67 | + echo "PR includes files under dist/; remove generated output from commits." >&2 |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | +
|
| 71 | + - name: Changed-spec completeness |
| 72 | + if: github.event_name == 'pull_request' |
| 73 | + shell: bash |
| 74 | + run: | |
| 75 | + set -euo pipefail |
| 76 | + BASE="origin/${{ github.base_ref }}" |
| 77 | + git fetch --no-tags --depth=1 origin "${{ github.base_ref }}" |
| 78 | + CHANGED="$(git diff --name-only "$BASE"...HEAD)" |
| 79 | + FAIL=0 |
| 80 | + while IFS= read -r file; do |
| 81 | + [ -z "$file" ] && continue |
| 82 | + case "$file" in |
| 83 | + components/*/*.md) |
| 84 | + case "$file" in |
| 85 | + *.test.md|*.preview.md) continue ;; |
| 86 | + esac |
| 87 | + dir="$(dirname "$file")" |
| 88 | + name="$(basename "$file" .md)" |
| 89 | + test_file="$dir/$name.test.md" |
| 90 | + preview_file="$dir/$name.preview.md" |
| 91 | + if ! echo "$CHANGED" | grep -Fxq "$test_file"; then |
| 92 | + echo "Missing changed test spec: $test_file (required when $file changes)" >&2 |
| 93 | + FAIL=1 |
| 94 | + fi |
| 95 | + if ! echo "$CHANGED" | grep -Fxq "$preview_file"; then |
| 96 | + echo "Missing changed preview spec: $preview_file (required when $file changes)" >&2 |
| 97 | + FAIL=1 |
| 98 | + fi |
| 99 | + ;; |
| 100 | + esac |
| 101 | + done <<< "$CHANGED" |
| 102 | + [ "$FAIL" -eq 0 ] |
0 commit comments