mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 08:37:49 +00:00
test(e2e): skip contributor git hooks and signing when seeding fixture repos (#31591)
Global setup and the worker-scoped fallback now share one seedTestRepository() that runs its commit and worktree add with per-command `-c core.hooksPath=/dev/null -c commit.gpgsign=false`, so a contributor's global hooks or always-on signing no longer abort e2e before any spec runs, and the test repo's own hook config stays untouched for specs that install hooks. Fixes #31587 Co-authored-by: Neil <neil@stably.ai>
This commit is contained in:
@@ -90,6 +90,13 @@ export default function globalSetup(): void {
|
||||
prepareDockerSshHostImage(root)
|
||||
}
|
||||
|
||||
const testRepoDir = seedTestRepository()
|
||||
writeFileSync(TEST_REPO_PATH_FILE, testRepoDir)
|
||||
console.error(`[e2e] Test repo created at ${testRepoDir}`)
|
||||
}
|
||||
|
||||
// Shared by global setup and worker fallbacks so both seed paths stay identical.
|
||||
export function seedTestRepository(): string {
|
||||
// Resolve macOS /var symlinks like git does when registering repo.path.
|
||||
const testRepoDir = realpathSync(mkdtempSync(path.join(os.tmpdir(), 'orca-e2e-repo-')))
|
||||
|
||||
@@ -112,16 +119,18 @@ export default function globalSetup(): void {
|
||||
writeFileSync(path.join(testRepoDir, 'src', 'diff-note-layout.ts'), 'export const seed = true\n')
|
||||
|
||||
execSync('git add -A', { cwd: testRepoDir, stdio: 'pipe' })
|
||||
execSync('git commit -m "Initial commit for E2E tests"', { cwd: testRepoDir, stdio: 'pipe' })
|
||||
|
||||
// Seed a second worktree so retention/switching specs run instead of skipping.
|
||||
const worktreeDir = path.join(testRepoDir, '..', `orca-e2e-worktree-${randomUUID()}`)
|
||||
execSync(`git worktree add "${worktreeDir}" -b e2e-secondary`, {
|
||||
// Why: per-command -c so contributor global hooks/signing can't fail the seed without persisting into repo config.
|
||||
const isolatedGit = 'git -c core.hooksPath=/dev/null -c commit.gpgsign=false'
|
||||
execSync(`${isolatedGit} commit -m "Initial commit for E2E tests"`, {
|
||||
cwd: testRepoDir,
|
||||
stdio: 'pipe'
|
||||
})
|
||||
console.error(`[e2e] Secondary worktree created at ${worktreeDir}`)
|
||||
|
||||
writeFileSync(TEST_REPO_PATH_FILE, testRepoDir)
|
||||
console.error(`[e2e] Test repo created at ${testRepoDir}`)
|
||||
// Seed a second worktree so retention/switching specs run; UUIDs keep concurrent workers apart.
|
||||
const worktreeDir = path.join(testRepoDir, '..', `orca-e2e-worktree-${randomUUID()}`)
|
||||
execSync(`${isolatedGit} worktree add "${worktreeDir}" -b e2e-secondary`, {
|
||||
cwd: testRepoDir,
|
||||
stdio: 'pipe'
|
||||
})
|
||||
return testRepoDir
|
||||
}
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
import {
|
||||
existsSync,
|
||||
mkdirSync,
|
||||
mkdtempSync,
|
||||
readFileSync,
|
||||
realpathSync,
|
||||
rmSync,
|
||||
writeFileSync
|
||||
} from 'node:fs'
|
||||
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import { execSync } from 'node:child_process'
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import { TEST_REPO_PATH_FILE } from '../global-setup'
|
||||
import { seedTestRepository, TEST_REPO_PATH_FILE } from '../global-setup'
|
||||
import { cleanupTestRepository } from '../global-teardown'
|
||||
|
||||
export async function provideWorkerTestRepository(
|
||||
@@ -50,37 +39,7 @@ export function isValidGitRepo(repoPath: string): boolean {
|
||||
}
|
||||
|
||||
export function createSeededTestRepo(options: { publishPath?: boolean } = {}): string {
|
||||
// Canonicalize macOS /var symlinks to match Git’s repo.path after add.
|
||||
const testRepoDir = realpathSync(mkdtempSync(path.join(os.tmpdir(), 'orca-e2e-repo-')))
|
||||
|
||||
execSync('git init', { cwd: testRepoDir, stdio: 'pipe' })
|
||||
execSync('git config user.email "e2e@test.local"', { cwd: testRepoDir, stdio: 'pipe' })
|
||||
execSync('git config user.name "E2E Test"', { cwd: testRepoDir, stdio: 'pipe' })
|
||||
|
||||
writeFileSync(
|
||||
path.join(testRepoDir, 'README.md'),
|
||||
'# Orca E2E Test Repo\n\nThis repo was created automatically for Playwright tests.\n'
|
||||
)
|
||||
writeFileSync(path.join(testRepoDir, 'CLAUDE.md'), '# CLAUDE.md\n\nTest instructions for E2E.\n')
|
||||
writeFileSync(
|
||||
path.join(testRepoDir, 'package.json'),
|
||||
`${JSON.stringify({ name: 'orca-e2e-test', version: '0.0.0', private: true }, null, 2)}\n`
|
||||
)
|
||||
writeFileSync(path.join(testRepoDir, '.gitignore'), 'node_modules/\n')
|
||||
mkdirSync(path.join(testRepoDir, 'src'), { recursive: true })
|
||||
writeFileSync(path.join(testRepoDir, 'src', 'index.ts'), 'export const hello = "world"\n')
|
||||
writeFileSync(path.join(testRepoDir, 'src', 'diff-note-layout.ts'), 'export const seed = true\n')
|
||||
|
||||
execSync('git add -A', { cwd: testRepoDir, stdio: 'pipe' })
|
||||
execSync('git commit -m "Initial commit for E2E tests"', { cwd: testRepoDir, stdio: 'pipe' })
|
||||
|
||||
// Worker-scoped fallbacks can run together; UUIDs prevent temp worktree collisions.
|
||||
const worktreeDir = path.join(testRepoDir, '..', `orca-e2e-worktree-${randomUUID()}`)
|
||||
execSync(`git worktree add "${worktreeDir}" -b e2e-secondary`, {
|
||||
cwd: testRepoDir,
|
||||
stdio: 'pipe'
|
||||
})
|
||||
|
||||
const testRepoDir = seedTestRepository()
|
||||
if (options.publishPath !== false) {
|
||||
writeFileSync(TEST_REPO_PATH_FILE, testRepoDir)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user