GeezerVison is showing github.com — chore: use paid zen model in e2e · Pablo-GNU/opencode@85c1692
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/test.yml +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -100,6 +100,9 @@ jobs: | 100 | 100 | run: bun --cwd packages/app test:e2e:local | 101 | 101 | env: | 102 | 102 | CI: true | | 103 | + OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} | | 104 | + OPENCODE_E2E_MODEL: opencode/claude-haiku-4-5 | | 105 | + OPENCODE_E2E_REQUIRE_PAID: "true" | 103 | 106 | timeout-minutes: 30 | 104 | 107 |
| 105 | 108 | - name: Upload Playwright artifacts | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/fixtures.ts +13-3Lines changed: 13 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,6 +15,16 @@ import { createSdk, dirSlug, getWorktree, sessionPath } from "./utils" | 15 | 15 |
| 16 | 16 | export const settingsKey = "settings.v3" | 17 | 17 |
| | 18 | +const seedModel = (() => { | | 19 | + const [providerID = "opencode", modelID = "big-pickle"] = ( | | 20 | + process.env.OPENCODE_E2E_MODEL ?? "opencode/big-pickle" | | 21 | + ).split("/") | | 22 | + return { | | 23 | + providerID: providerID || "opencode", | | 24 | + modelID: modelID || "big-pickle", | | 25 | + } | | 26 | +})() | | 27 | + | 18 | 28 | type TestFixtures = { | 19 | 29 | sdk: ReturnType<typeof createSdk> | 20 | 30 | gotoSession: (sessionID?: string) => Promise<void> | @@ -125,7 +135,7 @@ export const test = base.extend<TestFixtures, WorkerFixtures>({ | 125 | 135 |
| 126 | 136 | async function seedStorage(page: Page, input: { directory: string; extra?: string[] }) { | 127 | 137 | await seedProjects(page, input) | 128 | | - await page.addInitScript(() => { | | 138 | + await page.addInitScript((model: { providerID: string; modelID: string }) => { | 129 | 139 | const win = window as E2EWindow | 130 | 140 | win.__opencode_e2e = { | 131 | 141 | ...win.__opencode_e2e, | @@ -143,12 +153,12 @@ async function seedStorage(page: Page, input: { directory: string; extra?: strin | 143 | 153 | localStorage.setItem( | 144 | 154 | "opencode.global.dat:model", | 145 | 155 | JSON.stringify({ | 146 | | - recent: [{ providerID: "opencode", modelID: "big-pickle" }], | | 156 | + recent: [model], | 147 | 157 | user: [], | 148 | 158 | variant: {}, | 149 | 159 | }), | 150 | 160 | ) | 151 | | - }) | | 161 | + }, seedModel) | 152 | 162 | } | 153 | 163 |
| 154 | 164 | export { expect } |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/script/seed-e2e.ts +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@ const dir = process.env.OPENCODE_E2E_PROJECT_DIR ?? process.cwd() | 2 | 2 | const title = process.env.OPENCODE_E2E_SESSION_TITLE ?? "E2E Session" | 3 | 3 | const text = process.env.OPENCODE_E2E_MESSAGE ?? "Seeded for UI e2e" | 4 | 4 | const model = process.env.OPENCODE_E2E_MODEL ?? "opencode/gpt-5-nano" | | 5 | +const requirePaid = process.env.OPENCODE_E2E_REQUIRE_PAID === "true" | 5 | 6 | const parts = model.split("/") | 6 | 7 | const providerID = parts[0] ?? "opencode" | 7 | 8 | const modelID = parts[1] ?? "gpt-5-nano" | @@ -11,6 +12,7 @@ const seed = async () => { | 11 | 12 | const { Instance } = await import("../src/project/instance") | 12 | 13 | const { InstanceBootstrap } = await import("../src/project/bootstrap") | 13 | 14 | const { Config } = await import("../src/config/config") | | 15 | + const { Provider } = await import("../src/provider/provider") | 14 | 16 | const { Session } = await import("../src/session") | 15 | 17 | const { MessageID, PartID } = await import("../src/session/schema") | 16 | 18 | const { Project } = await import("../src/project/project") | @@ -25,6 +27,19 @@ const seed = async () => { | 25 | 27 | await Config.waitForDependencies() | 26 | 28 | await ToolRegistry.ids() | 27 | 29 |
| | 30 | + if (requirePaid && providerID === "opencode" && !process.env.OPENCODE_API_KEY) { | | 31 | + throw new Error("OPENCODE_API_KEY is required when OPENCODE_E2E_REQUIRE_PAID=true") | | 32 | + } | | 33 | + | | 34 | + const info = await Provider.getModel(ProviderID.make(providerID), ModelID.make(modelID)) | | 35 | + if (requirePaid) { | | 36 | + const paid = | | 37 | + info.cost.input > 0 || info.cost.output > 0 || info.cost.cache.read > 0 || info.cost.cache.write > 0 | | 38 | + if (!paid) { | | 39 | + throw new Error(`OPENCODE_E2E_MODEL must resolve to a paid model: ${providerID}/${modelID}`) | | 40 | + } | | 41 | + } | | 42 | + | 28 | 43 | const session = await Session.create({ title }) | 29 | 44 | const messageID = MessageID.ascending() | 30 | 45 | const partID = PartID.ascending() | |
|