Skip to content

Enhance GHA check-label-preliminary-update to use label-directory.json #7533

@t-will-gillis

Description

@t-will-gillis

Overview

We want to enhance the GHA workflows to reference each label by a general ID (i.e. a 'labelKey') rather than the label's name so that other HfLA project groups can use these workflows without needing to match the label names used by the Website team.

Details

Currently, the GHA workflows files that add, remove, and change labels on issues identify each label by its name (i.e. the 'labelName') directly. Instead of hard-coding each label name, we want these files to identify each label by its 'labelKey' and use the retrieve-label-directory.js module to look up the corresponding 'labelName' that is needed in order for the REST API to apply labels to issues.

Action Items

This issue involves specifically the check-label-preliminary-update.js function of the "Issue Trigger" GitHub Action, and you must set up your environment for testing GHAs in order to work on this issue. See notes below in "Resources/ Instructions", and ask questions if you need additional help- GHAs can be tricky, and if you get stuck somewhere, someone who has worked on these before might have information that will save you a lot of time.

  • Before making any of the edits following, first create a test branch in your repo and demonstrate the current, correct behavior of the "Issue Trigger" GHA. Afterwards, create an additional branch for the edits following- this is the branch that will be attached to the PR.

Refer to check-label-preliminary-update.

  • A preliminary search found that this file uses the following labels. As you work through this issue, confirm that this list is correct, and note any additions or subtractions as needed:
    • role: front end
    • role: back end/devOps
    • role: design
    • role: user research
  • Replace:
    // Global variables
    var github 
    var context
    
    with:
    // Import modules
    const retrieveLabelDirectory = require('../../utils/retrieve-label-directory');
    
    // Global variables
    var github 
    var context
    
  • Then add the following:
    // Label constants use labelKeys to retrieve current labelNames from directory
    const RELEVANT_ROLES = [
      roleFrontEnd,
      roleBackEndDevOps,
      roleDesign,
      roleUserResearch
    ] = [
      “roleFrontEnd”,
      “roleBackEndDevOps”,
      “roleDesign”,
      “roleUserResearch”,
    ].map(retrieveLabelDirectory);
    
  • The postComment() function can be simplified by replacing the if and else if statements with the following or similar:
    function postComment(existingLabels){
      // Compare whether a RELEVANT_ROLE is included in the existingLabels
      const roleFound = RELEVANT_ROLES.some(label => existingLabels.includes(label));
      console.log(roleFound ? '\nFound relevant role: Continue' : '\nMissing relevant role: Halt');
      return roleFound
    }
    
  • Prior to submitting the PR, search for all code comment that reference a specific label name
    • List these instances out in a comment on this issue, with your suggestion for replacement text that generalizes it.
    • When finished, add the label ready for product and change status to "Questions / In Review"
    • Product will review and provide feedback on replacement text for revision or sign-off on changes.
  • Perform a test in your own repo that demonstrates that there is no change to the GHA's functionality after making the edits.

Resources/Instructions

Metadata

Metadata

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions