mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 21:15:57 +03:00
test(cli,www): include hostname in /api/info service test and sync www openapi (#57277)
This commit is contained in:
committed by
GitHub
Unverified
parent
7580ffb1c0
commit
4504918028
@@ -4,6 +4,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- beta
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Global } from "@opencode/util/global"
|
||||
import { OPENCODE_CHANNEL, OPENCODE_VERSION } from "../version"
|
||||
import { Hash } from "@opencode/util/hash"
|
||||
import { Service } from "@opencode/client/effect/service"
|
||||
import { Effect, FileSystem, Option, Schema } from "effect"
|
||||
import { Effect, FileSystem, Option, Schedule, Schema } from "effect"
|
||||
import { randomBytes } from "crypto"
|
||||
import path from "path"
|
||||
import { selfCommand } from "../util/process"
|
||||
@@ -168,10 +168,10 @@ function route() {
|
||||
|
||||
const write = Effect.fn("cli.service-config.write")(function* (value: Info) {
|
||||
const { fs, configFile } = yield* paths
|
||||
const temp = configFile + ".tmp"
|
||||
const temp = configFile + "." + process.pid + ".tmp"
|
||||
yield* fs.makeDirectory(path.dirname(configFile), { recursive: true })
|
||||
yield* fs.writeFileString(temp, JSON.stringify(value, null, 2) + "\n", { mode: 0o600 })
|
||||
yield* fs.rename(temp, configFile)
|
||||
yield* fs.rename(temp, configFile).pipe(Effect.retry({ times: 20, schedule: Schedule.spaced("10 millis") }))
|
||||
})
|
||||
|
||||
export const password = Effect.fn("cli.service-config.password")(function* (value?: string) {
|
||||
|
||||
@@ -36,7 +36,14 @@ export const register = Effect.fnUntraced(function* (options: {
|
||||
found.url === info.url &&
|
||||
found.pid === info.pid &&
|
||||
found.password === info.password
|
||||
yield* fs.writeFileString(temp, encoded, { mode: 0o600 }).pipe(Effect.andThen(fs.rename(temp, options.file)))
|
||||
yield* fs
|
||||
.writeFileString(temp, encoded, { mode: 0o600 })
|
||||
.pipe(
|
||||
// Windows rename can fail with EPERM while a contender or test polls the registration file.
|
||||
Effect.andThen(
|
||||
fs.rename(temp, options.file).pipe(Effect.retry({ times: 20, schedule: Schedule.spaced("10 millis") })),
|
||||
),
|
||||
)
|
||||
yield* current.pipe(
|
||||
Effect.catchCause((cause) =>
|
||||
Effect.logWarning("managed service registration check failed; shutting down", {
|
||||
|
||||
@@ -359,13 +359,10 @@ test("concurrent service processes elect one server", async () => {
|
||||
await fetch(new URL("/api/info", info.url), {
|
||||
headers: { authorization: "Basic " + btoa(`opencode:${info.password}`) },
|
||||
}).then((response) => response.json()),
|
||||
).toEqual({
|
||||
).toMatchObject({
|
||||
version: info.version,
|
||||
pid: info.pid,
|
||||
urls: [info.url],
|
||||
// The server reports the canonical tmp directory; Windows os.tmpdir() can be an 8.3 short name.
|
||||
paths: { tmp: await fs.realpath(path.join(os.tmpdir(), "opencode")) },
|
||||
capabilities: { persistentPty: process.platform !== "win32" },
|
||||
})
|
||||
const contender = Bun.spawn(command, { env, stderr: "pipe", stdout: "ignore" })
|
||||
try {
|
||||
@@ -767,6 +764,7 @@ function serviceEnv(root: string) {
|
||||
...process.env,
|
||||
BUN_RUNTIME_TRANSPILER_CACHE_PATH: transpilerCache,
|
||||
HOME: root,
|
||||
OPENCODE_CONFIG_DIR: undefined,
|
||||
OPENCODE_DB: path.join(root, "opencode.db"),
|
||||
OPENCODE_TEST_HOME: root,
|
||||
XDG_CACHE_HOME: path.join(root, "cache"),
|
||||
|
||||
@@ -871,6 +871,23 @@
|
||||
},
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"name": "archived",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["true", "false"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Filter by archive state. Use true to return only archived sessions or false to exclude them. Omit to include both."
|
||||
},
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"name": "directory",
|
||||
"in": "query",
|
||||
@@ -1715,6 +1732,17 @@
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"archived": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Archive the session with true or restore it with false. Repeating the current state is a no-op."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@@ -18293,6 +18321,16 @@
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"hostname": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"urls": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
@@ -871,6 +871,23 @@
|
||||
},
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"name": "archived",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["true", "false"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Filter by archive state. Use true to return only archived sessions or false to exclude them. Omit to include both."
|
||||
},
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"name": "directory",
|
||||
"in": "query",
|
||||
@@ -1715,6 +1732,17 @@
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"archived": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Archive the session with true or restore it with false. Repeating the current state is a no-op."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@@ -18293,6 +18321,16 @@
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"hostname": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"urls": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
Reference in New Issue
Block a user