diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07ae0e6..50b8ac2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,6 @@ concurrency: permissions: contents: read - pull-requests: read jobs: quality: @@ -70,12 +69,3 @@ jobs: ${{ runner.os }}-bun- - run: bun install --frozen-lockfile - run: bun run pack:check - - dependency-review: - if: github.event_name == 'pull_request' - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v4 - - uses: actions/dependency-review-action@v4 diff --git a/docs/en/pull-request-guide.md b/docs/en/pull-request-guide.md index b3b11d2..a503bb7 100644 --- a/docs/en/pull-request-guide.md +++ b/docs/en/pull-request-guide.md @@ -26,10 +26,10 @@ Use `.github/PULL_REQUEST_TEMPLATE.md` and include: ## Review Expectations -- at least one approval is required on `main` -- code owner review is required by branch protection +- pull requests are required for `main` - required CI checks must pass before merge -- stale approvals are dismissed when the PR changes +- conversations must be resolved before merge +- history must remain linear and force-pushes are blocked on `main` ## Merge Guidance diff --git a/docs/tr/pr-kilavuzu.md b/docs/tr/pr-kilavuzu.md index ae54100..64efa9e 100644 --- a/docs/tr/pr-kilavuzu.md +++ b/docs/tr/pr-kilavuzu.md @@ -24,10 +24,10 @@ bun run ci:verify ## Inceleme Kurallari -- `main` branch'i icin en az bir onay gerekir -- code owner incelemesi branch protection ile istenir +- `main` branch'i icin pull request zorunludur - zorunlu CI kontrolleri gecmeden merge yapilamaz -- PR degistiginde eski onaylar gecersiz olur +- tum konusmalar cozulmeden merge yapilamaz +- `main` branch'inde lineer history korunur ve force-push engellenir ## Merge Rehberi diff --git a/src/index.ts b/src/index.ts index 44301a0..433a1cb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,6 +39,11 @@ function extractGoal(parts: Array<{ type?: string; text?: string }>): string { async function runPipeline(ctx: PipelineStageContext): Promise { for (;;) { const pipeline = getPipelineBySession(ctx.db, ctx.sessionID) + + if (pipeline) { + ctx.pipelineId = pipeline.id + } + const state = pipeline?.state ?? "intake" if (state === "blocked" || state === "completed" || state === "failed") { diff --git a/tests/helpers/test-utils.ts b/tests/helpers/test-utils.ts index c6b1fc7..5ce7594 100644 --- a/tests/helpers/test-utils.ts +++ b/tests/helpers/test-utils.ts @@ -1,9 +1,16 @@ import { Database } from "bun:sqlite" import type { PluginInput } from "@opencode-ai/plugin" import type { ToolContext } from "@opencode-ai/plugin/tool" +import { mkdtempSync } from "node:fs" +import { tmpdir } from "node:os" +import { join } from "node:path" import { initializeDatabase } from "../../src/state/database.js" +function createTempProjectDirectory(): string { + return mkdtempSync(join(tmpdir(), "opencode-ceo-test-")) +} + export function createTestDatabase(): Database { const db = new Database(":memory:") initializeDatabase(db) @@ -11,9 +18,11 @@ export function createTestDatabase(): Database { } export function createMockPluginInput(): Pick { + const directory = createTempProjectDirectory() + return { - directory: "/tmp/test-project", - worktree: "/tmp/test-project", + directory, + worktree: directory, client: { session: { create: async () => ({ data: { id: "mock-session-id" } }), @@ -34,9 +43,11 @@ export function createMockPluginInput(): Pick {}, } } @@ -44,12 +55,15 @@ export function createMockToolContext() { export function createMockToolExecutionContext( overrides: Partial = {}, ): ToolContext { + const directory = overrides.directory ?? createTempProjectDirectory() + const worktree = overrides.worktree ?? directory + return { sessionID: "mock-session-id", messageID: "mock-message-id", agent: "ceo", - directory: "/tmp/test-project", - worktree: "/tmp/test-project", + directory, + worktree, abort: new AbortController().signal, metadata() {}, ask: async () => {}, diff --git a/tests/unit/github/git-utils.test.ts b/tests/unit/github/git-utils.test.ts index 7000c3e..355708d 100644 --- a/tests/unit/github/git-utils.test.ts +++ b/tests/unit/github/git-utils.test.ts @@ -1,7 +1,7 @@ import { afterEach, describe, expect, test } from "bun:test" import { mkdtempSync, rmSync } from "node:fs" import { tmpdir } from "node:os" -import { join } from "node:path" +import { join, resolve } from "node:path" import { $ } from "bun" import { @@ -13,7 +13,7 @@ import { } from "../../../src/github/git-utils.ts" const testDirectories: string[] = [] -const projectDirectory = "/home/ugur/Projects/opencode-ceo" +const projectDirectory = resolve(import.meta.dir, "../../..") function createTempDirectory(prefix: string): string { const directory = mkdtempSync(join(tmpdir(), prefix)) @@ -54,8 +54,10 @@ describe("git-utils", () => { }) test("getCurrentBranch returns a non-empty branch name", async () => { - expect(await getCurrentBranch(projectDirectory)).not.toHaveLength(0) - }) + const directory = await createGitRepo("opencode-ceo-current-branch-") + + expect(await getCurrentBranch(directory)).not.toHaveLength(0) + }) test("hasRemote resolves to a boolean without throwing", async () => { const result = await hasRemote(projectDirectory)