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

Align 2.16 code to main with related changes #113

Open
wants to merge 15 commits into
base: 2.16
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/add-remove-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
pull_request_target:
types: [synchronize]

pull_request_review:

issue_comment:
types: [created, edited, deleted]
if: |
Expand All @@ -15,6 +17,7 @@ on:
permissions:
pull-requests: write
contents: write
issues: write

jobs:
add-remove-labels:
Expand All @@ -38,7 +41,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_NUMBER: "${{ github.event.pull_request.number || github.event.issue.number }}"
GITHUB_EVENT_ACTION: ${{ github.event.action }}
GITHUB_EVENT_REVIEW_STATE: ${{ github.event.review.state }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
COMMENT_BODY: ${{ github.event.comment.body }}
GITHUB_USER_LOGIN: ${{ github.event.sender.login }}
ACTION: "add-remove-labels"
run: uv run python .github/workflows/scripts/pr_workflow.py
Empty file.
71 changes: 71 additions & 0 deletions .github/workflows/scripts/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from typing import Dict

LABEL_PREFIX: str = "/"
SIZE_LABEL_PREFIX: str = f"size{LABEL_PREFIX}"
WIP_LABEL_STR: str = "wip"
LGTM_LABEL_STR: str = "lgtm"
VERIFIED_LABEL_STR: str = "verified"
HOLD_LABEL_STR: str = "hold"
APPROVED_BY_LABEL_PREFIX: str = "approved-by-"
LGTM_BY_LABEL_PREFIX: str = f"{LGTM_LABEL_STR}-by-"
CHANGED_REQUESTED_BY_LABEL_PREFIX: str = "changes-requested-by-"
COMMENTED_BY_LABEL_PREFIX: str = "commented-by-"
SUCCESS_STR: str = "success"
FAILURE_STR: str = "failure"
QUEUED_STR: str = "queued"

SUPPORTED_LABELS: set[str] = {
f"{LABEL_PREFIX}{WIP_LABEL_STR}",
f"{LABEL_PREFIX}{LGTM_LABEL_STR}",
f"{LABEL_PREFIX}{VERIFIED_LABEL_STR}",
f"{LABEL_PREFIX}{HOLD_LABEL_STR}",
}

CANCEL_ACTION: str = "cancel"
WELCOME_COMMENT: str = f"""
The following are automatically added/executed:
* PR size label.
* Run [pre-commit](https://pre-commit.ci/)
* Run [tox](https://tox.wiki/)

Available user actions:
* To mark a PR as `WIP`, add `/wip` in a comment. To remove it from the PR comment `/wip cancel` to the PR.
* To block merging of a PR, add `/hold` in a comment. To un-block merging of PR comment `/hold cancel`.
* To mark a PR as approved, add `/lgtm` in a comment. To remove, add `/lgtm cancel`.
`lgtm` label removed on each new commit push.
* To mark PR as verified comment `/verified` to the PR, to un-verify comment `/verified cancel` to the PR.
`verified` label removed on each new commit push.

<details>
<summary>Supported labels</summary>

{SUPPORTED_LABELS}
</details>
"""


DEFAULT_LABEL_COLOR = "B60205"
USER_LABELS_DICT: Dict[str, str] = {
HOLD_LABEL_STR: DEFAULT_LABEL_COLOR,
VERIFIED_LABEL_STR: "0E8A16",
WIP_LABEL_STR: DEFAULT_LABEL_COLOR,
LGTM_LABEL_STR: "0E8A16",
}

STATIC_LABELS_DICT: Dict[str, str] = {
**USER_LABELS_DICT,
f"{SIZE_LABEL_PREFIX}l": "F5621C",
f"{SIZE_LABEL_PREFIX}m": "F09C74",
f"{SIZE_LABEL_PREFIX}s": "0E8A16",
f"{SIZE_LABEL_PREFIX}xl": "D93F0B",
f"{SIZE_LABEL_PREFIX}xs": "ededed",
f"{SIZE_LABEL_PREFIX}xxl": DEFAULT_LABEL_COLOR,
}

DYNAMIC_LABELS_DICT: Dict[str, str] = {
LGTM_BY_LABEL_PREFIX: "DCED6F",
COMMENTED_BY_LABEL_PREFIX: "D93F0B",
CHANGED_REQUESTED_BY_LABEL_PREFIX: "F5621C",
}

ALL_LABELS_DICT: Dict[str, str] = {**STATIC_LABELS_DICT, **DYNAMIC_LABELS_DICT}
Loading
Loading