Skip to content

Commit a7b80f3

Browse files
authored
feat: differentiate vote messages for v1.0-rc proposals (#19)
See #304.
1 parent 918d1a2 commit a7b80f3

15 files changed

Lines changed: 111 additions & 4 deletions

dist/breaking-change.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
Thanks for your contribution :pray:
22

3+
{{^release_candidate}}
34
This is now marked as a [`breaking-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-breaking-change) proposal to the Standard, this means that an old version of `publiccode.yml` won't be compatible with the new version.
5+
{{/release_candidate}}
6+
{{#release_candidate}}
7+
This is now marked as a [`breaking-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-breaking-change) proposal to the Standard. This targets the upcoming **v1.0** on the `1.0-rc` branch.
8+
{{/release_candidate}}
49

10+
{{^release_candidate}}
511
Breaking changes can be released with a new major version at most once every two years, provided the current version of the Standard has been deprecating the object of this proposal for at least 6 months.
612

13+
{{/release_candidate}}
714
Example of breaking changes are removal of keys or changes to key types.
815

916
The next eligible voting round will take place on **{{ next_vote_date }}**

dist/bugfix-change.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
Thanks for your contribution :pray:
22

3+
{{^release_candidate}}
34
This is now marked as a [`bugfix-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-bugfix-change),
45
this means that this change won't break any compatibility with the old versions of the Standard.
6+
{{/release_candidate}}
7+
{{#release_candidate}}
8+
This is now marked as a [`bugfix-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-bugfix-change). This targets the upcoming **v1.0** on the `1.0-rc` branch.
9+
{{/release_candidate}}
510

611
Example of bugfix changes are typo fixes.
712

dist/deprecation-change.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
Thanks for your contribution :pray:
22

3+
{{^release_candidate}}
34
This is now marked as a [`deprecation-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-deprecation), this means that this change won't break any compatibility with the old versions of the Standard,
45
and it will be possibile to make the definitive change 6 months after the deprecation with a new major release.
6+
{{/release_candidate}}
7+
{{#release_candidate}}
8+
This is now marked as a [`deprecation-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-deprecation). This targets the upcoming **v1.0** on the `1.0-rc` branch.
9+
{{/release_candidate}}
510

611
The next eligible voting round will take place on **{{ next_vote_date }}**
712

dist/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8923,7 +8923,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
89238923
return (mod && mod.__esModule) ? mod : { "default": mod };
89248924
};
89258925
Object.defineProperty(exports, "__esModule", ({ value: true }));
8926-
exports.removeLabel = exports.addLabels = exports.setLabels = exports.commentToIssue = exports.reactToComment = exports.isChair = exports.isMaintainer = exports.inTeam = exports.getCommandsFromComment = void 0;
8926+
exports.removeLabel = exports.addLabels = exports.setLabels = exports.commentToIssue = exports.reactToComment = exports.hasLabel = exports.isChair = exports.isMaintainer = exports.inTeam = exports.getCommandsFromComment = void 0;
89278927
const fs_1 = __nccwpck_require__(7147);
89288928
const mustache_1 = __importDefault(__nccwpck_require__(8272));
89298929
const config_1 = __nccwpck_require__(6373);
@@ -8956,6 +8956,12 @@ function isChair(org, username) {
89568956
});
89578957
}
89588958
exports.isChair = isChair;
8959+
function hasLabel(context, name) {
8960+
var _a, _b;
8961+
const labels = ((_b = (_a = context.payload.issue) === null || _a === void 0 ? void 0 : _a.labels) !== null && _b !== void 0 ? _b : []);
8962+
return labels.some(label => label.name === name);
8963+
}
8964+
exports.hasLabel = hasLabel;
89598965
function reactToComment(context) {
89608966
var _a;
89618967
return __awaiter(this, void 0, void 0, function* () {
@@ -8996,6 +9002,7 @@ function toMustacheView(context) {
89969002
steering_committee_team: config_1.STEERING_COMMITTEE_TEAM,
89979003
comment_author_username: (_c = (_b = (_a = context.payload.comment) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.login) !== null && _c !== void 0 ? _c : '',
89989004
next_vote_date: getNextVoteDate(),
9005+
release_candidate: hasLabel(context, 'v1'),
89999006
};
90009007
}
90019008
function commentToIssue(context, template, additionalVariables) {
@@ -9384,6 +9391,7 @@ function run(context) {
93849391
// eslint-disable-next-line prefer-template,no-path-concat
93859392
const template = (0, fs_1.readFileSync)(__nccwpck_require__.ab + "vote-end.md", 'utf8');
93869393
(0, bot_1.reactToComment)(context);
9394+
const isReleaseCandidate = (0, bot_1.hasLabel)(context, 'v1');
93879395
const { owner, repo, number } = context.issue;
93889396
const comments = yield octokit_1.default.paginate('GET /repos/:owner/:repo/issues/:issue_number/comments', { owner, repo, issue_number: number });
93899397
const voteComment = getBotComment(comments, '<!-- ##bot-voting-marker## -->');
@@ -9420,7 +9428,13 @@ function run(context) {
94209428
const voteResults = processResults(thumbsUps.map(t => t.user.login), thumbsDowns.map(t => t.user.login), !isAdditionalPeriod, approvingMember);
94219429
switch (+voteResults) {
94229430
case VoteResult.Approved:
9423-
resultMessage = `
9431+
resultMessage = isReleaseCandidate
9432+
? `
9433+
**Proposal approved** :+1:
9434+
9435+
This proposal will be merged into the \`1.0-rc\` branch and released later as part of v1.0.
9436+
`
9437+
: `
94249438
**Proposal approved** :+1:
94259439

94269440
This proposal is now ready to be merged and get released with a new version of the standard.

dist/minor-change.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
Thanks for your contribution :pray:
22

3+
{{^release_candidate}}
34
This is now marked as a [`minor-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-minor-change),
45
this means that old versions of `publiccode.yml` will still be valid with this change.
6+
{{/release_candidate}}
7+
{{#release_candidate}}
8+
This is now marked as a [`minor-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-minor-change). This targets the upcoming **v1.0** on the `1.0-rc` branch.
9+
{{/release_candidate}}
510

611
Example of minor changes are additions of new keys or making keys optional.
712

dist/vote-start.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ The polls will stay open for {{ vote_period_days }} days, until **{{ vote_end_da
77

88
Leave a :+1: (thumbs up) **on this comment** to accept the proposal or a :-1: (thumbs down) to reject it.
99

10+
{{#release_candidate}}
11+
This proposal targets **v1.0**. If approved it will be merged into the `1.0-rc` branch and released later as part of v1.0, not immediately.
12+
13+
{{/release_candidate}}
1014
cc @{{{ steering_committee_team }}}

src/bot.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Context } from '@actions/github/lib/context';
2+
3+
import { hasLabel } from './bot';
4+
5+
function contextWithLabels(labels: unknown): Context {
6+
return { payload: { issue: { labels } } } as unknown as Context;
7+
}
8+
9+
test('hasLabel returns true when the label is present', () => {
10+
const context = contextWithLabels([{ name: 'v1' }, { name: 'vote-start' }]);
11+
12+
expect(hasLabel(context, 'v1')).toBe(true);
13+
});
14+
15+
test('hasLabel returns false when the label is absent', () => {
16+
const context = contextWithLabels([{ name: 'vote-start' }]);
17+
18+
expect(hasLabel(context, 'v1')).toBe(false);
19+
});
20+
21+
test('hasLabel returns false when there are no labels', () => {
22+
expect(hasLabel(contextWithLabels([]), 'v1')).toBe(false);
23+
expect(hasLabel({ payload: {} } as unknown as Context, 'v1')).toBe(false);
24+
});

src/bot.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface TemplateVariables {
2121
bot_username: string;
2222
comment_author_username: string;
2323
next_vote_date: string;
24+
release_candidate: boolean;
2425
}
2526

2627
export interface Command {
@@ -51,6 +52,12 @@ export async function isChair(org: string, username: string) {
5152
return inTeam(org, username, 'chair');
5253
}
5354

55+
export function hasLabel(context: Context, name: LabelName): boolean {
56+
const labels = (context.payload.issue?.labels ?? []) as Array<{ name?: string }>;
57+
58+
return labels.some(label => label.name === name);
59+
}
60+
5461
export async function reactToComment(context: Context) {
5562
const { owner: org, repo } = context.repo;
5663

@@ -94,6 +101,7 @@ function toMustacheView(context: Context): TemplateVariables {
94101
steering_committee_team: STEERING_COMMITTEE_TEAM,
95102
comment_author_username: context.payload.comment?.user?.login ?? '',
96103
next_vote_date: getNextVoteDate(),
104+
release_candidate: hasLabel(context, 'v1'),
97105
};
98106
}
99107

src/commands/voteEnd.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Context } from '@actions/github/lib/context';
33
import { GetResponseDataTypeFromEndpointMethod } from '@octokit/types';
44
import { BOT_USERNAME, MAINTAINERS_TEAM } from '../config';
55
import {
6-
reactToComment, commentToIssue, addLabels, removeLabel,
6+
reactToComment, commentToIssue, addLabels, removeLabel, hasLabel,
77
} from '../bot';
88
import { LabelName } from '../labels';
99
import octokit from '../octokit';
@@ -100,6 +100,8 @@ export default async function run(context: Context) {
100100

101101
reactToComment(context);
102102

103+
const isReleaseCandidate = hasLabel(context, 'v1');
104+
103105
const { owner, repo, number } = context.issue;
104106

105107
const comments = await octokit.paginate(
@@ -159,7 +161,13 @@ export default async function run(context: Context) {
159161

160162
switch (+voteResults) {
161163
case VoteResult.Approved:
162-
resultMessage = `
164+
resultMessage = isReleaseCandidate
165+
? `
166+
**Proposal approved** :+1:
167+
168+
This proposal will be merged into the \`1.0-rc\` branch and released later as part of v1.0.
169+
`
170+
: `
163171
**Proposal approved** :+1:
164172
165173
This proposal is now ready to be merged and get released with a new version of the standard.

src/labels.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type LabelName =
44
| 'standard-deprecation'
55
| 'standard-minor-change'
66
| 'standard-national-section'
7+
| 'v1'
78
| 'vote-additional-period'
89
| 'vote-approved'
910
| 'vote-draft'

0 commit comments

Comments
 (0)