Updater from public releases, English UI by default with Russian selectable, cancelable capture, English technical messages, language-independent smoke hooks
ci / linux-arm64-cross (push) Successful in 1m54s
ci / linux-x64 (push) Successful in 2m45s

This commit is contained in:
omar committed 2026-10-24 06:34:33 +03:00
1 parent ba4c7ec2af
commit 1142c9f60d
53 files changed
+4005 -549

No files matched your search

+5 -2
View File
@@ -1,5 +1,7 @@
// On a tag build, refuses to continue unless the tag equals v<package.json version> and the core's
// Cargo package version is the same. Branch/manual builds pass through.
// Cargo package version is the same. A release candidate (package.json 0.1.2-rc.1) ships the core of
// its target version (0.1.2), so for prerelease app versions the core must equal the version without
// the prerelease part. Branch/manual builds pass through.
// GITHUB_REF=refs/tags/v0.1.0 node scripts/check-version.mjs
import { readFileSync } from 'node:fs';
import path from 'node:path';
@@ -10,7 +12,8 @@ const app = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8')).ve
const cargo = /^\[package\][\s\S]*?^version\s*=\s*"([^"]+)"/m.exec(readFileSync(path.join(root, 'core', 'Cargo.toml'), 'utf8'))?.[1];
const ref = process.env.GITHUB_REF ?? '';
console.log(`package.json ${app}, core Cargo.toml ${cargo}, ref ${ref || '(none)'}`);
if (app !== cargo) {
const rc = /^(\d+\.\d+\.\d+)-rc\.\d+$/.exec(app);
if (app !== cargo && !(rc && rc[1] === cargo)) {
console.error('package.json and core/Cargo.toml versions differ');
process.exit(1);
}
+58 -11
View File
@@ -3,18 +3,33 @@
// The token is read only from the environment (TOKEN) and never printed or passed as an argument.
//
// TOKEN=… API=https://host/api/v1/repos/owner/repo TAG=v0.1.0 node scripts/publish-release.mjs <asset-dir> [notes-file]
// TOKEN=… API=… TAG=v0.1.2 node scripts/publish-release.mjs --append <asset-dir>
//
// --append adds assets (e.g. the locally built Windows packages) to the already published release of TAG;
// it refuses to replace an existing asset name.
//
// Update feeds (*.yml) are checked before anything is uploaded: every package a feed references must be in
// the same directory with the exact name, size and sha512 the feed declares, and the feed version must equal
// the tag. Feeds are uploaded after all packages, so clients never see a feed whose package is not there yet.
// The release is marked prerelease unless PRERELEASE=false is set and the tag has no prerelease part.
import { readdirSync, readFileSync, statSync } from 'node:fs';
import path from 'node:path';
import { checkFeed } from './update-feed-check.mjs';
const { TOKEN, API, TAG } = process.env;
const assetDir = process.argv[2];
const notesFile = process.argv[3];
const args = process.argv.slice(2);
const append = args[0] === '--append';
if (append) args.shift();
const assetDir = args[0];
const notesFile = args[1];
for (const [name, value] of Object.entries({ TOKEN, API, TAG, assetDir })) {
if (!value) {
console.error(`missing ${name}`);
process.exit(2);
}
}
const version = TAG.replace(/^v/, '');
const prerelease = process.env.PRERELEASE !== 'false' || version.includes('-');
function collect(dir) {
const files = [];
@@ -33,7 +48,9 @@ async function request(method, url, body, headers = {}) {
return text ? JSON.parse(text) : null;
}
const files = collect(assetDir);
const isFeed = (f) => f.endsWith('.yml');
// Packages first, feeds last.
const files = collect(assetDir).sort((a, b) => isFeed(a) - isFeed(b));
if (files.length === 0) {
console.error(`no assets in ${assetDir}`);
process.exit(1);
@@ -47,18 +64,48 @@ for (const f of files) {
}
names.add(n);
}
for (const feed of files.filter(isFeed)) {
try {
const referenced = await checkFeed(feed, { version });
console.log(`feed ${path.basename(feed)} ok: ${referenced.join(', ')}`);
} catch (err) {
console.error(`feed check failed: ${err.message}`);
process.exit(1);
}
}
async function upload(releaseId, file) {
const form = new FormData();
form.append('attachment', new Blob([readFileSync(file)]), path.basename(file));
const asset = await request('POST', `${API}/releases/${releaseId}/assets?name=${encodeURIComponent(path.basename(file))}`, form);
if (asset.name !== path.basename(file) || asset.size !== statSync(file).size) {
throw new Error(`server stored ${asset.name} (${asset.size} bytes) for ${path.basename(file)} (${statSync(file).size} bytes)`);
}
console.log(`uploaded ${asset.name} (${asset.size} bytes)`);
}
if (append) {
try {
const release = await request('GET', `${API}/releases/tags/${encodeURIComponent(TAG)}`);
if (release.draft) throw new Error(`release ${TAG} is a draft; publish it first`);
const existing = new Set((release.assets || []).map((a) => a.name));
const clash = files.map((f) => path.basename(f)).filter((n) => existing.has(n));
if (clash.length > 0) throw new Error(`release ${TAG} already has ${clash.join(', ')}`);
for (const file of files) await upload(release.id, file);
console.log(`appended ${files.length} assets to ${TAG}`);
} catch (err) {
console.error(`append failed: ${err.message}`);
process.exit(1);
}
process.exit(0);
}
const body = notesFile ? readFileSync(notesFile, 'utf8') : '';
let release = null;
try {
release = await request('POST', `${API}/releases`, JSON.stringify({ tag_name: TAG, name: `TeamsPeach ${TAG}`, body, draft: true, prerelease: true }), { 'Content-Type': 'application/json' });
console.log(`draft release ${release.id} created for ${TAG}`);
for (const file of files) {
const form = new FormData();
form.append('attachment', new Blob([readFileSync(file)]), path.basename(file));
const asset = await request('POST', `${API}/releases/${release.id}/assets?name=${encodeURIComponent(path.basename(file))}`, form);
console.log(`uploaded ${asset.name} (${asset.size} bytes)`);
}
release = await request('POST', `${API}/releases`, JSON.stringify({ tag_name: TAG, name: `TeamsPeach ${TAG}`, body, draft: true, prerelease }), { 'Content-Type': 'application/json' });
console.log(`draft release ${release.id} created for ${TAG} (prerelease: ${prerelease})`);
for (const file of files) await upload(release.id, file);
await request('PATCH', `${API}/releases/${release.id}`, JSON.stringify({ draft: false }), { 'Content-Type': 'application/json' });
console.log(`release ${TAG} published with ${files.length} assets`);
} catch (err) {
+3 -2
View File
@@ -105,11 +105,12 @@ try {
await page.waitForTimeout(1500);
const afterSwitch = await page.evaluate(() => ({
menus: document.querySelectorAll('.device-menu').length,
label: document.querySelector('.device-menu')?.getAttribute('aria-label'),
outputExpanded: document.querySelector('#btn-deafen').getAttribute('aria-expanded'),
inputExpanded: document.querySelector('#btn-mute').getAttribute('aria-expanded'),
items: document.querySelectorAll('.device-menu [role="menuitemradio"]').length,
}));
step('rapid mic → headphones while enumeration pending', afterSwitch);
if (afterSwitch.menus !== 1 || afterSwitch.label !== 'Устройство вывода' || afterSwitch.items < 2) throw new Error('stale or duplicate menu');
if (afterSwitch.menus !== 1 || afterSwitch.outputExpanded !== 'true' || afterSwitch.inputExpanded !== 'false' || afterSwitch.items < 2) throw new Error('stale or duplicate menu');
await page.keyboard.press('Escape');
await page.click('#btn-mute', { button: 'right' });
await page.click('#connect-address');
+1 -1
View File
@@ -1,4 +1,4 @@
// Real audio devices in Settings → Звук (NO fake-media flags): lists what the engine exposes without any
// Real audio devices in Settings → Audio (NO fake-media flags): lists what the engine exposes without any
// capture, selects a non-default microphone and output, restarts and checks the choice persisted.
// Never connects to a server, never starts the microphone, plays nothing.
// node scripts/smoke-devices.mjs --out docs/evidence/runtime/<name> [--exe packaged.exe]
+6 -6
View File
@@ -56,22 +56,22 @@ try {
await page.click('#settings-back');
}
// Save from the connect form, then manage it in Settings → Серверы.
// Save from the connect form, then manage it in Settings → Servers.
await page.fill('#connect-address', server);
await page.click('#connect-save');
await page.waitForSelector('#servers-list .server-item', { timeout: 5000 });
await page.click('#btn-settings');
await page.click('#settings-nav .nav-item[data-panel="servers"]');
await page.fill('#server-add-name', 'Недоступный тест');
await page.fill('#server-add-name', 'Unreachable test');
await page.fill('#server-add-address', '127.0.0.1:9');
await page.click('#server-add-form button[type="submit"]');
await page.waitForFunction(() => document.querySelectorAll('#servers-manage .manage-row').length === 2);
await page.click('#servers-manage .manage-row:first-child button:has-text("Изменить")');
await page.fill('#servers-manage .edit-row input[aria-label="Название сервера"]', 'Без негатива');
await page.click('#servers-manage .manage-row:first-child button[data-action="edit"]');
await page.fill('#servers-manage .edit-row input[data-field="name"]', 'Renamed server');
await page.click('#servers-manage .edit-row button[type="submit"]');
const del = page.locator('#servers-manage .manage-row', { hasText: 'Недоступный тест' }).locator('button', { hasText: 'Удалить' });
const del = page.locator('#servers-manage .manage-row', { hasText: 'Unreachable test' }).locator('button[data-action="delete"]');
await del.click();
await page.locator('#servers-manage .manage-row', { hasText: 'Недоступный тест' }).locator('button', { hasText: 'Точно удалить?' }).click();
await page.locator('#servers-manage .manage-row', { hasText: 'Unreachable test' }).locator('button[data-action="confirm-delete"]').click();
await page.waitForFunction(() => document.querySelectorAll('#servers-manage .manage-row').length === 1);
await page.screenshot({ path: path.join(out, '50-settings-servers.png') });
step('saved, edited, deleted', { rows: await page.$$eval('#servers-manage .manage-row', (r) => r.map((x) => x.textContent.trim())) });
+2 -2
View File
@@ -118,7 +118,7 @@ try {
}, exportFile);
await page.click('#btn-settings');
await page.click('#identity-export');
await page.waitForFunction(() => /UID|не удался/.test(document.querySelector('#identity-status').textContent), null, { timeout: 20000 });
await page.waitForFunction(() => Boolean(document.querySelector('#identity-status').dataset.state), null, { timeout: 20000 });
const exportStatus = await page.textContent('#identity-status');
const { readFileSync, rmSync } = await import('node:fs');
const exported = readFileSync(exportFile, 'utf8');
@@ -137,7 +137,7 @@ try {
await page.click('#btn-settings');
await page.click('#settings-nav .nav-item[data-panel="video"]');
await page.click('.settings-panel[data-panel="video"] summary');
await page.waitForFunction(() => /запрещено/.test(document.querySelector('#hwdec-status').textContent), null, { timeout: 10000 });
await page.waitForFunction(() => document.querySelector('#hwdec-status').dataset.policy === 'forbidden', null, { timeout: 10000 });
step('after restart', { status: await page.textContent('#hwdec-status'), restartHint: await page.isVisible('#hwdec-restart') });
await shot(page, '05-video-decode-disabled.png');
await page.check('#opt-hwdec');
+1 -1
View File
@@ -63,7 +63,7 @@ async function setRange(page, selector, value) {
}, value);
}
/** Transmit mode lives in Settings → Клавиши. */
/** Transmit mode lives in Settings → Keys. */
async function setTransmit(page, mode) {
await page.click('#btn-settings');
await page.click('#settings-nav .nav-item[data-panel="keys"]');
+156
View File
@@ -0,0 +1,156 @@
// End-to-end self-update of a real, published Linux AppImage (no mocks, no credentials):
// 1. start the OLD published AppImage with a disposable profile and create an identity, bookmark, device pref;
// 2. let its updater find, download and verify the NEWER published release from git.eeee.moe;
// 3. confirm install: the AppImage file is replaced and the app relaunches by itself after exiting;
// 4. the relaunched process reports the new version; its file matches the release feed's sha512;
// 5. start the new AppImage again: version, UID, nickname, bookmark and device pref are unchanged.
//
// xvfb-run -a node scripts/update-e2e.mjs --from <old.AppImage> --to-tag v0.1.2-rc.2 --out update-e2e-out
//
// Runs AppImages with APPIMAGE_EXTRACT_AND_RUN=1 (no FUSE needed). Everything lives in a temp directory:
// profile, updater cache, the "installed" AppImage. The user's own installation is never touched.
import { _electron as electron } from 'playwright-core';
import { createHash } from 'node:crypto';
import { chmodSync, copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { parseFeed } from './update-feed-check.mjs';
const argv = process.argv.slice(2);
const opt = (n) => (argv.indexOf(`--${n}`) >= 0 ? argv[argv.indexOf(`--${n}`) + 1] : undefined);
const fromImage = opt('from');
const toTag = opt('to-tag');
const out = path.resolve(opt('out') ?? 'update-e2e-out');
if (!fromImage || !toTag || process.platform !== 'linux') {
console.error('usage (Linux): update-e2e.mjs --from <old.AppImage> --to-tag <vX> [--out dir]');
process.exit(2);
}
const toVersion = toTag.slice(1);
const RELEASE = 'https://git.eeee.moe/TeamsPeach/client/releases/download';
mkdirSync(out, { recursive: true });
const work = mkdtempSync(path.join(tmpdir(), 'teamspeach-update-e2e-'));
const apps = path.join(work, 'apps');
const profile = path.join(work, 'profile');
mkdirSync(apps);
const installed = path.join(apps, path.basename(fromImage));
copyFileSync(fromImage, installed);
chmodSync(installed, 0o755);
const env = {
...process.env,
TEAMSPEACH_PROFILE_DIR: profile,
XDG_CACHE_HOME: path.join(work, 'cache'),
APPIMAGE_EXTRACT_AND_RUN: '1',
};
const result = { startedAt: new Date().toISOString(), fromImage: path.basename(fromImage), toTag, steps: [] };
const step = (name, data = {}) => {
result.steps.push({ name, at: new Date().toISOString(), ...data });
console.log(`[update-e2e] ${name} ${JSON.stringify(data)}`);
};
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const sha512 = (file) => createHash('sha512').update(readFileSync(file)).digest('base64');
const updaterLog = () => {
const file = path.join(profile, 'logs', 'updater.log');
return existsSync(file) ? readFileSync(file, 'utf8') : '';
};
async function launch(image, label) {
const app = await electron.launch({ executablePath: image, args: ['--no-sandbox'], env, timeout: 120000 });
const page = await app.firstWindow({ timeout: 120000 });
page.on('console', (m) => m.type() === 'error' && step(`${label} console error`, { text: m.text().slice(0, 300) }));
return { app, page };
}
const diag = (page) => page.evaluate(() => window.teamspeachDiagnostics.snapshot());
async function waitFor(fn, ms, what) {
const end = Date.now() + ms;
for (;;) {
const v = await fn();
if (v) return v;
if (Date.now() > end) throw new Error(`timed out waiting for ${what}`);
await sleep(1000);
}
}
let failed = null;
try {
// 1. Old version, fresh profile.
let { app, page } = await launch(installed, 'old');
await page.waitForSelector('#view-onboarding', { state: 'visible', timeout: 60000 });
await page.fill('#onboarding-nick', 'UpdateProof');
await page.click('#onboarding-submit');
await page.waitForSelector('#view-app', { state: 'visible', timeout: 60000 });
const before = await diag(page);
const oldInfo = await page.evaluate(() => window.teamspeach.getAppInfo());
const bookmark = { id: 'upd0001', name: 'Update proof', address: '192.0.2.10:9987' };
await page.evaluate((b) => window.teamspeach.setPrefs({ savedServers: [b], inputDeviceId: 'update-proof-device' }), bookmark);
step('old version running', { version: oldInfo.appVersion, uid: before.profile.uid, nickname: before.profile.nickname });
// 2. Real check + download from the public release server.
const checked = await page.evaluate(() => window.teamspeach.checkForUpdates());
step('check', { phase: checked.phase, available: checked.available, error: checked.error, skipped: checked.newerWithoutBuild });
const ready = await waitFor(async () => {
const s = await page.evaluate(() => window.teamspeach.getUpdateState());
if (s.phase === 'error') throw new Error(`updater error ${JSON.stringify(s.error)}`);
return s.phase === 'downloaded' && s;
}, 600000, 'download');
step('downloaded and verified by electron-updater', { available: ready.available, target: ready.target });
if (ready.available.version !== toVersion) throw new Error(`offered ${ready.available.version}, expected ${toVersion}`);
// 3. User confirms install (also confirming interruption, as the UI would).
const exited = new Promise((r) => app.process().once('exit', (code, signal) => r({ code, signal })));
const install = await page.evaluate(() => window.teamspeach.installUpdate(true)).catch((e) => ({ evaluateEnded: e.message.slice(0, 200) }));
step('install requested', { install });
step('old process exited', await Promise.race([exited, sleep(180000).then(() => ({ timeout: true }))]));
// 4. Relaunch happened by itself: the new version logs its start with its pid.
const started = await waitFor(() => {
const m = new RegExp(`updater: version ${toVersion.replace(/\./g, '\\.')} pid (\\d+) target (\\S+)`).exec(updaterLog());
return m && { pid: Number(m[1]), target: m[2] };
}, 180000, 'relaunched new version');
step('new version relaunched automatically', started);
const files = readdirSync(apps);
const newImage = path.join(apps, files.find((f) => f.endsWith('.AppImage')));
const feedName = `${toVersion.includes('-') ? toVersion.split('-')[1].split('.')[0] : 'latest'}-linux.yml`;
const feedRes = await fetch(`${RELEASE}/${toTag}/${feedName}`);
if (!feedRes.ok) throw new Error(`feed ${feedName}: HTTP ${feedRes.status}`);
const feed = parseFeed(await feedRes.text());
const fileSha = sha512(newImage);
step('installed file', { files, sha512MatchesFeed: fileSha === feed.files[0].sha512, feedFile: feed.files[0].url });
if (files.length !== 1 || path.basename(newImage) !== feed.files[0].url || fileSha !== feed.files[0].sha512) {
throw new Error('installed AppImage does not match the release feed');
}
process.kill(started.pid, 'SIGTERM');
await waitFor(() => !existsSync(`/proc/${started.pid}`), 60000, 'relaunched app to exit');
await sleep(2000);
// 5. Start the new AppImage again: same identity and preferences, new version.
({ app, page } = await launch(newImage, 'new'));
await page.waitForSelector('#view-app', { state: 'visible', timeout: 60000 });
const after = await diag(page);
const newInfo = await page.evaluate(() => window.teamspeach.getAppInfo());
const prefs = await page.evaluate(() => window.teamspeach.getPrefs());
const state = await page.evaluate(() => window.teamspeach.getUpdateState());
await page.screenshot({ path: path.join(out, 'after-update.png') });
await app.close();
const kept = {
version: newInfo.appVersion,
uidSame: after.profile.uid === before.profile.uid,
nicknameSame: after.profile.nickname === before.profile.nickname,
bookmarkSame: JSON.stringify(prefs.savedServers) === JSON.stringify([bookmark]),
deviceSame: prefs.inputDeviceId === 'update-proof-device',
updater: { phase: state.phase, target: state.target, mode: state.mode },
};
step('after update', kept);
if (kept.version !== toVersion || !kept.uidSame || !kept.nicknameSame || !kept.bookmarkSame || !kept.deviceSame) {
throw new Error('state after update is wrong');
}
} catch (err) {
failed = err;
step('FAILED', { error: err.message });
}
result.updaterLog = updaterLog().split('\n').filter((l) => / updater: /.test(l));
result.ok = !failed;
writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2));
process.exit(failed ? 1 : 0);
+102
View File
@@ -0,0 +1,102 @@
// Release gate for electron-updater feeds (latest.yml, latest-linux.yml, rc-linux-arm64.yml, …).
// Every file a feed references must sit next to it under exactly that name, with the declared size and
// sha512, and the feed version must be the expected one. A renamed or rebuilt package fails here instead
// of failing on users' machines.
//
// node scripts/update-feed-check.mjs [--version 0.1.2-rc.1] <feed.yml> [...]
import { createHash } from 'node:crypto';
import { createReadStream, readFileSync, statSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
export const FEED_NAME = /^[0-9A-Za-z][0-9A-Za-z-]*\.yml$/;
/** Parses the subset of YAML electron-builder writes for update info. Throws on anything else. */
export function parseFeed(text) {
const feed = { version: null, files: [] };
let current = null;
let inFiles = false;
for (const raw of text.split(/\r?\n/)) {
if (raw.trim() === '') continue;
const top = /^([A-Za-z][A-Za-z0-9]*):\s*(.*)$/.exec(raw);
if (top) {
inFiles = top[1] === 'files' && top[2] === '';
current = null;
if (top[1] === 'version') feed.version = unquote(top[2]);
continue;
}
const item = /^ {2}- ([A-Za-z][A-Za-z0-9]*):\s*(.*)$/.exec(raw);
const field = /^ {4}([A-Za-z][A-Za-z0-9]*):\s*(.*)$/.exec(raw);
if (inFiles && item) {
current = {};
feed.files.push(current);
current[item[1]] = unquote(item[2]);
} else if (inFiles && field && current) {
current[field[1]] = unquote(field[2]);
} else {
throw new Error(`unexpected feed line: ${raw.slice(0, 80)}`);
}
}
if (!feed.version) throw new Error('feed has no version');
if (feed.files.length === 0) throw new Error('feed lists no files');
for (const f of feed.files) {
if (!f.url || !f.sha512 || !/^\d+$/.test(f.size ?? '')) throw new Error(`feed entry without url/sha512/size: ${JSON.stringify(f)}`);
f.size = Number(f.size);
}
return feed;
}
function unquote(v) {
const s = v.trim();
return /^'.*'$/.test(s) || /^".*"$/.test(s) ? s.slice(1, -1) : s;
}
function sha512(file) {
return new Promise((resolve, reject) => {
const hash = createHash('sha512');
createReadStream(file).on('error', reject).on('data', (d) => hash.update(d)).on('end', () => resolve(hash.digest('base64')));
});
}
/** Returns the referenced file names; throws with a precise message when the feed and files disagree. */
export async function checkFeed(feedFile, { version } = {}) {
const name = path.basename(feedFile);
if (!FEED_NAME.test(name)) throw new Error(`${name}: not an electron-updater feed name`);
const feed = parseFeed(readFileSync(feedFile, 'utf8'));
if (version && feed.version !== version) throw new Error(`${name}: version ${feed.version}, expected ${version}`);
const dir = path.dirname(feedFile);
for (const f of feed.files) {
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(f.url)) throw new Error(`${name}: file name ${f.url} contains a path or characters a release asset cannot keep`);
const file = path.join(dir, f.url);
let size;
try {
size = statSync(file).size;
} catch {
throw new Error(`${name}: references ${f.url}, which is missing next to the feed (renamed?)`);
}
if (size !== f.size) throw new Error(`${name}: ${f.url} is ${size} bytes, feed says ${f.size}`);
if ((await sha512(file)) !== f.sha512) throw new Error(`${name}: sha512 of ${f.url} differs from the feed`);
}
return feed.files.map((f) => f.url);
}
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
const args = process.argv.slice(2);
const vi = args.indexOf('--version');
const version = vi >= 0 ? args.splice(vi, 2)[1] : undefined;
if (args.length === 0) {
console.error('usage: update-feed-check.mjs [--version X] <feed.yml> [...]');
process.exit(2);
}
let failed = false;
for (const feed of args) {
try {
const files = await checkFeed(feed, { version });
console.log(`${path.basename(feed)}: ok (${files.join(', ')})`);
} catch (err) {
console.error(err.message);
failed = true;
}
}
process.exit(failed ? 1 : 0);
}