mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-30 03:13:35 +00:00
86 lines
3.5 KiB
TypeScript
86 lines
3.5 KiB
TypeScript
// iOS Fastlane release gate tests keep TestFlight upload on one canonical path.
|
|
import { existsSync, readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const fastfilePath = path.join(process.cwd(), "apps", "ios", "fastlane", "Fastfile");
|
|
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
const legacyReleaseScriptPath = path.join(process.cwd(), "scripts", "ios-release.sh");
|
|
const uploadScriptPath = path.join(process.cwd(), "scripts", "ios-release-upload.sh");
|
|
|
|
function readFastfile(): string {
|
|
return readFileSync(fastfilePath, "utf8");
|
|
}
|
|
|
|
function laneBody(source: string, name: string): string {
|
|
const startMarker = `lane :${name} do`;
|
|
const start = source.indexOf(startMarker);
|
|
if (start < 0) {
|
|
throw new Error(`missing Fastlane lane ${name}`);
|
|
}
|
|
|
|
const rest = source.slice(start + startMarker.length);
|
|
const nextLane = rest.search(/\n\s+(?:desc|lane|private_lane) /);
|
|
return nextLane < 0 ? rest : rest.slice(0, nextLane);
|
|
}
|
|
|
|
describe("iOS Fastlane release upload gates", () => {
|
|
it("does not keep the old package release alias", () => {
|
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8")) as {
|
|
scripts?: Record<string, string>;
|
|
};
|
|
|
|
expect(packageJson.scripts).toHaveProperty("ios:release:upload");
|
|
expect(packageJson.scripts).not.toHaveProperty("ios:release");
|
|
expect(existsSync(legacyReleaseScriptPath)).toBe(false);
|
|
});
|
|
|
|
it("routes the package upload wrapper through the guarded Fastlane lane", () => {
|
|
const script = readFileSync(uploadScriptPath, "utf8");
|
|
|
|
expect(script).toContain("OPENCLAW_IOS_RELEASE_WRAPPER=1");
|
|
expect(script).toContain("DELIVER_NUMBER_OF_THREADS=1");
|
|
expect(script).toContain("FL_MAX_NUMBER_OF_THREADS=1");
|
|
expect(script).toContain("run_ios_fastlane ios release_upload");
|
|
});
|
|
|
|
it("keeps release_upload as the only Fastlane TestFlight upload implementation", () => {
|
|
const fastfile = readFastfile();
|
|
const uploadCalls = fastfile.match(/\bupload_to_testflight\s*\(/g) ?? [];
|
|
|
|
expect(uploadCalls).toHaveLength(1);
|
|
expect(laneBody(fastfile, "release_upload")).toContain("upload_to_testflight(");
|
|
expect(fastfile).not.toMatch(/\n\s+lane :app_store do\b/);
|
|
expect(fastfile).not.toContain("Deprecated. Use `pnpm ios:release:upload`.");
|
|
});
|
|
|
|
it("rejects direct Fastlane upload before release work", () => {
|
|
const fastfile = readFastfile();
|
|
const releaseUpload = laneBody(fastfile, "release_upload");
|
|
|
|
expect(releaseUpload).toContain('ENV["OPENCLAW_IOS_RELEASE_WRAPPER"] == "1"');
|
|
expect(releaseUpload).toContain("Use `pnpm ios:release:upload`");
|
|
expect(releaseUpload.indexOf("UI.user_error!")).toBeLessThan(
|
|
releaseUpload.indexOf("prepare_app_store_context"),
|
|
);
|
|
});
|
|
|
|
it("validates the exported IPA before the sole TestFlight upload call", () => {
|
|
const fastfile = readFastfile();
|
|
const validationCall = fastfile.indexOf("validate_app_store_ipa!(expected_ipa_path)");
|
|
const uploadCall = fastfile.indexOf("upload_to_testflight(");
|
|
|
|
expect(validationCall).toBeGreaterThanOrEqual(0);
|
|
expect(uploadCall).toBeGreaterThan(validationCall);
|
|
});
|
|
|
|
it("normalizes Watch screenshots as opaque RGB PNGs for App Store upload", () => {
|
|
const fastfile = readFastfile();
|
|
|
|
expect(fastfile).toContain("def normalize_watch_screenshot_status_bar(path)");
|
|
expect(fastfile).toContain("CGImageAlphaInfo.noneSkipLast.rawValue");
|
|
expect(fastfile).toContain("CGImageDestinationCreateWithURL");
|
|
expect(fastfile).toContain("operation: .sourceOver");
|
|
});
|
|
});
|