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

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

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from

Conversation

santisecco
Copy link
Member

@santisecco santisecco 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
Copy link

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
Member

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

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

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

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 Lang: GHA GitHub Actions role: back end/devOps Tasks for back-end developers size: 5pt Can be done in 19-30 hours
Projects
Status: PR Needs review
Development

Successfully merging this pull request may close these issues.

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