feat: 회의 파일 가져오기와 입력 엔진 배포 보완
This commit is contained in:
parent
5a8c5cd792
commit
b3519e5da7
54 changed files with 1129 additions and 116 deletions
64
scripts/ci/lib/release-artifacts.mjs
Normal file
64
scripts/ci/lib/release-artifacts.mjs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import { createHash } from 'node:crypto'
|
||||
import { createReadStream } from 'node:fs'
|
||||
import { readFile, readdir, rename, stat, writeFile } from 'node:fs/promises'
|
||||
import { isAbsolute, join, relative, resolve, sep } from 'node:path'
|
||||
|
||||
const CHECKPOINT = 'release-artifacts.json'
|
||||
|
||||
function artifactPath(directory, name) {
|
||||
const path = resolve(directory, name)
|
||||
const rel = relative(resolve(directory), path)
|
||||
if (!rel || isAbsolute(rel) || rel === '..' || rel.startsWith(`..${sep}`)) {
|
||||
throw new Error(`Invalid release artifact path: ${name}`)
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
async function fingerprint(directory, name) {
|
||||
const path = artifactPath(directory, name)
|
||||
const info = await stat(path)
|
||||
if (!info.isFile()) throw new Error(`Release artifact is not a file: ${name}`)
|
||||
const hash = createHash('sha256')
|
||||
for await (const chunk of createReadStream(path)) hash.update(chunk)
|
||||
return { name, size: info.size, sha256: hash.digest('hex') }
|
||||
}
|
||||
|
||||
export async function saveReleaseArtifacts(directory, { version, tagCommit, withRuntime }) {
|
||||
const names = await readdir(directory)
|
||||
const installers = names.filter((name) => /-Setup-.*\.exe$/.test(name))
|
||||
if (installers.length !== 1) throw new Error('Expected exactly one release installer')
|
||||
const files = [installers[0], `${installers[0]}.blockmap`, 'latest.yml']
|
||||
if (withRuntime) {
|
||||
const portable = JSON.parse(await readFile(join(directory, 'portable.json'), 'utf8'))
|
||||
const runtime = JSON.parse(await readFile(join(directory, 'runtime', 'runtime.json'), 'utf8'))
|
||||
if (portable.version !== version || runtime.version !== version) throw new Error('Release index version mismatch')
|
||||
files.push('portable.json', 'd3ro-voice.scoop.json', 'runtime/runtime.json')
|
||||
for (const entry of [...portable.volumes, ...portable.zipParts]) files.push(entry.name)
|
||||
for (const component of Object.values(runtime.components)) {
|
||||
for (const part of component.parts) files.push(`runtime/${part.name}`)
|
||||
}
|
||||
}
|
||||
const artifacts = []
|
||||
for (const name of new Set(files)) artifacts.push(await fingerprint(directory, name))
|
||||
const checkpoint = { version, tagCommit, withRuntime, artifacts }
|
||||
const path = join(directory, CHECKPOINT)
|
||||
await writeFile(`${path}.tmp`, `${JSON.stringify(checkpoint, null, 2)}\n`)
|
||||
await rename(`${path}.tmp`, path)
|
||||
}
|
||||
|
||||
export async function verifyReleaseArtifacts(directory, expected) {
|
||||
const checkpoint = JSON.parse(await readFile(join(directory, CHECKPOINT), 'utf8'))
|
||||
for (const field of ['version', 'tagCommit', 'withRuntime']) {
|
||||
if (checkpoint[field] !== expected[field]) throw new Error(`Release checkpoint ${field} mismatch`)
|
||||
}
|
||||
if (!Array.isArray(checkpoint.artifacts) || checkpoint.artifacts.length < 3) {
|
||||
throw new Error('Release checkpoint has no complete artifact set')
|
||||
}
|
||||
for (const entry of checkpoint.artifacts) {
|
||||
const actual = await fingerprint(directory, entry.name)
|
||||
if (actual.size !== entry.size || actual.sha256 !== entry.sha256) {
|
||||
throw new Error(`Release artifact changed: ${entry.name}`)
|
||||
}
|
||||
}
|
||||
return checkpoint
|
||||
}
|
||||
63
scripts/ci/lib/release-artifacts.test.mjs
Normal file
63
scripts/ci/lib/release-artifacts.test.mjs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import assert from 'node:assert/strict'
|
||||
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import test from 'node:test'
|
||||
import { saveReleaseArtifacts, verifyReleaseArtifacts } from './release-artifacts.mjs'
|
||||
|
||||
const identity = { version: '1.16.0', tagCommit: 'a'.repeat(40), withRuntime: false }
|
||||
async function fixture(t) {
|
||||
const dir = await mkdtemp(join(tmpdir(), 'd3ro-release-checkpoint-'))
|
||||
t.after(() => rm(dir, { recursive: true, force: true }))
|
||||
for (const name of ['D3RO-Voice-Setup-1.16.0.exe', 'D3RO-Voice-Setup-1.16.0.exe.blockmap', 'latest.yml']) {
|
||||
await writeFile(join(dir, name), `original ${name}`)
|
||||
}
|
||||
await saveReleaseArtifacts(dir, identity)
|
||||
return dir
|
||||
}
|
||||
|
||||
test('reuses exact release bytes after a partial publication', async (t) => {
|
||||
const dir = await fixture(t)
|
||||
const verified = await verifyReleaseArtifacts(dir, identity)
|
||||
assert.equal(verified.artifacts.length, 3)
|
||||
})
|
||||
|
||||
test('rejects rebuilt bytes even when size is unchanged', async (t) => {
|
||||
const dir = await fixture(t)
|
||||
const path = join(dir, 'D3RO-Voice-Setup-1.16.0.exe')
|
||||
const original = await readFile(path, 'utf8')
|
||||
await writeFile(path, original.replace('original', 'modified'))
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, identity), /artifact changed/)
|
||||
})
|
||||
|
||||
test('rejects missing artifacts and a different source commit', async (t) => {
|
||||
const dir = await fixture(t)
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, { ...identity, tagCommit: 'b'.repeat(40) }), /tagCommit mismatch/)
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, { ...identity, withRuntime: true }), /withRuntime mismatch/)
|
||||
await rm(join(dir, 'latest.yml'))
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, identity), /ENOENT/)
|
||||
})
|
||||
|
||||
test('rejects paths outside the preserved release directory', async (t) => {
|
||||
const dir = await fixture(t)
|
||||
const path = join(dir, 'release-artifacts.json')
|
||||
const checkpoint = JSON.parse(await readFile(path, 'utf8'))
|
||||
checkpoint.artifacts[0].name = '../outside.exe'
|
||||
await writeFile(path, JSON.stringify(checkpoint))
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, identity), /Invalid release artifact path/)
|
||||
})
|
||||
|
||||
test('preserves runtime and portable parts and rejects missing runtime bytes', async (t) => {
|
||||
const dir = await fixture(t)
|
||||
await mkdir(join(dir, 'runtime'))
|
||||
await writeFile(join(dir, 'portable.json'), JSON.stringify({ version: identity.version, volumes: [{ name: 'portable.7z.001' }], zipParts: [{ name: 'portable.zip.001' }] }))
|
||||
await writeFile(join(dir, 'runtime/runtime.json'), JSON.stringify({ version: identity.version, components: { sidecar: { parts: [{ name: 'sidecar.tar.gz.001' }] } } }))
|
||||
for (const name of ['portable.7z.001', 'portable.zip.001', 'd3ro-voice.scoop.json', 'runtime/sidecar.tar.gz.001']) {
|
||||
await writeFile(join(dir, name), name)
|
||||
}
|
||||
const expected = { ...identity, withRuntime: true }
|
||||
await saveReleaseArtifacts(dir, expected)
|
||||
assert.equal((await verifyReleaseArtifacts(dir, expected)).artifacts.length, 9)
|
||||
await rm(join(dir, 'runtime/sidecar.tar.gz.001'))
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, expected), /ENOENT/)
|
||||
})
|
||||
|
|
@ -53,6 +53,13 @@ test("parseRuntimeMinVersions reads the app's real RUNTIME_MIN_VERSION (drift gu
|
|||
assert.equal(parsed.ffmpeg, null);
|
||||
});
|
||||
|
||||
test("the shipping app rejects the old feed without typing safety fixes", () => {
|
||||
const source = readFileSync(fileURLToPath(new URL(`../../../${RUNTIME_MIN_VERSION_SOURCE}`, import.meta.url)), "utf8");
|
||||
const minVersions = parseRuntimeMinVersions(source);
|
||||
assert.match(evaluateRuntimeFeed({ index: index({ version: "1.10.0" }), minVersions, target: WINDOWS_X64_TARGET }).join(" "), /below/);
|
||||
assert.deepEqual(evaluateRuntimeFeed({ index: index({ version: "1.16.0" }), minVersions, target: WINDOWS_X64_TARGET }), []);
|
||||
});
|
||||
|
||||
test("parseRuntimeMinVersions fails loudly when the constant cannot be read", () => {
|
||||
assert.throws(() => parseRuntimeMinVersions("export const OTHER = {}"), /RUNTIME_MIN_VERSION not found/);
|
||||
assert.throws(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue