|
| 1 | +# PR-time test gate. Keeps the merge path fast while preserving slower |
| 2 | +# compatibility checks on master/manual runs. |
| 3 | +# |
| 4 | +# Two jobs: |
| 5 | +# - lint: documentation drift, go vet, gofmt cleanliness. The whole bundled |
| 6 | +# tree (registry/skills/_templates/_web) is gitignored and regenerated |
| 7 | +# via `task sync-bundled` + `task sync-web`, both of which run as deps |
| 8 | +# of `task vet` — so vet implicitly bootstraps the bundle here. |
| 9 | +# - test: Linux PR gate, builds bin/one then runs `go test ./...`. |
| 10 | +# Build is required because internal/cli/snapshot_e2e_test.go skips when |
| 11 | +# bin/one is missing. Race + macOS checks run on master/manual triggers only. |
| 12 | +# |
| 13 | +# Both jobs need Node + pnpm because sync-web runs `pnpm install` + |
| 14 | +# `vite build` against apps/dashboard/. |
| 15 | +# |
| 16 | +# Runners: |
| 17 | +# - ubuntu-latest for PR checks |
| 18 | +# - macos-latest for master/manual compatibility checks |
| 19 | +# |
| 20 | +# Windows is deferred until testdata/bin/ has .bat siblings of the POSIX |
| 21 | +# shell stubs (Phase 3 in the test plan). |
| 22 | + |
| 23 | +name: CI |
| 24 | + |
| 25 | +on: |
| 26 | + pull_request: |
| 27 | + push: |
| 28 | + branches: [master] |
| 29 | + workflow_dispatch: |
| 30 | + |
| 31 | +concurrency: |
| 32 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 33 | + cancel-in-progress: true |
| 34 | + |
| 35 | +permissions: |
| 36 | + contents: read |
| 37 | + |
| 38 | +env: |
| 39 | + # GitHub-hosted runners are outside China; the default Taskfile proxy |
| 40 | + # (goproxy.cn) is slower/flakier there and has caused CI download failures. |
| 41 | + GOPROXY: https://proxy.golang.org,direct |
| 42 | + |
| 43 | +jobs: |
| 44 | + lint: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Set up Go |
| 50 | + uses: actions/setup-go@v5 |
| 51 | + with: |
| 52 | + go-version-file: packages/cli/go.mod |
| 53 | + cache: true |
| 54 | + cache-dependency-path: packages/cli/go.sum |
| 55 | + |
| 56 | + - name: Set up pnpm |
| 57 | + uses: pnpm/action-setup@v4 |
| 58 | + with: |
| 59 | + # packageManager pin in apps/dashboard/package.json drives version selection. |
| 60 | + run_install: false |
| 61 | + |
| 62 | + - name: Set up Node |
| 63 | + uses: actions/setup-node@v4 |
| 64 | + with: |
| 65 | + node-version: 20 |
| 66 | + cache: pnpm |
| 67 | + cache-dependency-path: apps/dashboard/pnpm-lock.yaml |
| 68 | + |
| 69 | + - name: Install task |
| 70 | + run: go install github.com/go-task/task/v3/cmd/task@latest |
| 71 | + |
| 72 | + - name: Download Go modules |
| 73 | + working-directory: packages/cli |
| 74 | + run: go mod download |
| 75 | + |
| 76 | + - name: Verify documentation in sync |
| 77 | + run: task verify-docs |
| 78 | + |
| 79 | + - name: go vet |
| 80 | + # Implicitly runs sync-bundled + sync-web first, materialising the |
| 81 | + # gitignored bundle so the //go:embed directives compile. |
| 82 | + run: task vet |
| 83 | + |
| 84 | + - name: Check gofmt |
| 85 | + working-directory: packages/cli |
| 86 | + run: | |
| 87 | + changed=$(gofmt -l .) |
| 88 | + if [ -n "$changed" ]; then |
| 89 | + echo "Files need gofmt — run 'task fmt' locally:" >&2 |
| 90 | + echo "$changed" >&2 |
| 91 | + exit 1 |
| 92 | + fi |
| 93 | +
|
| 94 | + test: |
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v4 |
| 98 | + |
| 99 | + - name: Set up Go |
| 100 | + uses: actions/setup-go@v5 |
| 101 | + with: |
| 102 | + go-version-file: packages/cli/go.mod |
| 103 | + cache: true |
| 104 | + cache-dependency-path: packages/cli/go.sum |
| 105 | + |
| 106 | + - name: Set up pnpm |
| 107 | + uses: pnpm/action-setup@v4 |
| 108 | + with: |
| 109 | + run_install: false |
| 110 | + |
| 111 | + - name: Set up Node |
| 112 | + uses: actions/setup-node@v4 |
| 113 | + with: |
| 114 | + node-version: 20 |
| 115 | + cache: pnpm |
| 116 | + cache-dependency-path: apps/dashboard/pnpm-lock.yaml |
| 117 | + |
| 118 | + - name: Install task |
| 119 | + run: go install github.com/go-task/task/v3/cmd/task@latest |
| 120 | + |
| 121 | + - name: Download Go modules |
| 122 | + working-directory: packages/cli |
| 123 | + run: go mod download |
| 124 | + |
| 125 | + - name: Build binary |
| 126 | + run: task build |
| 127 | + |
| 128 | + - name: Run tests |
| 129 | + working-directory: packages/cli |
| 130 | + run: go test ./... |
| 131 | + |
| 132 | + test-race: |
| 133 | + # Race tests are useful but slow on GitHub-hosted runners. Keep them off |
| 134 | + # the PR critical path and run them before/after merging to master. |
| 135 | + if: github.event_name != 'pull_request' |
| 136 | + runs-on: ubuntu-latest |
| 137 | + steps: |
| 138 | + - uses: actions/checkout@v4 |
| 139 | + |
| 140 | + - name: Set up Go |
| 141 | + uses: actions/setup-go@v5 |
| 142 | + with: |
| 143 | + go-version-file: packages/cli/go.mod |
| 144 | + cache: true |
| 145 | + cache-dependency-path: packages/cli/go.sum |
| 146 | + |
| 147 | + - name: Set up pnpm |
| 148 | + uses: pnpm/action-setup@v4 |
| 149 | + with: |
| 150 | + run_install: false |
| 151 | + |
| 152 | + - name: Set up Node |
| 153 | + uses: actions/setup-node@v4 |
| 154 | + with: |
| 155 | + node-version: 20 |
| 156 | + cache: pnpm |
| 157 | + cache-dependency-path: apps/dashboard/pnpm-lock.yaml |
| 158 | + |
| 159 | + - name: Install task |
| 160 | + run: go install github.com/go-task/task/v3/cmd/task@latest |
| 161 | + |
| 162 | + - name: Download Go modules |
| 163 | + working-directory: packages/cli |
| 164 | + run: go mod download |
| 165 | + |
| 166 | + - name: Build binary |
| 167 | + run: task build |
| 168 | + |
| 169 | + - name: Run tests |
| 170 | + run: task test |
| 171 | + |
| 172 | + test-macos: |
| 173 | + # macOS runners are slower to start and are scarce on PRs. Keep the |
| 174 | + # cross-platform signal for master/manual runs without making every PR wait. |
| 175 | + if: github.event_name != 'pull_request' |
| 176 | + runs-on: macos-latest |
| 177 | + steps: |
| 178 | + - uses: actions/checkout@v4 |
| 179 | + |
| 180 | + - name: Set up Go |
| 181 | + uses: actions/setup-go@v5 |
| 182 | + with: |
| 183 | + go-version-file: packages/cli/go.mod |
| 184 | + cache: true |
| 185 | + cache-dependency-path: packages/cli/go.sum |
| 186 | + |
| 187 | + - name: Set up pnpm |
| 188 | + uses: pnpm/action-setup@v4 |
| 189 | + with: |
| 190 | + run_install: false |
| 191 | + |
| 192 | + - name: Set up Node |
| 193 | + uses: actions/setup-node@v4 |
| 194 | + with: |
| 195 | + node-version: 20 |
| 196 | + cache: pnpm |
| 197 | + cache-dependency-path: apps/dashboard/pnpm-lock.yaml |
| 198 | + |
| 199 | + - name: Install task |
| 200 | + run: go install github.com/go-task/task/v3/cmd/task@latest |
| 201 | + |
| 202 | + - name: Download Go modules |
| 203 | + working-directory: packages/cli |
| 204 | + run: go mod download |
| 205 | + |
| 206 | + - name: Build binary |
| 207 | + run: task build |
| 208 | + |
| 209 | + - name: Run tests |
| 210 | + working-directory: packages/cli |
| 211 | + run: go test ./... |
0 commit comments