Skip to content

Commit

Permalink
feat: Skipping docs team from milestones, linking, and estimates
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrunkat committed Dec 1, 2023
1 parent a6a2f61 commit 485fd13
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
11 changes: 8 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.TESTED_LABEL_NAME = exports.TEAMS_NOT_USING_ZENHUB = exports.LINKING_CHECK_DELAY_MILLIS = exports.LINKING_CHECK_RETRIES = exports.TEAM_NAME_TO_LABEL = exports.TEAM_LABEL_PREFIX = exports.ZENHUB_WORKSPACE_NAME = exports.ZENHUB_WORKSPACE_ID = exports.PARENT_TEAM_SLUG = exports.ORGANIZATION = void 0;
exports.TESTED_LABEL_NAME = exports.SKIP_MILESTONES_AND_ESTIMATES_FOR_TEAMS = exports.TEAMS_NOT_USING_ZENHUB = exports.LINKING_CHECK_DELAY_MILLIS = exports.LINKING_CHECK_RETRIES = exports.TEAM_NAME_TO_LABEL = exports.TEAM_LABEL_PREFIX = exports.ZENHUB_WORKSPACE_NAME = exports.ZENHUB_WORKSPACE_ID = exports.PARENT_TEAM_SLUG = exports.ORGANIZATION = void 0;
exports.ORGANIZATION = 'apify';
exports.PARENT_TEAM_SLUG = 'product-engineering';
exports.ZENHUB_WORKSPACE_ID = '5f6454160d9f82000fa6733f';
Expand All @@ -19,6 +19,7 @@ exports.TEAM_NAME_TO_LABEL = {
exports.LINKING_CHECK_RETRIES = 8;
exports.LINKING_CHECK_DELAY_MILLIS = 15 * 1000;
exports.TEAMS_NOT_USING_ZENHUB = ['put-some-team-here'];
exports.SKIP_MILESTONES_AND_ESTIMATES_FOR_TEAMS = ['Docs'];
exports.TESTED_LABEL_NAME = 'tested';


Expand Down Expand Up @@ -517,12 +518,12 @@ async function run() {
core.info('Creator already assigned.');
}
// 2. Assigns current milestone if not already assigned.
if (!pullRequestContext.milestone) {
if (!pullRequestContext.milestone && !consts_1.SKIP_MILESTONES_AND_ESTIMATES_FOR_TEAMS.includes(teamName)) {
const milestoneTitle = await (0, helpers_1.fillCurrentMilestone)(github.context, repoOctokit, pullRequest, teamName);
core.info(`Milestone successfully filled with ${milestoneTitle}.`);
}
else {
core.info('Milestone already assigned.');
core.info('Milestone already assigned or team is skipped.');
}
// 3. Adds team label if not already there.
const teamLabel = pullRequestContext.labels.find((label) => label.name.startsWith(consts_1.TEAM_LABEL_PREFIX));
Expand All @@ -548,6 +549,10 @@ async function run() {
else {
core.info('PR is not tested.');
}
if (consts_1.SKIP_MILESTONES_AND_ESTIMATES_FOR_TEAMS.includes(teamName)) {
core.info(`Team ${teamName} is listed in SKIP_MILESTONES_AND_ESTIMATES_FOR_TEAMS. Skipping the linking and estimate check.`);
return;
}
// On the other hand, this is a check that author of the PR correctly filled in the details.
// I.e., that the PR is linked to the ZenHub issue and that the estimate is set either on issue or on the PR.
await (0, helpers_1.retry)((isLastAttempt) => (0, helpers_1.ensureCorrectLinkingAndEstimates)(pullRequest, repoOctokit, !isLastAttempt), consts_1.LINKING_CHECK_RETRIES, consts_1.LINKING_CHECK_DELAY_MILLIS);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ export const LINKING_CHECK_DELAY_MILLIS = 15 * 1000;

export const TEAMS_NOT_USING_ZENHUB = ['put-some-team-here'];

export const SKIP_MILESTONES_AND_ESTIMATES_FOR_TEAMS = ['Docs'];

export const TESTED_LABEL_NAME = 'tested';
10 changes: 8 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
TEAMS_NOT_USING_ZENHUB,
ORGANIZATION,
TESTED_LABEL_NAME,
SKIP_MILESTONES_AND_ESTIMATES_FOR_TEAMS,
} from './consts';

type Assignee = components['schemas']['simple-user'];
Expand Down Expand Up @@ -97,11 +98,11 @@ async function run(): Promise<void> {
}

// 2. Assigns current milestone if not already assigned.
if (!pullRequestContext.milestone) {
if (!pullRequestContext.milestone && !SKIP_MILESTONES_AND_ESTIMATES_FOR_TEAMS.includes(teamName)) {
const milestoneTitle = await fillCurrentMilestone(github.context, repoOctokit, pullRequest, teamName);
core.info(`Milestone successfully filled with ${milestoneTitle}.`);
} else {
core.info('Milestone already assigned.');
core.info('Milestone already assigned or team is skipped.');
}

// 3. Adds team label if not already there.
Expand All @@ -128,6 +129,11 @@ async function run(): Promise<void> {
core.info('PR is not tested.');
}

if (SKIP_MILESTONES_AND_ESTIMATES_FOR_TEAMS.includes(teamName)) {
core.info(`Team ${teamName} is listed in SKIP_MILESTONES_AND_ESTIMATES_FOR_TEAMS. Skipping the linking and estimate check.`);
return;
}

// On the other hand, this is a check that author of the PR correctly filled in the details.
// I.e., that the PR is linked to the ZenHub issue and that the estimate is set either on issue or on the PR.
await retry(
Expand Down

0 comments on commit 485fd13

Please sign in to comment.