fix(agent-hooks): keep Node 18 relay companion loadable (#13135)
Co-authored-by: Jinwoo-H <Jinwoo-H@users.noreply.github.com>
This commit is contained in:
committed by
Jinwoo-H
co-authored by
Jinwoo-H
parent
5f3d5950d0
commit
985dbec060
@@ -97,6 +97,24 @@ describe('PR workflow parallelism', () => {
|
||||
expect(packageJson.scripts['build:release']).toContain('pnpm run build:web-from-renderer')
|
||||
})
|
||||
|
||||
it('smokes managed-hook companions under their supported Node 18 runtime', () => {
|
||||
const steps = workflow.jobs.managed_hook_node18.steps
|
||||
const installIndex = steps.findIndex(
|
||||
(step) => step.uses === './.github/actions/install-node-dependencies'
|
||||
)
|
||||
const buildIndex = steps.findIndex((step) => step.run === 'pnpm run build:relay')
|
||||
const node18Index = steps.findIndex(
|
||||
(step) => step.uses === 'actions/setup-node@v6' && step.with['node-version'] === '18'
|
||||
)
|
||||
const smokeIndex = steps.findIndex(
|
||||
(step) => step.run === 'node config/scripts/smoke-managed-hook-runtime-node18.mjs'
|
||||
)
|
||||
|
||||
expect(installIndex).toBeLessThan(buildIndex)
|
||||
expect(buildIndex).toBeLessThan(node18Index)
|
||||
expect(node18Index).toBeLessThan(smokeIndex)
|
||||
})
|
||||
|
||||
it('restores the pnpm store before dependency installation', () => {
|
||||
const steps = dependencyAction.runs.steps
|
||||
const pnpmIndex = steps.findIndex((step) => step.name === 'Setup pnpm')
|
||||
@@ -178,8 +196,14 @@ describe('PR workflow parallelism', () => {
|
||||
'git_compatibility',
|
||||
'shell_contracts',
|
||||
'test',
|
||||
'managed_hook_node18',
|
||||
'package',
|
||||
'package_windows'
|
||||
])
|
||||
const verifyStep = workflow.jobs.verify.steps.find(
|
||||
(step) => step.name === 'Require successful checks'
|
||||
)
|
||||
expect(verifyStep.env.MANAGED_HOOK_NODE18).toBe('${{ needs.managed_hook_node18.result }}')
|
||||
expect(verifyStep.run).toContain('"$MANAGED_HOOK_NODE18"')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import assert from 'node:assert/strict'
|
||||
import { constants } from 'node:fs'
|
||||
import { access, mkdtemp, readFile, rm } from 'node:fs/promises'
|
||||
import { createRequire } from 'node:module'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const PLATFORMS = [
|
||||
'linux-x64',
|
||||
'linux-arm64',
|
||||
'darwin-x64',
|
||||
'darwin-arm64',
|
||||
'win32-x64',
|
||||
'win32-arm64'
|
||||
]
|
||||
const ROOT = fileURLToPath(new URL('../..', import.meta.url))
|
||||
const require = createRequire(import.meta.url)
|
||||
|
||||
assert.match(process.versions.node, /^18\./, 'This smoke test must run under Node 18')
|
||||
|
||||
const home = await mkdtemp(join(tmpdir(), 'orca-managed-hook-node18-'))
|
||||
const originalHome = process.env.HOME
|
||||
const originalUserProfile = process.env.USERPROFILE
|
||||
const originalGetuid = process.getuid
|
||||
process.env.HOME = home
|
||||
process.env.USERPROFILE = home
|
||||
process.getuid = undefined
|
||||
|
||||
try {
|
||||
const runtimes = PLATFORMS.map((platform) => {
|
||||
const artifact = join(ROOT, 'out', 'relay', platform, 'managed-hook-runtime.js')
|
||||
const runtime = require(artifact)
|
||||
assert.equal(typeof runtime.installManagedHooks, 'function', `${platform} installer export`)
|
||||
return runtime
|
||||
})
|
||||
|
||||
const summary = await runtimes[0].installManagedHooks({ agents: ['codex', 'claude'] })
|
||||
assert.deepEqual(summary, { installers: 2, errors: 0 })
|
||||
|
||||
const codexHooks = await readFile(join(home, '.codex', 'hooks.json'), 'utf8')
|
||||
const claudeSettings = await readFile(join(home, '.claude', 'settings.json'), 'utf8')
|
||||
assert.match(codexHooks, /\.orca\/agent-hooks\/codex-hook\.sh/)
|
||||
assert.match(claudeSettings, /\.orca\/agent-hooks\/claude-hook\.sh/)
|
||||
await access(join(home, '.orca', 'agent-hooks', 'codex-hook.sh'), constants.X_OK)
|
||||
await access(join(home, '.orca', 'agent-hooks', 'claude-hook.sh'), constants.X_OK)
|
||||
} finally {
|
||||
if (originalHome === undefined) {
|
||||
delete process.env.HOME
|
||||
} else {
|
||||
process.env.HOME = originalHome
|
||||
}
|
||||
if (originalUserProfile === undefined) {
|
||||
delete process.env.USERPROFILE
|
||||
} else {
|
||||
process.env.USERPROFILE = originalUserProfile
|
||||
}
|
||||
process.getuid = originalGetuid
|
||||
await rm(home, { recursive: true, force: true })
|
||||
}
|
||||
|
||||
console.log('Node 18 managed-hook runtime smoke passed for all relay platforms.')
|
||||
Reference in New Issue
Block a user