From 757aa88355f1a5c9f71d573a95390c38ab3185a0 Mon Sep 17 00:00:00 2001 From: Fabio Bonelli Date: Thu, 9 Oct 2025 17:28:41 +0200 Subject: [PATCH] feat: show next scheduled voting date in replies Fix #11. --- dist/breaking-change.md | 4 ++-- dist/bugfix-change.md | 4 ++-- dist/deprecation-change.md | 4 ++-- dist/index.js | 19 ++++++++++++++++++- dist/minor-change.md | 4 ++-- dist/national-section.md | 2 +- dist/vote-start.md | 1 - src/bot.ts | 22 ++++++++++++++++++++++ src/commands/voteEnd.ts | 6 +++--- src/templates/breaking-change.md | 4 ++-- src/templates/bugfix-change.md | 4 ++-- src/templates/deprecation-change.md | 4 ++-- src/templates/minor-change.md | 4 ++-- src/templates/national-section.md | 2 +- src/templates/vote-start.md | 1 - 15 files changed, 61 insertions(+), 24 deletions(-) diff --git a/dist/breaking-change.md b/dist/breaking-change.md index a3fe428..600ca01 100644 --- a/dist/breaking-change.md +++ b/dist/breaking-change.md @@ -6,6 +6,6 @@ Breaking changes can be released with a new major version at most once every two Example of breaking changes are removal of keys or changes to key types. -The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start`. +The next eligible voting round will take place on **{{ next_vote_date }}** -cc @{{ chair_team }} @{{{ steering_committee_team }}} +cc @{{{ steering_committee_team }}} diff --git a/dist/bugfix-change.md b/dist/bugfix-change.md index a06f2c6..066fa5f 100644 --- a/dist/bugfix-change.md +++ b/dist/bugfix-change.md @@ -5,6 +5,6 @@ this means that this change won't break any compatibility with the old versions Example of bugfix changes are typo fixes. -The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start`. +The next eligible voting round will take place on **{{ next_vote_date }}** -cc @{{ chair_team }} @{{{ steering_committee_team }}} +cc @{{{ steering_committee_team }}} diff --git a/dist/deprecation-change.md b/dist/deprecation-change.md index 17c1b0c..2555159 100644 --- a/dist/deprecation-change.md +++ b/dist/deprecation-change.md @@ -3,6 +3,6 @@ Thanks for your contribution :pray: 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, and it will be possibile to make the definitive change 6 months after the deprecation with a new major release. -The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start` +The next eligible voting round will take place on **{{ next_vote_date }}** -cc @{{ chair_team }} @{{{ steering_committee_team }}} +cc @{{{ steering_committee_team }}} diff --git a/dist/index.js b/dist/index.js index 8a5eba8..64b69db 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8969,6 +8969,22 @@ function reactToComment(context) { }); } exports.reactToComment = reactToComment; +function getNextVoteDate() { + const now = new Date(); + const year = now.getFullYear(); + const schedule = [ + new Date(year, 0 /* Jan */, 30), + new Date(year, 4 /* May */, 30), + new Date(year, 8 /* Sep */, 30), + ]; + const next = schedule.find(d => d > now); + const nextDate = next !== null && next !== void 0 ? next : new Date(year + 1, schedule[0].getMonth(), schedule[0].getDate()); + return nextDate.toLocaleDateString('en-US', { + month: 'long', + day: 'numeric', + year: 'numeric', + }); +} function toMustacheView(context) { var _a, _b, _c; return { @@ -8977,6 +8993,7 @@ function toMustacheView(context) { maintainers_team: config_1.MAINTAINERS_TEAM, steering_committee_team: config_1.STEERING_COMMITTEE_TEAM, 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 : '', + next_vote_date: getNextVoteDate(), }; } 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 resultMessage = ` ${resultMessage} -cc @${config_1.CHAIR_TEAM} @${config_1.MAINTAINERS_TEAM} +cc @${config_1.MAINTAINERS_TEAM} `; const vars = { vote_thumbs_ups_tags: thumbsUpsTags.join(' '), diff --git a/dist/minor-change.md b/dist/minor-change.md index dff8c33..008da21 100644 --- a/dist/minor-change.md +++ b/dist/minor-change.md @@ -5,6 +5,6 @@ this means that old versions of `publiccode.yml` will still be valid with this c Example of minor changes are additions of new keys or making keys optional. -The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start` +The next eligible voting round will take place on **{{ next_vote_date }}** -cc @{{ chair_team }} @{{{ steering_committee_team }}} +cc @{{{ steering_committee_team }}} diff --git a/dist/national-section.md b/dist/national-section.md index 1451ef1..dd99350 100644 --- a/dist/national-section.md +++ b/dist/national-section.md @@ -4,4 +4,4 @@ This is now marked as a national section change to the Standard and it will requ [National section rules](https://github.com/publiccodeyml/publiccode.yml/blob/main/governance/procedure-proposing-changes-and-voting.md#country-specific-sections) -cc @{{ chair_team }} @{{{ steering_committee_team }}} +cc @{{{ steering_committee_team }}} diff --git a/dist/vote-start.md b/dist/vote-start.md index 606d030..7d87edb 100644 --- a/dist/vote-start.md +++ b/dist/vote-start.md @@ -4,7 +4,6 @@ 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! The polls will stay open for {{ vote_period_days }} days, until **{{ vote_end_date }}**. -At the end of that period the Chair (@{{ chair_team }}) will mark the voting period as over using `@{{ bot_username }} vote-end` Leave a :+1: (thumbs up) **on this comment** to accept the proposal or a :-1: (thumbs down) to reject it. diff --git a/src/bot.ts b/src/bot.ts index b47d81e..258a95e 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -20,6 +20,7 @@ interface TemplateVariables { steering_committee_team: string; bot_username: string; comment_author_username: string; + next_vote_date: string; } export interface Command { @@ -62,6 +63,26 @@ export async function reactToComment(context: Context) { }); } +function getNextVoteDate() { + const now = new Date(); + const year = now.getFullYear(); + + const schedule = [ + new Date(year, 0 /* Jan */, 30), + new Date(year, 4 /* May */, 30), + new Date(year, 8 /* Sep */, 30), + ]; + + const next = schedule.find(d => d > now); + const nextDate = next ?? new Date(year + 1, schedule[0]!.getMonth(), schedule[0]!.getDate()); + + return nextDate.toLocaleDateString('en-US', { + month: 'long', + day: 'numeric', + year: 'numeric', + }); +} + function toMustacheView(context: Context): TemplateVariables { return { bot_username: BOT_USERNAME, @@ -69,6 +90,7 @@ function toMustacheView(context: Context): TemplateVariables { maintainers_team: MAINTAINERS_TEAM, steering_committee_team: STEERING_COMMITTEE_TEAM, comment_author_username: context.payload.comment?.user?.login ?? '', + next_vote_date: getNextVoteDate(), }; } diff --git a/src/commands/voteEnd.ts b/src/commands/voteEnd.ts index 6268613..16e869f 100644 --- a/src/commands/voteEnd.ts +++ b/src/commands/voteEnd.ts @@ -1,7 +1,7 @@ import { readFileSync } from 'fs'; import { Context } from '@actions/github/lib/context'; import { GetResponseDataTypeFromEndpointMethod } from '@octokit/types'; -import { BOT_USERNAME, CHAIR_TEAM, MAINTAINERS_TEAM } from '../config'; +import { BOT_USERNAME, MAINTAINERS_TEAM } from '../config'; import { reactToComment, commentToIssue, addLabels, removeLabel, } from '../bot'; @@ -129,7 +129,7 @@ export default async function run(context: Context) { const thumbsDownsTags = thumbsDowns.map(r => `@${r.user?.login}`); let resultMessage = ''; - const voteDetailsNotes: string [] = []; + const voteDetailsNotes: string[] = []; await removeLabel(context, 'vote-start'); @@ -191,7 +191,7 @@ This proposal can be put to vote again in 90 days (using \`${BOT_USERNAME} vote- resultMessage = ` ${resultMessage} -cc @${CHAIR_TEAM} @${MAINTAINERS_TEAM} +cc @${MAINTAINERS_TEAM} `; const vars = { diff --git a/src/templates/breaking-change.md b/src/templates/breaking-change.md index a3fe428..600ca01 100644 --- a/src/templates/breaking-change.md +++ b/src/templates/breaking-change.md @@ -6,6 +6,6 @@ Breaking changes can be released with a new major version at most once every two Example of breaking changes are removal of keys or changes to key types. -The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start`. +The next eligible voting round will take place on **{{ next_vote_date }}** -cc @{{ chair_team }} @{{{ steering_committee_team }}} +cc @{{{ steering_committee_team }}} diff --git a/src/templates/bugfix-change.md b/src/templates/bugfix-change.md index a06f2c6..066fa5f 100644 --- a/src/templates/bugfix-change.md +++ b/src/templates/bugfix-change.md @@ -5,6 +5,6 @@ this means that this change won't break any compatibility with the old versions Example of bugfix changes are typo fixes. -The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start`. +The next eligible voting round will take place on **{{ next_vote_date }}** -cc @{{ chair_team }} @{{{ steering_committee_team }}} +cc @{{{ steering_committee_team }}} diff --git a/src/templates/deprecation-change.md b/src/templates/deprecation-change.md index 17c1b0c..2555159 100644 --- a/src/templates/deprecation-change.md +++ b/src/templates/deprecation-change.md @@ -3,6 +3,6 @@ Thanks for your contribution :pray: 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, and it will be possibile to make the definitive change 6 months after the deprecation with a new major release. -The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start` +The next eligible voting round will take place on **{{ next_vote_date }}** -cc @{{ chair_team }} @{{{ steering_committee_team }}} +cc @{{{ steering_committee_team }}} diff --git a/src/templates/minor-change.md b/src/templates/minor-change.md index dff8c33..008da21 100644 --- a/src/templates/minor-change.md +++ b/src/templates/minor-change.md @@ -5,6 +5,6 @@ this means that old versions of `publiccode.yml` will still be valid with this c Example of minor changes are additions of new keys or making keys optional. -The Chair will eventually pick up this proposal and start the voting procedure using `@{{ bot_username }} vote-start` +The next eligible voting round will take place on **{{ next_vote_date }}** -cc @{{ chair_team }} @{{{ steering_committee_team }}} +cc @{{{ steering_committee_team }}} diff --git a/src/templates/national-section.md b/src/templates/national-section.md index 1451ef1..dd99350 100644 --- a/src/templates/national-section.md +++ b/src/templates/national-section.md @@ -4,4 +4,4 @@ This is now marked as a national section change to the Standard and it will requ [National section rules](https://github.com/publiccodeyml/publiccode.yml/blob/main/governance/procedure-proposing-changes-and-voting.md#country-specific-sections) -cc @{{ chair_team }} @{{{ steering_committee_team }}} +cc @{{{ steering_committee_team }}} diff --git a/src/templates/vote-start.md b/src/templates/vote-start.md index 606d030..7d87edb 100644 --- a/src/templates/vote-start.md +++ b/src/templates/vote-start.md @@ -4,7 +4,6 @@ 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! The polls will stay open for {{ vote_period_days }} days, until **{{ vote_end_date }}**. -At the end of that period the Chair (@{{ chair_team }}) will mark the voting period as over using `@{{ bot_username }} vote-end` Leave a :+1: (thumbs up) **on this comment** to accept the proposal or a :-1: (thumbs down) to reject it.