-
Notifications
You must be signed in to change notification settings - Fork 1
316 lines (259 loc) · 9.14 KB
/
ci.yml
File metadata and controls
316 lines (259 loc) · 9.14 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# Formatting check - only needs to run once since cargo fmt is purely textual
# (no compilation, so no platform-specific code paths like #[cfg(target_os)])
format:
name: Format Check
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.89"
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
bun-ecosystem:
name: Bun Ecosystem Checks
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- name: Setup Bun
uses: ./.github/actions/setup-bun
- name: Verify bun.lock hash integrity
run: |
set -euo pipefail
stored="$(bun pm hash-print | tr -d '\r\n')"
computed="$(bun pm hash | tr -d '\r\n')"
if [ -z "${stored}" ] || [ -z "${computed}" ]; then
echo "Failed to compute bun.lock hash."
exit 1
fi
if [ "${stored}" != "0000000000000000-0000000000000000-0000000000000000-0000000000000000" ] && [ "${stored}" != "${computed}" ]; then
echo "bun.lock hash mismatch."
echo "stored: ${stored}"
echo "computed: ${computed}"
exit 1
fi
git diff --exit-code -- bun.lock
- name: Audit dependencies
run: bun audit --audit-level=high
marketplace-validate:
name: Marketplace Packer Validate
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- name: Assert Marketplace scripts
run: |
test -f infra/digitalocean/marketplace/90-cleanup.sh
test -f infra/digitalocean/marketplace/99-img-check.sh
- name: Setup Packer
uses: hashicorp/setup-packer@v3
with:
version: "1.10.0"
- name: Packer init
run: packer init infra/digitalocean/packer/opencode-marketplace.pkr.hcl
- name: Packer fmt
run: packer fmt -check infra/digitalocean/packer/opencode-marketplace.pkr.hcl
- name: Packer validate
run: packer validate -var-file=infra/digitalocean/packer/variables.pkr.hcl infra/digitalocean/packer/opencode-marketplace.pkr.hcl
compose-validate:
name: Compose File Validate
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- name: Validate docker-compose.yml
run: docker compose config --quiet
docker-context-guard:
name: Docker Context Guard
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Use docker/build-push-action with GHA + registry cache so unchanged
# layers are reused across CI runs (~3 min → ~30s on cache hit).
# Previously this ran a bare `docker build` with no caching at all.
- name: Build Docker target stage
uses: docker/build-push-action@v6
with:
context: .
file: packages/core/src/docker/Dockerfile
target: opencode-build
push: false
load: false
cache-from: |
type=gha,scope=opencode-cloud-sandbox-context-guard,version=2
type=gha,scope=opencode-cloud-sandbox-amd64,version=2
type=registry,ref=ghcr.io/prizz/opencode-cloud-sandbox:buildcache-amd64
cache-to: type=gha,scope=opencode-cloud-sandbox-context-guard,mode=min,version=2
opencode-guardrails:
name: Opencode Guardrails
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- name: Initialize opencode submodule
run: |
git -c url."https://github.com/".insteadOf=git@github.com: submodule update --init --recursive packages/opencode
git submodule status --recursive
- name: Setup Bun
uses: ./.github/actions/setup-bun
- name: Install just
uses: extractions/setup-just@v3
- name: Ensure submodule dev ref exists
run: |
git -C packages/opencode show-ref --verify --quiet refs/heads/dev || git -C packages/opencode branch dev HEAD
- name: Run opencode guardrails
run: just check-opencode-guardrails
# Build, lint, and test on multiple platforms
# Clippy/build/test must run on each platform because #[cfg(target_os)] causes
# different code to compile (e.g., systemd.rs on Linux, launchd.rs on macOS)
build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 20
needs: [opencode-guardrails]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v6
- name: Verify opencode submodule pin is published
run: ./scripts/check-opencode-submodule-published.sh
- name: Install Linux system dependencies
if: matrix.os == 'ubuntu-latest'
run: |
# Required by opencode-broker (libpam-sys links against -lpam).
sudo apt-get update
sudo apt-get install -y libpam0g-dev
- name: Initialize opencode submodule
run: |
git -c url."https://github.com/".insteadOf=git@github.com: submodule update --init --recursive packages/opencode
git submodule status --recursive
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.89"
components: clippy
- name: Install just
uses: extractions/setup-just@v3
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20'
- name: Setup Bun
uses: ./.github/actions/setup-bun
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Configure git identity
run: |
git config --global user.email "bot@opencode.ai"
git config --global user.name "opencode"
# Project checks should run via shared just targets.
- name: Run CI checks
run: just ci-checks
- name: Record CLI parity SHA
if: matrix.os == 'ubuntu-latest'
run: git rev-parse HEAD > cli-parity.sha
- name: Upload CLI parity artifacts
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: cli-parity-artifacts
path: |
target/debug/opencode-cloud
packages/cli-node/dist
cli-parity.sha
# CLI Parity - ensures Node CLI can invoke all Rust CLI commands
cli-parity:
name: CLI Parity Tests
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [build]
steps:
- uses: actions/checkout@v6
- name: Install just
uses: extractions/setup-just@v3
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20'
- name: Setup Bun
uses: ./.github/actions/setup-bun
with:
install: "false"
- name: Download CLI parity artifacts
uses: actions/download-artifact@v4
with:
name: cli-parity-artifacts
- name: Verify artifact SHA
run: |
if [ -f cli-parity.sha ]; then
echo "Artifact SHA: $(cat cli-parity.sha)"
echo "Workflow SHA: $GITHUB_SHA"
test "$(cat cli-parity.sha)" = "$GITHUB_SHA"
fi
- name: Ensure Rust binary executable
run: chmod +x target/debug/opencode-cloud
- name: Install Node dependencies (cli only)
run: just ci-node-install-cli-only
- name: Run CLI parity tests
run: bun run --cwd packages/cli-node test
# E2E Tests - Playwright browser tests for the opencode web UI
e2e:
name: E2E Tests
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [build]
steps:
- uses: actions/checkout@v6
- name: Initialize opencode submodule
run: |
git -c url."https://github.com/".insteadOf=git@github.com: submodule update --init --recursive packages/opencode
git submodule status --recursive
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20'
- name: Setup Bun
uses: ./.github/actions/setup-bun
with:
install: "false"
- name: Configure git identity
run: |
git config --global user.email "bot@opencode.ai"
git config --global user.name "opencode"
- name: Install just
uses: extractions/setup-just@v3
- name: Run e2e tests
run: just ci-e2e
timeout-minutes: 30
- name: Upload Playwright artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-e2e-${{ github.run_attempt }}
if-no-files-found: ignore
retention-days: 7
path: |
packages/opencode/packages/app/e2e/test-results
packages/opencode/packages/app/e2e/playwright-report