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

Create JSON file and related functionality for replacing hard-coded labels #6442

Merged

Conversation

t-will-gillis
Copy link
Member

@t-will-gillis t-will-gillis commented Mar 9, 2024

Fixes #5205

What changes did you make?

  • Created the JSON file with key/value pairs for all repo labels- label-directory.json and located it in a new subfolder
  • Populated the JSON file with data extracted from the HfLA repo for all label names + ids (the directory Values) and generated Key camelCased names
  • Wrote retrieve-label-directory.js that returns the actual label display name value when a label key name is provided- note that this is not currently used. It is a necessary file for the next phase which updates the GHA files
  • Wrote GHA update-label-directory.yml that is triggered whenever one of the HfLA labels is edited or is added.
  • Wrote a companion update-label-directory.js that determines whether the label is a name-change (such as by adding an emoji) or is a new label, then adds this change to the 'label directory' JSON,
  • In order to commit the changes to the repo, the GHA finishes with the stefanzweifel/git-auto-commit-action@v5.0.1
  • Created Create new Wiki for GHA update-label-directory.yml #6968

Additionally, there are Google Apps Scripts/ Worksheets associated with this:

Why did you make the changes (we will use this info to test)?

  • This series of issues was triggered by the study of adding emoji's to issue labels.
  • We determined that we want the freedom to make changes to the labels without the need to track down all instances of each label being used. The intent of the 'label directory' is to be able to refer to a key label such as '2WeeksInactive' and return the actual label name 2 weeks inactive!!! or 💤 2 weeks inactive or however we want to change the label, however many times.
  • Also, ultimately other projects with HfLA could be using Website's GHAs, but those project teams might have named their labels differently. The files here are intended to make it easier for other teams to swap out label names in one location (the JSON file).

Screenshots of Proposed Changes Of The Website (if any, please do not screen shot code changes)

  • Create label: Log file from personal repo showing label creation

    Create label

    Screenshot 2024-03-10 215953

    Screenshot 2024-03-10 220157

    Screenshot 2024-03-10 220251

  • Edit label: Log file from personal repo showing label editing

    Edit label

    Screenshot 2024-03-10 220737

    Screenshot 2024-03-10 220649

    Screenshot 2024-03-10 220810

  • Delete label: Log file from personal repo showing label deletion

    Delete label

    Screenshot 2024-03-10 221255

    Notes to PR Reviewers

    • You will need to have a functioning test environment on your local repo. If you have not done this yet, see Hack for LA's GitHub Actions to set up, especially Tips 6-8. Tip 8 describes how to copy all of HfLA's labels to your own repo. GHAs are quirky at first so feel free to ask questions.

    • In addition to the 'files changed' in the PR, there are additional changes that you should make to help with testing:

      • In the update-label-directory.yml file:

        • Line 14, redirect to your personal repo.
        • Line 18 & 24, the "github-token" needs to be associated with your repo.
      • Note that none of the labels in the label-directory.json file will match your repo because the IDs will be a different number. I.e. if you edit your good first issue, the automation will see this as a new label- this is OK.

    • To test this action, you can first create a new label. Go to "Issues" in your repo***, select "New Issue", and choose "Get Started" for any of the templates. Then on the right hand side select the gear icon for "Labels", then select "Edit labels" at the bottom, and finally "New label" to the upper right. Name the issue anything you want, but it might be easier to create a label beginning with an "a", eg. A new label or whatever. "Description" and "Color" can be anything you want. Select "Create label" and confirm your label is shown on the "Labels" page.

    • (*** If you don't see "Issues" as a menu option, go to "Settings" and scroll down about halfway. Under "Features", make sure to check the box for "Issues".)

    • When you see that the label is created:

      • Confirm that GitHub Actions was triggered: select "Actions", then check that a workflow named "Update Label Directory" has run. Feel free to explore the log...
      • Confirm that your new label was added to /_data/label-directory.json. It should be at the end of the JSON, and it will begin with "NEW" + your title.
    • Repeat the above steps to return to "Edit labels", select your new label, then make some change to the name. Add an emoji if you want. Confirm in that "Actions" has run and that the JSON file was updated.

    • Finally, repeat the above steps to delete the label, and confirm in "Actions". The JSON file will still list the label, but the labelId will be '9999999999'.

    • The tie-in can be seen here for Google Apps Script /Worksheet

Please feel free to make suggestions...
Wish List and Outstanding Items:

  • abstract the url?
  • ? Break Google Apps Script functions into modules
  • ? Need "Anomaly Report" functional
  • ? Need a way to automatically clear deleted Label Objects from JSON after review
  • ? Have method/ procedure for updating keyNames hopefully without need to edit files separate, or to do a PR

Completed:

  • Done ---> Replace link to Apps Script and fix repo
  • Done ---> Add + " (deleted)" to labelName when deleted
  • Done ---> Have timeline on the "Worksheet: GitHub Label Updates Log" automatically clear after certain number of days
  • Done ---> Very important: Since the URL variable in the yml workflow will change every time we need to edit the Google Apps Script: We need the URL to be referenced rather than hard-coded. Should this use a doGet() call?
  • Done ---> Remove "show context"
  • Withdrawn ---> Should deleted labels be pulled into a separate object?

Future (maybe):

  • If the label edit does not include the name, the workflow can skip "post to Apps Script"

Copy link

github-actions bot commented Mar 9, 2024

Want to review this pull request? Take a look at this documentation for a step by step guide!

From your project repository, check out a new branch and test the changes.

git checkout -b t-will-gillis-create-json-label-directory-5205 gh-pages
git pull https://github.com/t-will-gillis/website.git create-json-label-directory-5205

Note that CONTRIBUTING.md cannot previewed locally; rather it should be previewed at this URL:

https://github.com/t-will-gillis/website/blob/create-json-label-directory-5205/CONTRIBUTING.md  

@github-actions github-actions bot added role: back end/devOps Tasks for back-end developers Complexity: Large time sensitive Needs to be worked on by a particular timeframe Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms size: 5pt Can be done in 19-30 hours Added to dev/pm agenda labels Mar 9, 2024
@t-will-gillis t-will-gillis added the Draft Issue is still in the process of being created label Mar 9, 2024
@github-actions github-actions bot removed the Draft Issue is still in the process of being created label Mar 10, 2024
@t-will-gillis t-will-gillis marked this pull request as draft March 12, 2024 02:31
@drakenguyen4000 drakenguyen4000 requested review from MarcosG119 and removed request for MarcosG119 March 13, 2024 02:12
@gaylem
Copy link
Member

gaylem commented Apr 15, 2024

@marioantonini I connected with Will about this issue and it looks like it's still in draft, so I'm going to remove us as reviewers for now.

Also leaving this as a note to anyone else who sees this PR and considers picking it up.

@t-will-gillis t-will-gillis marked this pull request as ready for review June 6, 2024 22:40
@t-will-gillis t-will-gillis changed the title Create JSON file and related functionality for replacing hard-coded labels 5205 Create JSON file and related functionality for replacing hard-coded labels Jun 12, 2024
@mSharifHub

This comment was marked as outdated.

@t-will-gillis

This comment was marked as outdated.

@mSharifHub

This comment was marked as outdated.

HackforLABot and others added 2 commits August 19, 2024 18:06
@github-actions github-actions bot added the GHA New Project Board compatible This GitHub Action issue does not reference columns and will work with the new board label Aug 22, 2024
Tweaks to no update condition
to address CodeQL warning
@santisecco
Copy link
Member

Review ETA: 3 PM Thursday
Availability: Monday-Thursday

@santisecco
Copy link
Member

Updated review schedule!
Review ETA: 3 PM Friday
Availability: Wednesday-Saturday

@t-will-gillis
Copy link
Member Author

Hello @santisecco Thank you for your review so far. Please let me know if there is anything that you have questions about, questions, comments, or concerns. Thanks!

santisecco
santisecco previously approved these changes Sep 11, 2024
Copy link
Member

@santisecco santisecco left a comment

Choose a reason for hiding this comment

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

Hi @t-will-gillis everything looks great.
Tested the automation in my repo and labels are correctly updated, deleted and added.
I liked the idea of setting the labelID to '9999999999' when the label is deleted. I think it's safer and more efficient than deleting it from the JSON file.

Understood that retrieve-label-directory.js is not yet used but will be in the future, also the presence of the wishlist and that the Google sheets doc is updated using Google Apps Script.
Branches are correct. And your explanation of Why and What changes you made is clear and concise.

Thanks for working on this and answering my questions on the changes throughout the review process.

@t-will-gillis t-will-gillis merged commit 417ad5f into hackforla:gh-pages Sep 14, 2024
3 checks passed
@t-will-gillis
Copy link
Member Author

Final edits are for linking to the live 'Source of Truth' document as well as updating the JSON labels so that the file is current as of today. Bypassing final review since the previous review was full approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complexity: Large Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms GHA New Project Board compatible This GitHub Action issue does not reference columns and will work with the new board role: back end/devOps Tasks for back-end developers size: 5pt Can be done in 19-30 hours time sensitive Needs to be worked on by a particular timeframe
Projects
Development

Successfully merging this pull request may close these issues.

Create JSON file and related functionality to support replacement of hard-coded issue labels
5 participants