Skip to content

Commit 98691ac

Browse files
authored
feat: show next scheduled voting date in replies (#12)
Fix #11.
1 parent 6a6af11 commit 98691ac

15 files changed

+61
-24
lines changed

dist/breaking-change.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Breaking changes can be released with a new major version at most once every two
66

77
Example of breaking changes are removal of keys or changes to key types.
88

9-
The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start`.
9+
The next eligible voting round will take place on **{{ next_vote_date }}**
1010

11-
cc @{{ chair_team }} @{{{ steering_committee_team }}}
11+
cc @{{{ steering_committee_team }}}

dist/bugfix-change.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ this means that this change won't break any compatibility with the old versions
55

66
Example of bugfix changes are typo fixes.
77

8-
The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start`.
8+
The next eligible voting round will take place on **{{ next_vote_date }}**
99

10-
cc @{{ chair_team }} @{{{ steering_committee_team }}}
10+
cc @{{{ steering_committee_team }}}

dist/deprecation-change.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ Thanks for your contribution :pray:
33
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,
44
and it will be possibile to make the definitive change 6 months after the deprecation with a new major release.
55

6-
The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start`
6+
The next eligible voting round will take place on **{{ next_vote_date }}**
77

8-
cc @{{ chair_team }} @{{{ steering_committee_team }}}
8+
cc @{{{ steering_committee_team }}}

dist/index.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8969,6 +8969,22 @@ function reactToComment(context) {
89698969
});
89708970
}
89718971
exports.reactToComment = reactToComment;
8972+
function getNextVoteDate() {
8973+
const now = new Date();
8974+
const year = now.getFullYear();
8975+
const schedule = [
8976+
new Date(year, 0 /* Jan */, 30),
8977+
new Date(year, 4 /* May */, 30),
8978+
new Date(year, 8 /* Sep */, 30),
8979+
];
8980+
const next = schedule.find(d => d > now);
8981+
const nextDate = next !== null && next !== void 0 ? next : new Date(year + 1, schedule[0].getMonth(), schedule[0].getDate());
8982+
return nextDate.toLocaleDateString('en-US', {
8983+
month: 'long',
8984+
day: 'numeric',
8985+
year: 'numeric',
8986+
});
8987+
}
89728988
function toMustacheView(context) {
89738989
var _a, _b, _c;
89748990
return {
@@ -8977,6 +8993,7 @@ function toMustacheView(context) {
89778993
maintainers_team: config_1.MAINTAINERS_TEAM,
89788994
steering_committee_team: config_1.STEERING_COMMITTEE_TEAM,
89798995
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 : '',
8996+
next_vote_date: getNextVoteDate(),
89808997
};
89818998
}
89828999
function commentToIssue(context, template, additionalVariables) {
@@ -9427,7 +9444,7 @@ This proposal can be put to vote again in 90 days (using \`${config_1.BOT_USERNA
94279444
resultMessage = `
94289445
${resultMessage}
94299446

9430-
cc @${config_1.CHAIR_TEAM} @${config_1.MAINTAINERS_TEAM}
9447+
cc @${config_1.MAINTAINERS_TEAM}
94319448
`;
94329449
const vars = {
94339450
vote_thumbs_ups_tags: thumbsUpsTags.join(' '),

dist/minor-change.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ this means that old versions of `publiccode.yml` will still be valid with this c
55

66
Example of minor changes are additions of new keys or making keys optional.
77

8-
The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start`
8+
The next eligible voting round will take place on **{{ next_vote_date }}**
99

10-
cc @{{ chair_team }} @{{{ steering_committee_team }}}
10+
cc @{{{ steering_committee_team }}}

dist/national-section.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ This is now marked as a national section change to the Standard and it will requ
44

55
[National section rules](https://github.com/publiccodeyml/publiccode.yml/blob/main/governance/procedure-proposing-changes-and-voting.md#country-specific-sections)
66

7-
cc @{{ chair_team }} @{{{ steering_committee_team }}}
7+
cc @{{{ steering_committee_team }}}

dist/vote-start.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
If you are a member of the [Steering Committee](https://github.com/publiccodeyml/publiccode.yml/blob/main/governance/charter.md#steering-committee-publiccodeymlsteering-committee) you can now vote!
55

66
The polls will stay open for {{ vote_period_days }} days, until **{{ vote_end_date }}**.
7-
At the end of that period the Chair (@{{ chair_team }}) will mark the voting period as over using `@{{ bot_username }} vote-end`
87

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

src/bot.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface TemplateVariables {
2020
steering_committee_team: string;
2121
bot_username: string;
2222
comment_author_username: string;
23+
next_vote_date: string;
2324
}
2425

2526
export interface Command {
@@ -62,13 +63,34 @@ export async function reactToComment(context: Context) {
6263
});
6364
}
6465

66+
function getNextVoteDate() {
67+
const now = new Date();
68+
const year = now.getFullYear();
69+
70+
const schedule = [
71+
new Date(year, 0 /* Jan */, 30),
72+
new Date(year, 4 /* May */, 30),
73+
new Date(year, 8 /* Sep */, 30),
74+
];
75+
76+
const next = schedule.find(d => d > now);
77+
const nextDate = next ?? new Date(year + 1, schedule[0]!.getMonth(), schedule[0]!.getDate());
78+
79+
return nextDate.toLocaleDateString('en-US', {
80+
month: 'long',
81+
day: 'numeric',
82+
year: 'numeric',
83+
});
84+
}
85+
6586
function toMustacheView(context: Context): TemplateVariables {
6687
return {
6788
bot_username: BOT_USERNAME,
6889
chair_team: CHAIR_TEAM,
6990
maintainers_team: MAINTAINERS_TEAM,
7091
steering_committee_team: STEERING_COMMITTEE_TEAM,
7192
comment_author_username: context.payload.comment?.user?.login ?? '',
93+
next_vote_date: getNextVoteDate(),
7294
};
7395
}
7496

src/commands/voteEnd.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readFileSync } from 'fs';
22
import { Context } from '@actions/github/lib/context';
33
import { GetResponseDataTypeFromEndpointMethod } from '@octokit/types';
4-
import { BOT_USERNAME, CHAIR_TEAM, MAINTAINERS_TEAM } from '../config';
4+
import { BOT_USERNAME, MAINTAINERS_TEAM } from '../config';
55
import {
66
reactToComment, commentToIssue, addLabels, removeLabel,
77
} from '../bot';
@@ -129,7 +129,7 @@ export default async function run(context: Context) {
129129
const thumbsDownsTags = thumbsDowns.map(r => `@${r.user?.login}`);
130130

131131
let resultMessage = '';
132-
const voteDetailsNotes: string [] = [];
132+
const voteDetailsNotes: string[] = [];
133133

134134
await removeLabel(context, 'vote-start');
135135

@@ -191,7 +191,7 @@ This proposal can be put to vote again in 90 days (using \`${BOT_USERNAME} vote-
191191
resultMessage = `
192192
${resultMessage}
193193
194-
cc @${CHAIR_TEAM} @${MAINTAINERS_TEAM}
194+
cc @${MAINTAINERS_TEAM}
195195
`;
196196

197197
const vars = {

src/templates/breaking-change.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Breaking changes can be released with a new major version at most once every two
66

77
Example of breaking changes are removal of keys or changes to key types.
88

9-
The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start`.
9+
The next eligible voting round will take place on **{{ next_vote_date }}**
1010

11-
cc @{{ chair_team }} @{{{ steering_committee_team }}}
11+
cc @{{{ steering_committee_team }}}

0 commit comments

Comments
 (0)