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

Determine labels for checks using labels.yml, factor out common workflow utils #2046

Merged
merged 4 commits into from May 8, 2023

Conversation

AetherUnbound
Copy link
Contributor

@AetherUnbound AetherUnbound commented May 6, 2023

Fixes

Fixes #1195 by @AetherUnbound

Description

This PR is primarily intended to modify the pr_label_check.yml GitHub Action workflow so that it reads from the labels.yml definition rather then requiring the label groups be explicitly redefined. In order to do this, I factored out some shared functions which read in the labels and convert them to Python objects. I also factored out code in several of our workflow python scripts which would print data to both stdout and the GITHUB_OUTPUTS destinations. I had to add the PYTHONPATH environment variable to the places where we call python scripts in order to have those shared modules load properly.

The effect of this is now any labels we add to the required categories in labels.yml will automatically be added to the pr_label_check workflow!

Testing Instructions

The fact that CI passes here is sign that things are working! See the output from the adjusted actions to see that they are still outputting what they were before.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@openverse-bot openverse-bot added this to In progress in Openverse PRs May 6, 2023
@openverse-bot openverse-bot added 🟩 priority: low Low priority and doesn't need to be rushed 🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🧱 stack: mgmt Related to repo management and automations 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels May 6, 2023
@AetherUnbound AetherUnbound removed the 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work label May 6, 2023
@AetherUnbound AetherUnbound marked this pull request as ready for review May 6, 2023 03:14
@AetherUnbound AetherUnbound requested a review from a team as a code owner May 6, 2023 03:14
@openverse-bot openverse-bot moved this from In progress to Needs review in Openverse PRs May 6, 2023

def write_to_github_output(lines: list[str]) -> None:
"""
Write a list of strings to both stdout and the GITHUB_OUTPUT environment variable.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need both? What is stdout output used for?

Copy link
Member

Choose a reason for hiding this comment

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

I like writing to stdout so that it's printed in the workflow logs and helps with debugging.

Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

LGTM, this is great. Now only if there was a way to merge .github/filters.yml into the labels file as well.

On the other hand, I see less and less utility everyday in even having a labels.yml file, considering we only have two repos now (and @sarayourfriend is already coming up with interesting ways of integrating the infra into the monorepo as well).

@@ -80,6 +80,7 @@ jobs:
id: set-matrix
env:
CHANGES: ${{ needs.get-changes.outputs.changes }}
PYTHONPATH: ${{ github.workspace }}/automations/python
Copy link
Member

@dhruvkb dhruvkb May 6, 2023

Choose a reason for hiding this comment

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

Just curious, why this is necessary? Is it because of the shared functions being imported into other Python files? If so, is it better to make it a a standard Python module using an __init__.py file instead of editing PYTHONPATH?

.github/workflows/pr_label_check.yml Show resolved Hide resolved

def write_to_github_output(lines: list[str]) -> None:
"""
Write a list of strings to both stdout and the GITHUB_OUTPUT environment variable.
Copy link
Member

Choose a reason for hiding this comment

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

I like writing to stdout so that it's printed in the workflow logs and helps with debugging.

Openverse PRs automation moved this from Needs review to Reviewer approved May 7, 2023
Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

🆒 LGTM!

@AetherUnbound AetherUnbound merged commit 95f268a into main May 8, 2023
88 of 92 checks passed
Openverse PRs automation moved this from Reviewer approved to Merged! May 8, 2023
@AetherUnbound AetherUnbound deleted the feature/use-label-definition branch May 8, 2023 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: mgmt Related to repo management and automations
Projects
Archived in project
Openverse PRs
  
Merged!
Development

Successfully merging this pull request may close these issues.

Determine labels for check using labels.yml
5 participants