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

Linter test two #3485

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/add-update-label-weekly.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Add Update Label to Issues Weekly

on:
schedule:
- cron: '0 7 * * 5'
workflow_dispatch
# schedule:
# - cron: '0 7 * * 5'

jobs:
Add-Update-Label-to-Issues-Weekly:
Expand Down
37 changes: 17 additions & 20 deletions github-actions/add-update-label-weekly/add-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ var context;
const statusUpdatedLabel = 'Status: Updated';
const toUpdateLabel = 'To Update !';
const inactiveLabel = '2 weeks inactive';
const updatedByDays = 3; // number of days ago to check for to update label
const inactiveUpdatedByDays = 14; // number of days ago to check for inactive label
const commentByDays = 7; // number of days ago to check for comment by assignee
const updatedByDays = 1; // number of days ago to check for to update label
const inactiveUpdatedByDays = 1; // number of days ago to check for inactive label
const commentByDays = 1; // number of days ago to check for comment by assignee
const threeDayCutoffTime = new Date()
threeDayCutoffTime.setDate(threeDayCutoffTime.getDate() - updatedByDays)
const sevenDayCutoffTime = new Date()
Expand Down Expand Up @@ -138,36 +138,33 @@ async function getTimeline(issueNum) {
async function isTimelineOutdated(timeline, issueNum, assignees) {
for await (let [index, moment] of timeline.entries()) {
if (isMomentRecent(moment.created_at, threeDayCutoffTime)) { // all the events of an issue within last three days will return true
if (moment.event == 'cross-referenced' && isLinkedIssue(moment, issueNum)) { // checks if cross referenced within last three days
if (moment.event == 'cross-referenced' && isLinkedIssue(moment, issueNum)) { // checks if cross referenced within last three days
return {result: false, labels: statusUpdatedLabel}
}
else if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented within last three days
else if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented within last three days
return {result: false, labels: statusUpdatedLabel}
}
else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < fourteenDayCutoffTime.valueOf())) { // returns true if issue was created before 14 days after comparing the two dates in millisecond format
return {result: true, labels: inactiveLabel}
return {result: false, labels: inactiveLabel}
}
else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < threeDayCutoffTime.valueOf())) { // returns true if issue was created before 3 days
return {result: true, labels: toUpdateLabel}
}
else if (index === timeline.length-1) { // returns true if above two else ifs are false meaning issue was created within last 3 days
return {result: true, labels: statusUpdatedLabel}
return {result: false, labels: toUpdateLabel}
}
}
else if (isMomentRecent(moment.created_at, sevenDayCutoffTime)) { // all the events of an issue between three and seven days will return true
if (moment.event == 'cross-referenced' && isLinkedIssue(moment, issueNum)) { // checks if cross referenced between 3 and 7 days
console.log('between 3 and 7 cross referenced');
return {result: false, labels: statusUpdatedLabel}
return {result: true, labels: statusUpdatedLabel}
}
else if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented between 3 and 7 days
console.log('between 3 and 7 commented');
return {result: false, labels: statusUpdatedLabel}
return {result: true, labels: statusUpdatedLabel}
}
else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < fourteenDayCutoffTime.valueOf())) { // returns true if issue was created before 14 days after comparing the two dates in millisecond format
return {result: true, labels: inactiveLabel}
return {result: false, labels: inactiveLabel}
}
else if (index === timeline.length-1) { // returns true if the latest event created is between 3 and 7 days
return {result: true, labels: toUpdateLabel}
return {result: false, labels: toUpdateLabel}
}
}
else if (isMomentRecent(moment.created_at, fourteenDayCutoffTime)) { // all the events of an issue between seven and fourteen days will return true
Expand Down Expand Up @@ -211,7 +208,7 @@ async function removeLabels(issueNum, ...labels) {
});
console.log(`Removed "${label}" from issue #${issueNum}`);
} catch (err) {
console.error(`No "${label}" label to remove for issue #${issueNum}`);
console.error(`Function failed to remove label ${label} for issue #${issueNum}. Please refer to the error below: /n ${err}`);
}
}
}
Expand All @@ -221,7 +218,7 @@ async function removeLabels(issueNum, ...labels) {
* @param {Array} labels an array containing the labels to add (captures the rest of the parameters)
*/
async function addLabels(issueNum, ...labels) {
try {
try { let
// https://octokit.github.io/rest.js/v18#issues-add-labels
await github.issues.addLabels({
owner: context.repo.owner,
Expand All @@ -231,8 +228,8 @@ async function addLabels(issueNum, ...labels) {
});
console.log(`Added these labels to issue #${issueNum}: ${labels}`);
// If an error is found, the rest of the script does not stop.
} catch {
console.error(`Could not add these labels for issue #${issueNum}: ${labels}`);
} catch (err){
console.error(`Function failed to add label ${labels} for issue #${issueNum}. Please refer to the error below: \n ${err}`);
}
}
async function postComment(issueNum, assignees) {
Expand All @@ -246,7 +243,7 @@ async function postComment(issueNum, assignees) {
body: instructions,
});
} catch (err) {
console.error(`Could not post a comment for issue #${issueNum}`);
console.error(`Function failed to post comment for issue#${issueNum}. Please refer to the error below: \n ${err}`);
}
}
/***********************
Expand Down Expand Up @@ -280,7 +277,7 @@ async function getAssignees(issueNum) {
assigneesLogins = filterForAssigneesLogins(assigneesData);
return assigneesLogins
} catch (err) {
console.error(`Failed request to get assignee from issue: #${issueNum}`)
console.error(`Function failed to return assignees for issue #${issueNum}. Please refer to the error below: \n${err}`)
return null
}
}
Expand Down