Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create comment-issue-due-date helper #443

Closed
wants to merge 3 commits into from

Conversation

k-borley
Copy link
Contributor

@k-borley k-borley commented Sep 26, 2023

📝 Description

  • When an issue is labeled with a priority (critical, high, med, low), this automatically adds a comment with the due date (ex: This issue is due on Mon Dec 25 2023). The due date is based on SLA guidelines (see table).
Priority Days For Resolution
1 2
2 14
3 45
4 90

@k-borley k-borley requested a review from a team as a code owner September 26, 2023 20:00
src/helpers/comment-issue-due-date.ts Outdated Show resolved Hide resolved
src/helpers/comment-issue-due-date.ts Outdated Show resolved Hide resolved
test/helpers/comment-issue-due-date.test.ts Outdated Show resolved Hide resolved

jobs:
test:
if: contains(fromJSON('["Priority: Critical", "Priority: High", "Priority: Medium", "Priority: Low"]'), github.event.label.name)
Copy link
Contributor

@danadajian danadajian Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be more intuitive to run this helper for each label and have it do nothing in the case the label doesn't match

import { PRIORITY_1, PRIORITY_2, PRIORITY_3, PRIORITY_4 } from '../constants';

export class CreateIssueDuedateComment extends HelperInputs {
label!: typeof PRIORITY_1 | typeof PRIORITY_2 | typeof PRIORITY_3 | typeof PRIORITY_4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
label!: typeof PRIORITY_1 | typeof PRIORITY_2 | typeof PRIORITY_3 | typeof PRIORITY_4;
label!: keyof typeof daysOpenBasedOnPriority

Comment on lines +23 to +32
export type PriorityDueDateMapping = {
[key: string]: number;
};

const daysOpenBasedOnPriority: PriorityDueDateMapping = {
[PRIORITY_1]: 2,
[PRIORITY_2]: 14,
[PRIORITY_3]: 45,
[PRIORITY_4]: 90
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type PriorityDueDateMapping = {
[key: string]: number;
};
const daysOpenBasedOnPriority: PriorityDueDateMapping = {
[PRIORITY_1]: 2,
[PRIORITY_2]: 14,
[PRIORITY_3]: 45,
[PRIORITY_4]: 90
};
const daysOpenBasedOnPriority = {
[PRIORITY_1]: 2,
[PRIORITY_2]: 14,
[PRIORITY_3]: 45,
[PRIORITY_4]: 90
} as const;

jest.spyOn(Date, 'now').mockImplementation(() => new Date('2023-09-26T10:00:00Z').getTime());

describe('commentIssueDueDate', () => {
it('should add due dates correctly based on priority label', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a test for if an invalid label is added

k-borley added a commit to k-borley/github-helpers that referenced this pull request Oct 2, 2023
@k-borley k-borley closed this Oct 2, 2023
@k-borley k-borley deleted the comment-issue-due-date branch October 2, 2023 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants