Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 11 additions & 3 deletions Tools/Play/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,23 @@ round, the second commit would meet a review already under way. Without
## Rules it keeps

- Every write but that release waits in the Play Console
(`--changes-not-sent-for-review`): only the user submits.
(`--changes-not-sent-for-review`): only the user submits. The one way round
it is `--without-hold`, on a draft release only, for an app whose changes
Play won't hold (below).
- `--send-for-review` takes a rolled-out testing-track release, and still
passes `--changes-in-review error`, so it never cancels a review under way.
- Production takes only a non-beta build, only ever as a draft the user rolls
out; `--rollout`, `--also` and `--send-for-review` refuse it.
- A testing track takes only a beta build (`build.json`'s `beta`, which the
app template writes from `-P<betaProperty>`).
- An app Play has never published refuses the hold; the tool then sends
nothing rather than every pending change.
- Play holds an app's changes back from review only after a rejected update,
and never for an app it hasn't published; otherwise it refuses
`--changes-not-sent-for-review`. The tool then sends nothing rather than
every pending change. A draft release (production, or a testing track
without `--rollout`) can go up with `--without-hold`: it serves nobody, but
anything else waiting in the Play Console goes for review with it, so check
Publishing overview first. A review already under way still makes it fail
(`--changes-in-review error`), never cancelled.

## Tests

Expand Down
9 changes: 8 additions & 1 deletion Tools/Play/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,15 @@ function approvedRelease(releases, version) {
return releases.find((r) => r.track === 'production' && APPROVED.includes(r.status) && namesVersion(r.name, version)) ?? null;
}

// What a commit passes. Held (--changes-not-sent-for-review) unless it's sent
// for review or, for a draft, the user asked for no hold; a review already
// under way always makes it fail rather than be cancelled.
function commitFlags({ forReview = false, withoutHold = false } = {}) {
return forReview || withoutHold ? ['--changes-in-review', 'error'] : ['--changes-not-sent-for-review', '--changes-in-review', 'error'];
}

module.exports = {
APPROVED, sameVersion, namesVersion, releasesIn, uploadedIn, approvedRelease,
commitFlags, APPROVED, sameVersion, namesVersion, releasesIn, uploadedIn, approvedRelease,
TESTING, LIMITS, KEPT, tracksIn, alsoProblem, cutNotes, overLimits, counted, describe,
betaIn, nativeSymbols, onlyTallScreenshots, everPublished,
};
37 changes: 25 additions & 12 deletions Tools/Play/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@
// --send-for-review on a testing-track release only: with --send, send
// the edit for review instead of holding it (without
// --send the plan says it would)
// --without-hold on a draft release only (production, or a testing
// track without --rollout): commit without holding the
// edit back, for an app whose changes Play won't hold
// (it refuses --changes-not-sent-for-review unless an
// update was rejected). The draft serves nobody, but
// anything else waiting in the Play Console goes for
// review with it: check Publishing overview first.
// --help, -h print this and stop
//
// Nothing here submits for review but the nightly testing build: every
// other write passes --changes-not-sent-for-review, so it waits in the Play
// Console for the user. The nightly's release (--send-for-review) still
// Console for the user, unless --without-hold asks a draft release not to. The nightly's release (--send-for-review) still
// passes --changes-in-review error, so it never cancels a review already
// under way.

Expand Down Expand Up @@ -105,6 +112,7 @@ const PRODUCTS = path.join(HERE, 'Monetization/iap');
const send = args.includes('--send');
const offline = args.includes('--offline');
const forReview = args.includes('--send-for-review');
const withoutHold = args.includes('--without-hold');
const usage = (why) => { console.error(why); process.exit(2); };
if (offline && send) usage('--offline reads nothing from Play, so it can send nothing: drop one.');
const STEPS = ['listing', 'images', 'screenshots', 'product', 'datasafety', 'release', 'tracks', 'versions', 'status'];
Expand All @@ -115,9 +123,10 @@ const SHOTS = option('--screenshots') ? path.resolve(option('--screenshots')) :

// Every write waits in the Play Console: only the user submits, but for the
// nightly's release.
const HOLD = ['--changes-not-sent-for-review', '--changes-in-review', 'error'];
// Play's answer when an app was never published: it won't hold changes, and
// a commit without the hold would send every pending change for review.
const HOLD = lib.commitFlags();
// Play's answer when it won't hold an app's changes back (it holds them only
// after a rejected update, and never for an app it hasn't published): a commit
// without the hold would send every pending change for review.
const REFUSES_HOLD = /changesNotSentForReview must not be set/i;

let changes = 0;
Expand Down Expand Up @@ -191,11 +200,11 @@ function stage(name, { lint, plan, apply }) {
if (!send) return true;
const wrote = gplay(apply);
if (wrote.status !== 0 && REFUSES_HOLD.test(wrote.err || wrote.out)) {
// Never send without the hold: on a never-published app that sends every
// pending change for review, and an approval can publish the app.
// Never send without the hold: that sends every pending change for
// review, and on a never-published app an approval can publish it.
failed += 1;
console.log(`${name}: this app has never been published, so Play refuses to hold changes back and would send`);
console.log(' every pending change for review. Nothing was sent; make this change in the Play Console.');
console.log(`${name}: Play won't hold this app's changes back from review, and without the hold every pending`);
console.log(' change would go for review. Nothing was sent; make this change in the Play Console.');
return false;
}
if (wrote.status !== 0) {
Expand Down Expand Up @@ -462,6 +471,7 @@ function releaseStep() {
const alsoWrong = lib.alsoProblem(TRACK, also);
if (alsoWrong) return refuse(`${alsoWrong}.`);
if (forReview && !rollout) return refuse('--send-for-review sends a rolled-out release; pass --rollout with it.');
if (withoutHold && (rollout || forReview)) return refuse('--without-hold is for a draft release only, not with --rollout or --send-for-review.');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan doesn't mention --without-hold. The "checks out for … ready for …" line (504–505) adds , sent for review for --send-for-review, but a run with --without-hold and no --send prints the same plan as a held draft. So the dry run hides the one thing this flag risks: everything waiting in the Play Console goes for review on --send. Please add something like , without the hold (anything else waiting goes for review) to that line when withoutHold is set.

if (!fs.existsSync(ARTIFACT)) return refuse(`${ARTIFACT} is not there.`);
// A testing track takes a beta build, production a build of its own.
const beta = betaOf(ARTIFACT);
Expand Down Expand Up @@ -497,15 +507,18 @@ function releaseStep() {
changes += 1;
if (!send) return;
const published = lib.everPublished(maybe(online('tracks', 'list', '--output', 'json'))?.tracks);
// Sent for review: no hold, and a review already under way makes the
// commit fail rather than be cancelled and resubmitted.
const commit = forReview ? ['--changes-in-review', 'error'] : HOLD;
// Sent for review, or a draft with --without-hold: no hold. Either way a
// review already under way makes the commit fail rather than be cancelled.
const commit = lib.commitFlags({ forReview, withoutHold });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--without-hold drops the hold even when published (line 509) is false. Your own comments say that's the dangerous case: on a never-published app, a commit without the hold sends every pending change for review, and an approval can publish the app. The refusal on line 517 tells the person to use the Play Console, not this flag, but nothing stops them from passing it anyway. When they do, the listing, pricing and the rest go for review, and the warning on line 527 doesn't print because it checks only forReview. Please refuse withoutHold && !published before the commit, or at least extend the line-527 warning to (forReview || withoutHold) && !published.

const wrote = gplay(online(...argv, ...commit));
if (wrote.status !== 0 && REFUSES_HOLD.test(wrote.err || wrote.out)) {
return refuse('this app has never been published, so Play refuses to hold the release back and would send every pending change for review. Upload it in the Play Console instead.');
return refuse(published
? 'Play won\'t hold this app\'s changes back from review (it holds them only after a rejected update). A draft serves nobody: once Publishing overview in the Play Console shows nothing else waiting, run this again with --without-hold, or upload it in the Play Console.'
: 'this app has never been published, so Play refuses to hold the release back and would send every pending change for review. Upload it in the Play Console instead.');
}
if (wrote.status !== 0) { failed += 1; console.log(`Release: failed.\n${wrote.err || wrote.out}`); return; }
if (forReview) sentForReview = true;
if (withoutHold) console.log('Release: committed without the hold. Anything else waiting in the Play Console went for review with it.');
console.log(production
? 'Release: uploaded as a draft on production. It reaches nobody until it is rolled out in the Play Console.'
: rollout
Expand Down
7 changes: 7 additions & 0 deletions Tools/Play/play.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ const path = require('path');
const { spawnSync } = require('child_process');
const lib = require('./lib');

test('a commit is held unless it goes for review or a draft asks not to be', () => {
const hold = ['--changes-not-sent-for-review', '--changes-in-review', 'error'];
assert.deepStrictEqual(lib.commitFlags(), hold);
assert.deepStrictEqual(lib.commitFlags({ forReview: true }), ['--changes-in-review', 'error']);
assert.deepStrictEqual(lib.commitFlags({ withoutHold: true }), ['--changes-in-review', 'error']);
});

test('notes are cut to 500 characters at a line break', () => {
const line = 'x'.repeat(99);
const notes = Array.from({ length: 8 }, () => line).join('\n');
Expand Down
Loading