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

Refactor GHAs so templates use label-directory.json #7688

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: 4 additions & 1 deletion .github/ISSUE_TEMPLATE/blank-issue-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
name: Blank Issue Template
about: 'Standard HackforLA issue template '
title: ''
labels: 'Complexity: Missing, Feature Missing, role missing, size: missing'
labels: 'Template Label Placeholder'
assignees: ''

---
<!-- labels: 'complexityMissing, featureMissing, roleMissing, sizeMissing' -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- NOTE: do not edit the line above. These labels are used by the automation. -->

### Overview
REPLACE THIS TEXT - Clearly state the purpose of this issue in 2 sentences or less. We write ours a modified user story in this format: _We need to do X for Y reason._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Module imports
const retrieveLabelDirectory = require('../../utils/retrieve-label-directory');
const statusFieldIds = require('../../utils/_data/status-field-ids');
const queryIssueInfo = require('../../utils/query-issue-info');
const mutateIssueStatus = require('../../utils/mutate-issue-status');
Expand All @@ -8,9 +9,6 @@ const REQUIRED_LABELS = ['Complexity', 'role', 'Feature', 'size'];
const LABEL_MISSING = ['Complexity: Missing', 'role missing', 'Feature Missing', 'size: missing'];
const COMPLEXITY_EXCEPTIONS = ['good first issue'];

// SPECIAL_CASE is for issue created by reference with issue title "Hack for LA website bot" (from "Review Inactive Team Members")
const SPECIAL_CASE = ['ready for dev lead','Feature: Administrative','size: 0.25pt','Complexity: Small','role: dev leads'];

// Global variables
var github;
var context;
Expand All @@ -26,14 +24,22 @@ async function main({ g, c }) {
context = c;
const issueNum = context.payload.issue.number;
const issueTitle = context.payload.issue.title;
const templateTrigger = context.payload.issue.labels[0].name;
let labels = [];

const labels = obtainLabels();
// If the issue is a template, extract the labelKeys then convert to labels
if (templateTrigger === 'Template Label Placeholder') {
labels = extractTemplateLabels();
} else {
labels = obtainLabels();
}

const filteredLabels = filterLabels(labels);
let labelsToAdd = checkLabels(filteredLabels);

// Labels for SPECIAL_CASE noted above, change issue status to "Questions / In Review"
// SPECIAL_CASE: If issue has title "Hack for LA website bot" (from "Review
// Inactive Team Members") then change issue status to "Questions / In Review"
if (issueTitle.includes('Hack for LA website bot')) {
labelsToAdd = SPECIAL_CASE;
// Find GraphQL issue id and change status id, then change status
const { id: itemId } = await queryIssueInfo(github, context, issueNum);
const newStatusValue = statusFieldIds("Questions_In_Review");
Expand All @@ -54,6 +60,22 @@ async function main({ g, c }) {
};
}

/**
* Only for template: extract all labels from the template body
* @return {Array} - returns an array of all the labels
*/
function extractTemplateLabels() {
const templateBody = context.payload.issue.body;
// Extract label list from a comment in the template body
const match = templateBody.match(/<!--\s*labels:\s*'([^']*)'(?:,\s*'([^']*)')*\s*-->/);
if (!match) return [];

// Extract each labelKey, convert to labelName, and return as an array
let labelKeys = match[1].split(',').map(label => label.trim());
let labelNames = labelKeys.map(labelKey => retrieveLabelDirectory(labelKey));
return labelNames
}

/**
* Get all labels from the issue
* @return {Array} - returns an array of all the labels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
name: Review Inactive Team Members
about: Issue template used only by `schedule-monthly.yml`
title: "Review Inactive Team Members"
labels: ['Feature: Administrative', 'Feature: Onboarding/Contributing.md', 'role: dev leads', 'Complexity: Small', 'size: 0.5pt']
labels: 'Template Label Placeholder'
milestone: 8
assignees: ''
---

<!--
Note: This template is only for use by the `schedule-monthly.yml` workflow.
-->
<!-- labels: 'featureAdministrative, featureOnboardingContributingMd, roleDevLeads, complexity2, size05pt' -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- NOTE: do not edit the line above. These labels are used by the automation. -->
<!-- NOTE: This template is only for use by the `schedule-monthly.yml` workflow. -->

# Review of Inactive Website Team Members
## Inactive Members
Expand Down