Skip to content

Commit

Permalink
feat: warn if branch has had unreleased commits for N days (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanders11 authored May 7, 2024
1 parent eba137c commit 58a48c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions action-audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const {
SLACK_BOT_TOKEN,
ACTION_TYPE,
AUDIT_POST_CHANNEL,
MILLISECONDS_PER_DAY,
UNRELEASED_DAYS_WARN_THRESHOLD,
} = require('./constants');

const Actions = {
Expand Down Expand Up @@ -49,6 +51,14 @@ async function run() {
let text = '';
if (ACTION_TYPE === Actions.UNRELEASED) {
text += buildUnreleasedCommitsMessage(branch, commits, initiatedBy);
const earliestCommit = commits[0];
const unreleasedDays = Math.floor(
(Date.now() - new Date(earliestCommit.committer.date).getTime()) /
MILLISECONDS_PER_DAY,
);
if (unreleasedDays > UNRELEASED_DAYS_WARN_THRESHOLD) {
text += `\n ⚠️ *There have been unreleased commits on \`${branch}\` for ${unreleasedDays} days!*`;
}
} else if (ACTION_TYPE === Actions.NEEDS_MANUAL) {
text += buildNeedsManualPRsMessage(
branch,
Expand Down
6 changes: 6 additions & 0 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const RELEASE_BRANCH_PATTERN = /^(\d)+-(?:(?:[0-9]+-x$)|(?:x+-y$))$/;

const BUMP_COMMIT_PATTERN = /Bump v(\d)+.(\d)+.(\d)+(-(beta|nightly)(.\d+))?/;

const MILLISECONDS_PER_DAY = 1000 * 60 * 60 * 24;

const UNRELEASED_DAYS_WARN_THRESHOLD = 8;

module.exports = {
ACTION_TYPE,
AUDIT_POST_CHANNEL,
Expand All @@ -27,4 +31,6 @@ module.exports = {
REPO_NAME,
SLACK_BOT_TOKEN,
UNRELEASED_GITHUB_APP_CREDS,
MILLISECONDS_PER_DAY,
UNRELEASED_DAYS_WARN_THRESHOLD,
};

0 comments on commit 58a48c9

Please sign in to comment.