Skip to content

Enhanced code to reference the mentioned labels by a general ID#7987

Merged
daras-cu merged 1 commit intohackforla:gh-pagesfrom
santiseccovidal:refactor-gha-7533
Mar 24, 2025
Merged

Enhanced code to reference the mentioned labels by a general ID#7987
daras-cu merged 1 commit intohackforla:gh-pagesfrom
santiseccovidal:refactor-gha-7533

Conversation

@santiseccovidal
Copy link
Copy Markdown
Member

@santiseccovidal santiseccovidal commented Mar 10, 2025

Fixes #7533

What changes did you make?

  • Imported retrieveLabelDirectory() function from retrieve-label-directory.js that fetches the label value, also called labelName (thinking in terms of key-value pair).
  • Added constant of the labels appearing in the file, mapped them to the values in label-directory.json using retrieveLabelDirectory()
  • Refactored the function postComment() to use the constant variable created above

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

  • At this time, the GitHub Actions workflow files that manage labels on issues (adding, removing, or updating them) reference each label directly by its label name (the 'labelName')
  • 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' in label-directory.json instead of hard-coding the labelNames.
  • The specific file modified mentions role: front end, role: back end/devOps, role: design and role: user research so the constant variable created addresses this labels in particular.

CodeQL Alerts

After the PR has been submitted and the resulting GitHub actions/checks have been completed, developers should check the PR for CodeQL alert annotations.

Check the PR's comments. If present on your PR, the CodeQL alert looks similar as shown

Screenshot 2024-10-28 154514

Please let us know that you have checked for CodeQL alerts. Please do not dismiss alerts.

  • I have checked this PR for CodeQL alerts and none were found.
  • I found CodeQL alert(s), and (select one):
    • I have resolved the CodeQL alert(s) as noted
    • I believe the CodeQL alert(s) is a false positive (Merge Team will evaluate)
    • I have followed the Instructions below, but I am still stuck (Merge Team will evaluate)
Instructions for resolving CodeQL alerts

If CodeQL alert/annotations appear, refer to How to Resolve CodeQL alerts.

In general, CodeQL alerts should be resolved prior to PR reviews and merging

Screenshots of Proposed Changes To The Website (if any, please do not include screenshots of code changes)

  • No visual changes to the website

To reviewers

  • This issue works using Github Actions. To properly test the code changes you need to setup your own environment which can take a while if you haven't done it before. There are some tweaks around it, just post your doubts here or message me on Slack.
  • There's a guide on how GHA works on the Wiki, how to setup your own version of the project board, etc. here
  • I created another branch in my repo "refactor-gha-7533-debug" that adds a bunch of comments and console.log() to help you understand why the changes were performed that way and to see that the code works as intended.
  • Checkout the Project Board on my repo https://github.com/users/santisecco/projects/6, the issues created there and the results from the actions. The following link shows that labels were fetched correctly by the changes and that all the parts of the code run https://github.com/santisecco/website/actions/runs/13726127006
  • See the last issue created in my project board (using the debug branch) which shows that even when changing the labelName in label-directory.json, this is fetched correctly. You must watch the raw logs of GHA for this, here goes a screenshot as retrieveLabelDirectory() logs this.
Here are the screenshots

To see the raw logs open the Actions tab, and look for this Screenshot 2025-03-11 at 12 16 49 PM

Here's the raw log of the last issue created that shows that the value from the directory is fetched correctly more clearly (as "front end" is now "front end GHA ACTIONS FETCHED CORRECTLY USING labelKey")

Screenshot 2025-03-11 at 12 05 56 PM

- Imported retrieveLabelDirectory function
- Added constant of the labels appearing in the file mapped to label-directory.json
- Refactored the function postComment to use the constant variable
@github-actions
Copy link
Copy Markdown

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 santisecco-refactor-gha-7533 gh-pages
git pull https://github.com/santisecco/website.git refactor-gha-7533

@github-actions github-actions bot added role: back end/devOps Tasks for back-end developers Complexity: Large Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms size: 5pt Can be done in 19-30 hours labels Mar 10, 2025
@ExperimentsInHonesty ExperimentsInHonesty added the Lang: GHA GitHub Actions label Mar 11, 2025
@t-will-gillis t-will-gillis self-requested a review March 11, 2025 02:00
@t-will-gillis
Copy link
Copy Markdown
Member

Hi @santisecco let me know when this is ready- thanks!

@santiseccovidal santiseccovidal marked this pull request as ready for review March 11, 2025 15:26
@santiseccovidal
Copy link
Copy Markdown
Member Author

Hi @t-will-gillis it's ready, thanks

Copy link
Copy Markdown
Member

@t-will-gillis t-will-gillis left a comment

Choose a reason for hiding this comment

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

Hey @santisecco Thanks for taking on this issue!

  • Great explanations in the "What changes did you make?" and "Why did you make the changes"
  • Fantastic instructions and accompanying screenshots in the "To reviewers" section- these notes are very helpful.

I tested in my repo and everything is working as intended, and the correct labels are being substituted in. The refactored postComment() function in check-label-preliminary-update.js is much more streamlined.

Great job!

@santiseccovidal
Copy link
Copy Markdown
Member Author

@t-will-gillis Hi Will thank you!

@ExperimentsInHonesty ExperimentsInHonesty added Skill: enhance and removed Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms labels Mar 16, 2025
@santiseccovidal santiseccovidal changed the title Refactored code to reference the mentioned labels by a general ID Enhanced code to reference the mentioned labels by a general ID Mar 16, 2025
@daras-cu daras-cu self-requested a review March 17, 2025 22:17
@daras-cu
Copy link
Copy Markdown
Member

ETA: 3/21 EOD
Availability: Tues-Saturday after 6 pm, Sunday/Monday all day

Copy link
Copy Markdown
Member

@daras-cu daras-cu left a comment

Choose a reason for hiding this comment

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

Hi @santisecco, thanks for working on this issue!

  • Your branches are set up correctly
  • The PR is clear and has a thorough explanation of what changes you made and why
  • The provided screenshots and GH Actions logs from your testing were helpful to demonstrate that the labels were successfully retrieved
  • The Issue Trigger action runs successfully when tested in my repo

Suggestions:

  • In the original issue, one of the action items calls for you to check for references to a specific label name in the code comments and leave a comment with suggested changes. I see after your updates there are no such comments in the code, but you should still leave a comment on your issue confirming that you checked and no changes are required.
  • It appears none of the issues you used for testing in your own repo had a role label included in RELEVANT_ROLES, so the postComment function always returned false. If that's the case, I would go back and test if the results of the GH action are as expected when an issue does have one of these labels. That way you will be sure that the label names are being retrieved successfully from the directory, and there is no other issue with the postComment logic.

@github-project-automation github-project-automation bot moved this from PR Needs review to PRs being reviewed in P: HfLA Website: Project Board Mar 23, 2025
@santiseccovidal
Copy link
Copy Markdown
Member Author

Hi @daras-cu thanks for the comment.
Since the issue focuses more around the idea of changing the way labels are coded, that aspect you mentioned of the logic of the function was not tested using GHA, though I think I had separately tested if it returned true or false before changing it.
Great insight, though. Here's with a relevant role label TEST REFACTOR GHA #8. Note that role "front end" won't work as I changed the label name to another thing in the refactor-gha-7533-debug branch. So if you try it yourself, it won't work.

By the way, I just did a simple test file if you want to look at yourself test file

As per your comment on the original issue, about the reference to a specific label, I didn't understand what that meant originally. I asked Will, the creator of the issue, and he mentioned that it was not necessary to do that.

Copy link
Copy Markdown
Member

@daras-cu daras-cu left a comment

Choose a reason for hiding this comment

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

Hi @santisecco, thanks for trying the additional test issue with the role included, I got the same result when testing in my own repo so it looks like everything is working as it should be after your changes. Good idea to use the test file as well.
Noted about the comment action item, I'm glad you got clarification from Will. Overall great job on this issue!

@github-project-automation github-project-automation bot moved this from PRs being reviewed to PRs ✅ waiting for merge team in P: HfLA Website: Project Board Mar 24, 2025
@daras-cu daras-cu merged commit d875ed1 into hackforla:gh-pages Mar 24, 2025
19 checks passed
@santiseccovidal santiseccovidal deleted the refactor-gha-7533 branch August 2, 2025 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complexity: Large Lang: GHA GitHub Actions role: back end/devOps Tasks for back-end developers size: 5pt Can be done in 19-30 hours Skill: enhance

Projects

Development

Successfully merging this pull request may close these issues.

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

4 participants