Skip to content

Commit f99347b

Browse files
Refuse release PR writes when a test channel is set
A test-channel run posts only to that channel. It does not rewrite the release pull request body, even when allow-pr-write is true, and it logs the refusal. Co-authored-by: Victor Pinto <vpintorico@users.noreply.github.com>
1 parent c18467e commit f99347b

4 files changed

Lines changed: 47 additions & 7 deletions

File tree

‎.github/actions/release-slack-summaries/action.yml‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ description: >-
44
summary (Zap 597) to Slack. Jira is read-only. The caller passes short-lived
55
GitHub tokens from `.github/actions/get-token`; this action does not mint
66
tokens. Dry-run defaults to true and writes the message to the job summary.
7-
The release PR checklist is rewritten only when allow-pr-write is true and
8-
dry-run is false.
7+
The release PR checklist is rewritten only when allow-pr-write is true,
8+
dry-run is false, and test-channel is empty. A test channel never writes
9+
a pull request body.
910
1011
inputs:
1112
mode:
@@ -64,7 +65,8 @@ inputs:
6465
default: jiraProject
6566
test-channel:
6667
description: >-
67-
When set, post only to this channel. Real release channels are not used.
68+
When set, post only to this channel and do not write any release PR body,
69+
even if allow-pr-write is true. Real release channels are not used.
6870
required: false
6971
default: ''
7072
dry-run:
@@ -76,7 +78,8 @@ inputs:
7678
allow-pr-write:
7779
description: >-
7880
Default false. Zap 597 rewrites the release PR checklist only when this
79-
is true and dry-run is false. Blocker summary never writes.
81+
is true, dry-run is false, and test-channel is empty. Blocker summary
82+
never writes.
8083
required: false
8184
default: 'false'
8285
github-tools-repository:

‎.github/actions/release-slack-summaries/gates.test.mjs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ describe('safe defaults', () => {
8484
}),
8585
true,
8686
);
87+
assert.equal(
88+
shouldWriteReleasePr({
89+
mode: 'release-validation',
90+
dryRun: false,
91+
allowPrWrite: true,
92+
testChannel: '#release-summary-test',
93+
}),
94+
false,
95+
);
96+
assert.equal(
97+
shouldWriteReleasePr({
98+
mode: 'release-validation',
99+
dryRun: false,
100+
allowPrWrite: true,
101+
testChannel: ' ',
102+
}),
103+
true,
104+
);
87105
});
88106

89107
it('posts only to the test channel when one is set', () => {

‎.github/actions/release-slack-summaries/lib/gates.mjs‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Safe defaults for the shared action.
33
* Dry-run posts nothing and writes nothing. A pull request body is written
4-
* only for release validation, when dry-run is off and allow-pr-write is on.
5-
* `test-channel` changes the Slack target only (see the action description).
4+
* only for release validation, when dry-run is off, allow-pr-write is on,
5+
* and test-channel is empty. A test channel never writes a pull request body.
66
*/
77

88
/**
@@ -39,9 +39,18 @@ export function isPrWriteAllowed(value) {
3939
* @param {string} args.mode - `blocker-summary` or `release-validation`.
4040
* @param {boolean} args.dryRun - Parsed dry-run flag.
4141
* @param {boolean} args.allowPrWrite - Parsed allow-pr-write flag.
42+
* @param {string} [args.testChannel] - When set, the write is refused.
4243
* @returns {boolean} Whether this run may PATCH a pull request body.
4344
*/
44-
export function shouldWriteReleasePr({ mode, dryRun, allowPrWrite }) {
45+
export function shouldWriteReleasePr({
46+
mode,
47+
dryRun,
48+
allowPrWrite,
49+
testChannel,
50+
}) {
51+
if ((testChannel || '').trim()) {
52+
return false;
53+
}
4554
return (
4655
mode === 'release-validation' && dryRun === false && allowPrWrite === true
4756
);

‎.github/actions/release-slack-summaries/run.mjs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Jira is read-only. GitHub tokens are passed in by the caller (get-token);
66
* this action does not mint them and does not read a personal access token.
77
* Defaults: dry-run, and no pull request write unless `allow-pr-write` is set.
8+
* A set test-channel also refuses the pull request write.
89
*/
910

1011
import { Octokit } from '@octokit/rest';
@@ -205,6 +206,12 @@ export async function run(config, deps = {}) {
205206
`OPEN: topology Jira project field "${config.topologyJiraProjectField}" is the PROPOSED name. Teams with a key: ${teamsWithProjects} of ${Object.keys(registry.teams).length}.`,
206207
);
207208
openLines.push(...registry.warnings.map((warning) => `OPEN: ${warning}`));
209+
if (config.testChannel) {
210+
const refusal =
211+
'test-channel is set. Refusing pull request body writes even if allow-pr-write is true. Zap 597 still rewrites those bodies during the parallel run.';
212+
console.log(refusal);
213+
openLines.push(refusal);
214+
}
208215

209216
writeSummary(
210217
[
@@ -423,6 +430,9 @@ function describePrWrite(config, updatedBody) {
423430
if (!updatedBody) {
424431
return 'checklist unchanged';
425432
}
433+
if (config.testChannel) {
434+
return 'test-channel is set, not written';
435+
}
426436
if (config.dryRun) {
427437
return 'dry-run, not written';
428438
}

0 commit comments

Comments
 (0)