* fix(bundles): write the build stamp before flavored icons land A flavored build (commit, canary, preview channel) copies its icons over the committed apps/desktop/assets before packaging. write-build-stamp ran after that copy, so its git check saw modified tracked files and stamped the bundle dirty, and the Windows smoke refused it (stamp.dirty: true != false), which keeps a channel from promoting the build. Stamp first, in both the CI driver (scripts/bundles/desktop.py) and the source build (build.mjs). The stamp reads no artwork, so its content is unchanged. * test(bundles): pin the build stamp ahead of the flavored icon copy buildSourceDesktop copies flavored icons over committed files in apps/desktop/assets. write-build-stamp asks git whether tracked files changed, so it has to run while the committed bytes are still there. The test records what the stamp step sees through the injectable run seam. It fails on the old order (sees the flavored icon) and passes on the new one.
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { basename, dirname, join } from 'node:path'
|
|
import { afterEach, test } from 'vitest'
|
|
|
|
import { buildSourceDesktop } from './build.mjs'
|
|
|
|
const roots = []
|
|
|
|
afterEach(() => {
|
|
for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true })
|
|
})
|
|
|
|
function put(path, text) {
|
|
mkdirSync(dirname(path), { recursive: true })
|
|
writeFileSync(path, text)
|
|
}
|
|
|
|
test('the install stamp is written while the committed assets are still in place', () => {
|
|
const root = mkdtempSync(join(tmpdir(), 'desktop-build-order-'))
|
|
roots.push(root)
|
|
const source = join(root, 'source')
|
|
const icons = join(root, 'icons')
|
|
const asset = join(source, 'apps/desktop/assets/icon.ico')
|
|
put(asset, 'committed icon')
|
|
put(join(icons, 'apps/desktop/assets/icon.ico'), 'flavored icon')
|
|
|
|
// write-build-stamp asks git whether tracked files changed, so it must see
|
|
// the committed bytes, not the flavored copy.
|
|
let seenByStamp
|
|
buildSourceDesktop({
|
|
source,
|
|
icons,
|
|
run: (_command, [script]) => {
|
|
if (basename(script) === 'write-build-stamp.mjs') seenByStamp = readFileSync(asset, 'utf8')
|
|
}
|
|
})
|
|
|
|
assert.equal(seenByStamp, 'committed icon')
|
|
assert.equal(readFileSync(asset, 'utf8'), 'flavored icon')
|
|
})
|