Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions scripts/ios-fleet/asc-api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3014,29 +3014,32 @@ async function main() {
// Hand-written parse, not zod: see ensure-appstore-profiles above.
const EMAIL_RE = /^[^\s@,]+@[^\s@,]+\.[^\s@,]+$/;
const raw = String(process.env.ASC_STANDING_TESTERS || "");
const emails = [...new Set(raw.split(/[\s,;]+/).map((e) => e.trim().toLowerCase()).filter(Boolean))];
let emails = [...new Set(raw.split(/[\s,;]+/).map((e) => e.trim().toLowerCase()).filter(Boolean))];
const mask = maskEmail;
if (!/^\d+$/.test(appId)) {
console.error(`${prefix}: usage: node asc-api.mjs ensure-standing-testers <appleId> [buildVersion]`);
process.exit(2);
}
const rows = ascRows;
const errText = ascErrorText;
let warnings = 0;
const warn = (msg) => { warnings += 1; console.error(`${prefix}: WARNING ${msg}`); };
// The email list is never REQUIRED: the external group already holds the
// standing people, so an empty list is not a failure. The build still has
// to reach that group and Beta App Review. A bad list is a warning about
// the list, never a reason to exit before the build is assigned.
if (!emails.length) {
console.error(`${prefix}: ASC_STANDING_TESTERS is empty; set the repo secret to the standing tester emails`);
process.exit(2);
console.error(`${prefix}: no tester list; the members of the external group stay as they are`);
}
Comment thread
swu-wise[bot] marked this conversation as resolved.
Resolved
const bad = emails.filter((e) => !EMAIL_RE.test(e));
if (bad.length) {
console.error(`${prefix}: ASC_STANDING_TESTERS has ${bad.length} malformed entr${bad.length === 1 ? "y" : "ies"}; nothing changed`);
process.exit(2);
const badEmails = emails.filter((e) => !EMAIL_RE.test(e));
if (badEmails.length) {
warn(`ASC_STANDING_TESTERS has ${badEmails.length} malformed entr${badEmails.length === 1 ? "y" : "ies"}; they are ignored`);
}
emails = emails.filter((e) => EMAIL_RE.test(e));
if (emails.length > 5) {
console.error(`${prefix}: ASC_STANDING_TESTERS lists ${emails.length} emails; the standing list is three. Refusing to invite`);
process.exit(2);
warn(`ASC_STANDING_TESTERS lists ${emails.length} valid emails; the standing list is three, and only the first five are added`);
}
const rows = ascRows;
const errText = ascErrorText;
let warnings = 0;
const warn = (msg) => { warnings += 1; console.error(`${prefix}: WARNING ${msg}`); };
emails = emails.slice(0, 5);

// 1) External beta group: reuse "Public Beta" or the first external group;
// create a private "Public Beta" (public link off) only when none exists.
Expand Down Expand Up @@ -3066,13 +3069,20 @@ async function main() {
}

// 2) Testers: add each standing email to the group, reusing tester records.
const inGroupRes = await api("GET", `/v1/betaGroups/${group.id}/betaTesters?limit=200&fields[betaTesters]=email`);
if (!inGroupRes.ok) {
warn(`could not list testers in group "${group.attributes?.name}" (${errText(inGroupRes)}); not re-adding anyone`);
process.exit(3);
// Only touch the group's testers when there is a list to add. A failed
// tester listing is a warning, never a reason to skip the build assignment.
let inGroup = new Set();
let listable = emails.length > 0;
if (listable) {
const inGroupRes = await api("GET", `/v1/betaGroups/${group.id}/betaTesters?limit=200&fields[betaTesters]=email`);
if (!inGroupRes.ok) {
warn(`could not list testers in group "${group.attributes?.name}" (${errText(inGroupRes)}); not re-adding anyone`);
listable = false;
} else {
inGroup = new Set(rows(inGroupRes).map((t) => String(t.attributes?.email || "").toLowerCase()));
}
}
const inGroup = new Set(rows(inGroupRes).map((t) => String(t.attributes?.email || "").toLowerCase()));
for (const email of emails) {
for (const email of (listable ? emails : [])) {
if (inGroup.has(email)) {
console.error(`${prefix}: ${mask(email)} already in group`);
continue;
Expand All @@ -3087,15 +3097,8 @@ async function main() {
}
}

// 2b) Internal group: App Store Connect users install every build with no
// Beta App Review. This is the path that reaches the owner's phone; a
// new app record has none until this creates it (GH #1018).
// Its warnings go through warn(), so they count toward the exit code.
await ensureInternalTesterGroup({
api, appId, emails,
log: (m) => console.error(`${prefix}: ${m}`),
warn
});
// No internal group: iOS TestFlight uses the external group only (owner,
// 2026-11-24). An internal group an app record already has is left alone.

// 3) Build: the given CFBundleVersion, else the newest upload.
const buildQuery = wantBuild
Expand Down
Loading