mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 18:37:24 +00:00
The Worker-started source build used the VM scripts, provision script and manifest pins embedded in
the Worker that started it, so a golden built from a newer commit could miss that commit's new VM
scripts (seen live: snap_HTsU from 19f900e has #122's orcad but not orca-desktop-proxy or
orca-desktop-page.js). source-build.sh now sources image/commit-provision-env.mjs from the fetched
checkout (no dependencies; mirrors provisionEnv, enforced by a test), so the image ships exactly that
commit. Tests also require every image/vm file to be a declared VM script and installed by provision.
26 lines
1.5 KiB
TypeScript
26 lines
1.5 KiB
TypeScript
import { readdirSync, readFileSync } from 'node:fs'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { describe, expect, it } from 'vitest'
|
|
// @ts-expect-error -- plain .mjs helper (runs before dependencies are installed); no type declarations
|
|
import { commitProvisionEnv } from './commit-provision-env.mjs'
|
|
import { VM_SCRIPTS, provisionEnv, type BuildInputs } from './golden-image'
|
|
|
|
const here = (path: string) => fileURLToPath(new URL(path, import.meta.url).href)
|
|
|
|
describe('commit-provision-env.mjs (source builds provision with the fetched commit\'s image files)', () => {
|
|
it('matches provisionEnv for this checkout, so Worker-started and operator builds provision the same', () => {
|
|
const manifest = JSON.parse(readFileSync(here('./golden-image.manifest.json'), 'utf8'))
|
|
const vmScripts = Object.fromEntries(VM_SCRIPTS.map((name) => [name, readFileSync(here(`./vm/${name}`), 'utf8')])) as BuildInputs['vmScripts']
|
|
const expected = provisionEnv({ manifest, provisionScript: '', vmScripts, buildId: 'x' })
|
|
delete expected.ORCAD_BUNDLE_URL
|
|
delete expected.ORCAD_BUNDLE_SHA256
|
|
expect(commitProvisionEnv(here('.'))).toEqual(expected)
|
|
})
|
|
|
|
it('every image/vm file is a declared VM script and installed by provision (none silently left out)', () => {
|
|
expect(readdirSync(here('./vm')).sort()).toEqual([...VM_SCRIPTS].sort())
|
|
const loop = /for name in ([^;]+); do\n\s+var="ORCA_VM_SCRIPT_/.exec(readFileSync(here('./provision-golden.sh'), 'utf8'))
|
|
expect(loop?.[1]?.trim().split(/\s+/).sort()).toEqual([...VM_SCRIPTS].sort())
|
|
})
|
|
})
|