Files
Piik/tests/release-automation.test.ts
AAAandPedro Antonio c18502fd18 feat: improve microphone, chat and platform support
This release adds microphone processing controls and local chat controls, expands platform packages, and synchronizes the website and guides. It also fixes native H.264 input/format handling, signaling recovery, fresh STUN discovery, and UDP ownership during overlapping connections.

This is **v1.8.0**. Browser/Server v23, Native control v9 and capture v7 remain unchanged, with the existing 1440p ceiling. Additional resolutions, capability negotiation and Magicsock are separate follow-up work.

## Validation

- Full local Web check: 79 files / 1,317 tests, TypeScript and production build.
- Full Go checks, platform builds and Windows native capture regressions/probe.
- Native H.264 Host lifecycle, Browser-to-App fanout and App-exit recovery, and Native H.264 through embedded SFU: all passed with owned process/port/profile cleanup.
- Website build, documentation and repository hygiene passed. Existing UI acceptance covers narrow screens, both languages/themes, architecture downloads and all 23 film checks; final packaging and Go race checks run on the merged revision in CI.
- Physical macOS/Linux capture, representative public networks and unmatched field reports retain their documented evidence limits. No claim that every blur/disconnection report is resolved.

## Release notes

### 中文

这是一次功能与兼容性更新:麦克风和聊天增加了实用的小选项,App 与 Server 支持更多设备,同时修复了原生分享和连接恢复中的若干问题。现有 1.x 协议保持不变。

#### 新增与改进

- 浏览器麦克风新增「降噪与回声消除」开关,默认开启回声消除、降噪和自动增益;分享音乐或使用虚拟音频输入时,可按需关闭。
- 可调整弹幕字号和透明度,并将当前保留的聊天记录导出为 TXT。当前会话最多保留 1,000 条文字消息,刷新页面后清空;需要保存时请先导出。
- 新增 Intel Mac、Linux ARM64 App,以及 Linux ARM64 Server 和容器镜像。官网下载区可直接选择对应架构,并显示最新版本和发布时间。
- 更新官网演示、README 截图和中英文教程,明确浏览器分享也可选择窗口或屏幕;开始分享前显示房间号占位,保持底栏控件位置稳定。
- 官网新增直达问题排查的入口,补充浏览器 WebRTC 限制、校园网和 Windows 显卡相关的排查步骤。
- App 模式选择页显示免费开源说明、作者与贡献者署名,以及官方网站和源码链接。

#### 修复

- 修正部分 H.264 原生分享的格式兼容性校验,以及 Windows 编码器输入长度和输出缓冲区对齐问题。
- 清理已失效的重连任务和 Native 接收信令,避免旧连接继续影响当前会话。
- 修复 App 重连时可能复用过期公网地址的问题;重新探测使用当前地址,并处理探测丢包和过期响应,保留其他正常连接。
- 修复 App 新旧媒体连接重叠时共用端口造成的冲突,避免准备或撤销新连接打断仍在使用的画面;关闭连接时及时取消未完成的端口映射请求。
- 无站点密码时,连接恢复不再误引导用户输入站点密码。
- 房间失效或会话终止时,开播前后的原因提示统一显示在电视状态图标中,避免额外提示条。
- 修正 Linux 原生采集的时间戳与关键帧时间基准。感谢 Pedro Antonio 在 [#449](https://github.com/TNTcraftHIM/Piik/pull/449) 的贡献。

#### 使用说明

下载对应平台的完整压缩包,退出旧 App 后解压使用。Windows 继续提供 x64;macOS 提供 Apple 芯片与 Intel 版本,原生采集需要 macOS 13 或更新版本。Linux 提供 x64 与 ARM64,原生采集还需安装[系统组件](https://github.com/TNTcraftHIM/Piik/blob/main/native/capture/linux/README.md)。macOS 和 Linux 的实机覆盖仍有限,欢迎反馈。

### English

This update adds useful microphone and chat controls, brings Piik to more devices, and fixes several native-sharing and connection-recovery issues. The existing 1.x protocols remain unchanged.

#### New and improved

- Browser microphones now have a “Noise & echo reduction” toggle. Echo cancellation, noise suppression and automatic gain control are on by default; turn them off when appropriate for music or virtual audio inputs.
- Adjust chat-overlay text size and opacity, and export retained messages as TXT. The current session keeps up to 1,000 text messages and clears on page refresh; export first if you want to keep them.
- Added Intel Mac and Linux ARM64 App packages, plus Linux ARM64 Server and container images. The website provides architecture selectors and shows the latest release and publication date.
- Updated the website demonstration, README screenshots and bilingual guides, clarifying that browser capture can also select windows or screens. A room-code placeholder keeps the bottom bar stable before sharing starts.
- Added direct website links to troubleshooting, with steps for browser WebRTC restrictions, campus networks and Windows graphics issues.
- The App mode-selection page now shows its free and open-source status, author and contributor credit, and links to the official website and source.

#### Fixes

- Corrected H.264 format compatibility checks and Windows encoder input-length and output-buffer alignment handling.
- Retired stale reconnect tasks and Native receive signals so they cannot continue affecting the current session.
- Fixed App reconnection reusing an expired public address. Fresh discovery handles lost probes and stale responses while preserving other working connections.
- Fixed UDP socket conflicts between overlapping App media connections so preparing or canceling a replacement preserves the active picture. Closing a connection now cancels unfinished gateway mapping requests.
- Connection recovery on passwordless sites no longer incorrectly asks for a site passphrase.
- Expired-room and session-termination reasons now use the same TV status indicator before and during sharing, without an extra notice strip.
- Corrected Linux native capture timestamps and keyframe time bases. Thanks to Pedro Antonio for [#449](https://github.com/TNTcraftHIM/Piik/pull/449).

#### Updating

Download the complete archive for your platform, quit the old App, and extract the new package. Windows remains x64-only. macOS packages support Apple silicon and Intel; native capture requires macOS 13 or newer. Linux supports x64 and ARM64 and requires additional [system components](https://github.com/TNTcraftHIM/Piik/blob/main/native/capture/linux/README.md) for native capture. Physical-device coverage on macOS and Linux remains limited; feedback is welcome.

## Attribution

Co-authored-by: Pedro Antonio <wrenchwastaken@gmail.com>
2026-10-04 16:21:01 +08:00

243 lines
15 KiB
TypeScript

import { execFileSync, spawnSync } from "node:child_process";
import { createHash } from "node:crypto";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
import { pullRequestNotes, releaseNotes } from "../scripts/release-notes.mjs";
const planner = fileURLToPath(new URL("../scripts/release-version.mjs", import.meta.url));
const publisher = fileURLToPath(new URL("../scripts/publish-release.mjs", import.meta.url));
const sha = (value: string) => createHash("sha256").update(value).digest("hex");
describe("release automation", () => {
it("validates the PR body against its net product diff before the squash", () => {
const root = mkdtempSync(join(tmpdir(), "piik-pr-notes-"));
const git = (...args: string[]) => execFileSync("git", args, { cwd: root, encoding: "utf8" }).trim();
const commit = () => { git("add", "."); git("commit", "-m", "checkpoint without release notes"); return git("rev-parse", "HEAD"); };
try {
git("init", "--quiet", "--initial-branch=main");
git("config", "user.name", "Piik fixture");
git("config", "user.email", "fixture@example.invalid");
git("config", "commit.gpgSign", "false");
mkdirSync(join(root, "public"));
mkdirSync(join(root, "site"));
writeFileSync(join(root, "public/asset.svg"), "art");
const base = commit();
writeFileSync(join(root, "README.md"), "guide");
const docs = commit();
const event = { pull_request: { number: 1, base: { sha: base }, head: { sha: docs }, body: "" } };
expect(pullRequestNotes(root, event)).toBe("");
// Moving a product file out is still a deletion from the shipped surface.
git("mv", "public/asset.svg", "site/asset.svg");
event.pull_request.head.sha = commit();
expect(() => pullRequestNotes(root, event)).toThrow("one nonempty");
for (const body of ["## Release notes\n???", "## Release notes\n\uFFFD"]) {
event.pull_request.body = body;
expect(() => pullRequestNotes(root, event)).toThrow("damaged");
}
event.pull_request.body = "## Release notes\nOne\n## Release notes\nTwo";
expect(() => pullRequestNotes(root, event)).toThrow("one nonempty");
event.pull_request.body = "## Implementation\nprivate detail\n## Release notes\n修复分享 / Sharing fixes.\nLiteral `code` and $(text).";
expect(pullRequestNotes(root, event)).toBe("修复分享 / Sharing fixes.\nLiteral `code` and $(text).");
const eventFile = join(root, "event.json");
writeFileSync(join(root, ".git/info/exclude"), "event.json\n");
writeFileSync(eventFile, JSON.stringify(event));
const script = fileURLToPath(new URL("../scripts/release-notes.mjs", import.meta.url));
expect(execFileSync(process.execPath, [script, "--pull-request"], {
cwd: root, encoding: "utf8", env: { ...process.env, GITHUB_EVENT_PATH: eventFile },
})).toContain("validated");
// Reverting the product change leaves a documentation-only PR.
git("mv", "site/asset.svg", "public/asset.svg");
event.pull_request.head.sha = commit();
event.pull_request.body = "";
expect(pullRequestNotes(root, event)).toBe("");
} finally { rmSync(root, { recursive: true, force: true }); }
}, 15_000);
it("publishes reviewed notes, excludes private history and retains every unreleased phase on retries", () => {
const root = mkdtempSync(join(tmpdir(), "piik-release-notes-"));
const git = (...args: string[]) => execFileSync("git", args, { cwd: root, encoding: "utf8" }).trim();
const commit = (message: string, path = "index.html") => {
mkdirSync(dirname(join(root, path)), { recursive: true });
writeFileSync(join(root, path), message);
git("add", "--", path);
git("commit", "-m", message);
return git("rev-parse", "HEAD");
};
try {
git("init", "--quiet", "--initial-branch=main");
git("config", "user.name", "Piik fixture");
git("config", "user.email", "fixture@example.invalid");
git("config", "commit.gpgSign", "false");
commit("chore: private history without release copy");
const launch = commit("feat: launch\n\n## Problem\nInternal discussion\n\n## Release notes\n" +
"<!-- Editor guidance -->\n### 开始分享\n\n- 一起玩,一起看。\n\n## Verification\nInternal log");
const first = releaseNotes(root, "v1.0.0", launch, "fixture/Piik");
expect(first).toContain("### 开始分享\n\n- 一起玩,一起看。");
expect(first).toContain(`/tree/${launch}`);
expect(first).not.toMatch(/private history|Internal|Editor guidance/);
git("tag", "-a", "v1.0.0", "-m", "Launch");
expect(releaseNotes(root, "v1.0.0", launch, "fixture/Piik")).toBe(first);
const website = commit("feat(site)!: redesign the homepage", "site/index.html");
expect(() => releaseNotes(root, "v1.0.1", website, "fixture/Piik")).toThrow("No release changes");
expect(releaseNotes(root, "v1.0.1", website, "fixture/Piik", { allowEmpty: true })).toBe("");
const candidate = JSON.parse(execFileSync(process.execPath, [planner, "build"], {
cwd: root, encoding: "utf8", env: { ...process.env, PIIK_BUILD_VERSION: "v1.0.1" },
}));
expect(candidate).toMatchObject({ version: "v1.0.1", publish: false });
commit("fix: repair playback\n\n## Release notes\n- Playback resumes after reconnecting.");
const next = commit("feat: add a sharing option\n\n## Release notes\n- Choose a window to share.");
const notes = releaseNotes(root, "v1.1.0", next, "fixture/Piik");
expect(notes).toContain("- Playback resumes after reconnecting.\n\n- Choose a window to share.");
expect(notes).toContain(`/compare/v1.0.0...${next}`);
expect(notes).not.toContain("开始分享");
expect(notes).not.toContain("redesign");
git("tag", "v1.1.0");
expect(releaseNotes(root, "v1.1.0", next, "fixture/Piik")).toBe(notes);
// A checkout may have advanced; generation still uses the requested SHA.
expect(releaseNotes(root, "v1.0.0", launch, "fixture/Piik")).toBe(first);
for (const section of ["", "## Release notes", "## Release notes\n<!-- Fill in -->\n### Changes",
"## Release notes\n- One\n## Release notes\n- Two"]) {
git("checkout", "--quiet", "--detach", next);
const invalid = commit(`chore: maintenance\n\n${section}`);
expect(() => releaseNotes(root, "v1.1.1", invalid, "fixture/Piik")).toThrow("one nonempty");
}
for (const damaged of ["????????????", "Updated \uFFFD capture"]) {
git("checkout", "--quiet", "--detach", next);
const invalid = commit(`fix: capture\n\n## Release notes\n${damaged}`);
expect(() => releaseNotes(root, "v1.1.1", invalid, "fixture/Piik")).toThrow("damaged Release notes");
}
} finally { rmSync(root, { recursive: true, force: true }); }
}, 15_000); // Real Git subprocesses share the runner with the rest of the suite.
it("plans from immutable tags and all unreleased main changes without editing version files", () => {
const root = mkdtempSync(join(tmpdir(), "piik-release-plan-"));
const git = (...args: string[]) => execFileSync("git", args, { cwd: root, encoding: "utf8" }).trim();
const plan = () => JSON.parse(execFileSync(process.execPath, [planner, "plan"], { cwd: root, encoding: "utf8" }));
const commit = (message: string, path = "index.html") => {
mkdirSync(dirname(join(root, path)), { recursive: true });
writeFileSync(join(root, path), message);
git("add", "--", path);
git("commit", "-m", message);
};
try {
git("init", "--quiet", "--initial-branch=main");
git("config", "user.name", "Piik fixture");
git("config", "user.email", "fixture@example.invalid");
git("config", "commit.gpgSign", "false");
commit("chore: initial");
expect(plan().version).toBe("v1.0.0");
const candidate = JSON.parse(execFileSync(process.execPath, [planner, "build"], {
cwd: root, encoding: "utf8", env: { ...process.env, PIIK_BUILD_VERSION: "v1.0.0" },
}));
expect(candidate).toMatchObject({ version: "v1.0.0", publish: false });
expect(git("tag")).toBe("");
git("tag", "v1.0.0");
// The tag might belong to an unfinished draft: publication can resume.
expect(plan()).toMatchObject({ version: "v1.0.0", publish: true });
for (const path of ["site/film/art.js", "site/docs/package.json", "site/docs/package-lock.json",
"site/docs/.vitepress/config.mjs", "docs/guide/troubleshooting.md", "docs/deployment.md", "README.zh-CN.md",
"scripts/build-website.mjs", "scripts/check-docs.mjs", "scripts/check-container.mjs", "scripts/markdown-slug.mjs", "scripts/release-notes.mjs",
"scripts/publish-container.mjs",
"scripts/app-gate-endpoint.ts", "scripts/client-gate-endpoint.ts",
"tests/room.test.ts", ".agents/skills/ponytail/SKILL.md", ".github/workflows/website.yml"]) {
mkdirSync(dirname(join(root, path)), { recursive: true });
writeFileSync(join(root, path), "Peripheral content");
}
git("add", ".");
git("commit", "-m", "feat(site)!: redesign the website\n\nBREAKING CHANGE: website layout only");
expect(plan()).toMatchObject({ version: "development", publish: false });
commit("fix: repair playback\n\nExample text:\nfeat: is not this commit's type");
expect(plan().version).toBe("v1.0.1");
commit("feat(site)!: refresh the film", "site/film/art.js");
expect(plan()).toMatchObject({ version: "v1.0.1", revision: git("rev-parse", "HEAD"), publish: true });
commit("feat(app): add a sharing option");
expect(plan().version).toBe("v1.1.0");
commit("refactor!: replace the public contract");
expect(plan().version).toBe("v2.0.0");
expect(git("tag")).toBe("v1.0.0");
const reused = spawnSync(process.execPath, [planner, "build"], {
cwd: root, encoding: "utf8", env: { ...process.env, PIIK_BUILD_VERSION: "v1.0.0" },
});
expect(reused.status).not.toBe(0);
expect(reused.stderr).toContain("two source revisions");
} finally { rmSync(root, { recursive: true, force: true }); }
}, 15_000); // Real Git subprocesses share the runner with the rest of the suite.
it("keeps shipped assets, build inputs and moves across the website boundary release-worthy", () => {
const root = mkdtempSync(join(tmpdir(), "piik-release-paths-"));
const git = (...args: string[]) => execFileSync("git", args, { cwd: root, encoding: "utf8" }).trim();
const plan = () => JSON.parse(execFileSync(process.execPath, [planner, "plan"], { cwd: root, encoding: "utf8" }));
try {
git("init", "--quiet", "--initial-branch=main");
git("config", "user.name", "Piik fixture");
git("config", "user.email", "fixture@example.invalid");
git("config", "commit.gpgSign", "false");
mkdirSync(join(root, "public"));
writeFileSync(join(root, "public", "asset.svg"), "Shared artwork");
git("add", ".");
git("commit", "-m", "feat: launch");
git("tag", "v1.0.0");
for (const path of ["src/client/styles.css", "src/shared/protocol.ts", "internal/server/app/app.go",
"cmd/piik-app/piik.ico", "native/capture/windows/build.ps1", "public/guide.md",
"licenses/NOTICE.md", "LICENSE", "package-lock.json", "go.mod",
"scripts/check-go.mjs", "scripts/app-package-targets.mjs", ".github/workflows/repository-hygiene.yml",
"new-product-input.json"]) {
git("checkout", "--quiet", "--detach", "v1.0.0");
mkdirSync(dirname(join(root, path)), { recursive: true });
writeFileSync(join(root, path), "Changed product input");
git("add", "--", path);
git("commit", "-m", "fix: update product input");
expect(plan(), path).toMatchObject({ version: "v1.0.1", publish: true });
}
git("checkout", "--quiet", "--detach", "v1.0.0");
mkdirSync(join(root, "site"), { recursive: true });
git("mv", "public/asset.svg", "site/asset.svg");
git("commit", "-m", "fix: retire the product asset");
expect(plan()).toMatchObject({ version: "v1.0.1", publish: true });
git("tag", "v1.0.1");
mkdirSync(join(root, "public"), { recursive: true });
git("mv", "site/asset.svg", "public/asset.svg");
git("commit", "-m", "feat: add the product asset");
expect(plan()).toMatchObject({ version: "v1.1.0", publish: true });
} finally { rmSync(root, { recursive: true, force: true }); }
}, 15_000);
it("accepts only a complete same-build package set before contacting GitHub", () => {
const root = mkdtempSync(join(tmpdir(), "piik-release-assets-"));
const version = "v1.0.0";
const revision = "a".repeat(40);
const run = () => spawnSync(process.execPath, [publisher, root, version, revision, "--dry-run"], { encoding: "utf8" });
try {
for (const target of ["server", "server-linux-arm64", "windows-amd64", "linux-amd64", "linux-arm64", "darwin-arm64", "darwin-amd64"]) {
const server = target.startsWith("server");
const artifact = `${target}.${server ? "tar.gz" : "zip"}`;
writeFileSync(join(root, artifact), target);
const descriptor = { schema: 2, version, revision, artifact, artifactSha256: sha(target),
target, ...(server ? { manifest: `${target}.manifest.tsv`, manifestSha256: sha("manifest") } : {}) };
writeFileSync(join(root, `${target}.release.json`), JSON.stringify(descriptor));
if (server) writeFileSync(join(root, `${target}.manifest.tsv`), "manifest");
else writeFileSync(join(root, `${artifact}.sha256`), `${sha(target)} ${artifact}\n`);
}
const complete = run();
expect(complete.status, complete.stderr).toBe(0);
expect(JSON.parse(complete.stdout).targets).toHaveLength(7);
expect(JSON.parse(complete.stdout).files).toBe(7);
const checksum = join(root, "windows-amd64.zip.sha256");
const originalChecksum = readFileSync(checksum, "utf8");
writeFileSync(checksum, "wrong checksum");
expect(run().stderr).toContain("App checksum file mismatch");
writeFileSync(checksum, originalChecksum);
const path = join(root, "windows-amd64.release.json");
const original = readFileSync(path, "utf8");
writeFileSync(path, JSON.stringify({ ...JSON.parse(original), revision: "b".repeat(40) }));
expect(run().stderr).toContain("Release identity mismatch");
writeFileSync(path, original);
writeFileSync(join(root, "windows-amd64.zip"), "changed bytes");
expect(run().stderr).toContain("checksum mismatch");
} finally { rmSync(root, { recursive: true, force: true }); }
});
});