| 1 | #!/usr/bin/env bash |
| 2 | set -euo pipefail |
| 3 | bun_binary="$(bun -p 'process.execPath')" |
| 4 | host_binary="$(node -p "require('path').join(process.env.RUNNER_TEMP, 'codewhale-extension-host' + (process.platform === 'win32' ? '.exe' : ''))")" |
| 5 | compiled_info="$(node crates/engine/extension-host/compile-host.mjs --bun "$bun_binary" --output "$host_binary")" |
| 6 | printf 'CODEWHALE_COMPILED_HOST_TEST_BINARY=%s\n' "$host_binary" >> "$GITHUB_ENV" |
| 7 | node - "$host_binary" "$bun_binary" "$compiled_info" >> "$GITHUB_ENV" <<'JS' |
| 8 | const fs = require('node:fs'), crypto = require('node:crypto'); |
| 9 | const digest = (file) => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex'); |
| 10 | const info = JSON.parse(process.argv[4]); |
| 11 | if (!info.platform || !info.arch || info.platform !== info.compiler?.platform || info.arch !== info.compiler?.arch) throw new Error('image/compiler identity mismatch'); |
| 12 | console.log('CODEWHALE_COMPILED_HOST_TEST_PLATFORM=' + info.platform); |
| 13 | console.log('CODEWHALE_COMPILED_HOST_TEST_ARCH=' + info.arch); |
| 14 | console.log('CODEWHALE_COMPILED_HOST_TEST_SHA256=' + digest(process.argv[2])); |
| 15 | console.log('CODEWHALE_COMPILED_HOST_TEST_BUN=' + process.argv[3]); |
| 16 | console.log('CODEWHALE_COMPILED_HOST_TEST_RUNTIME_SHA256=' + digest(process.argv[3])); |
| 17 | console.log('CODEWHALE_COMPILED_HOST_TEST_BUNDLE_SHA256=' + digest('crates/engine/extension-host/dist/codewhale-extension-host.mjs')); |
| 18 | JS |
| 19 |