Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
0822fc05
Unverified
Commit
0822fc05
authored
Nov 02, 2021
by
moto
Committed by
GitHub
Nov 02, 2021
Browse files
Update PR label notifier (#1964)
Include the list of labels.
parent
8a93717c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
.github/process_commit.py
.github/process_commit.py
+16
-3
.github/workflows/pr-labels.yml
.github/workflows/pr-labels.yml
+3
-6
No files found.
.github/process_commit.py
View file @
0822fc05
#!/usr/bin/env python3
"""
"""
This script finds the merger responsible for labeling a PR by a commit SHA. It is used by the workflow in
This script finds the merger responsible for labeling a PR by a commit SHA. It is used by the workflow in
'.github/workflows/pr-labels.yml'. If there exists no PR associated with the commit or the PR is properly labeled,
'.github/workflows/pr-labels.yml'. If there exists no PR associated with the commit or the PR is properly labeled,
...
@@ -60,14 +61,26 @@ def get_pr_merger_and_labels(pr_number: int) -> Tuple[str, Set[str]]:
...
@@ -60,14 +61,26 @@ def get_pr_merger_and_labels(pr_number: int) -> Tuple[str, Set[str]]:
return
merger
,
labels
return
merger
,
labels
if
__name__
==
"__main__"
:
def
_get_formatted
(
l
):
return
', '
.
join
(
f
'`
{
i
}
`'
for
i
in
l
)
def
_main
():
commit_hash
=
sys
.
argv
[
1
]
commit_hash
=
sys
.
argv
[
1
]
pr_number
=
get_pr_number
(
commit_hash
)
pr_number
=
get_pr_number
(
commit_hash
)
if
not
pr_number
:
if
not
pr_number
:
sys
.
exit
(
0
)
return
merger
,
labels
=
get_pr_merger_and_labels
(
pr_number
)
merger
,
labels
=
get_pr_merger_and_labels
(
pr_number
)
is_properly_labeled
=
bool
(
PRIMARY_LABELS
.
intersection
(
labels
)
and
SECONDARY_LABELS
.
intersection
(
labels
))
is_properly_labeled
=
bool
(
PRIMARY_LABELS
.
intersection
(
labels
)
and
SECONDARY_LABELS
.
intersection
(
labels
))
if
not
is_properly_labeled
:
if
not
is_properly_labeled
:
print
(
f
"@
{
merger
}
"
)
print
(
f
"""Hi @
{
merger
}
You merged this PR, but one or more labels are missing.
Please include a primary label (
{
_get_formatted
(
PRIMARY_LABELS
)
}
) and a secondary label (
{
_get_formatted
(
SECONDARY_LABELS
)
}
).
"""
)
# noqa: E501
if
__name__
==
"__main__"
:
_main
()
.github/workflows/pr-labels.yml
View file @
0822fc05
...
@@ -21,15 +21,12 @@ jobs:
...
@@ -21,15 +21,12 @@ jobs:
-
name
:
Process commit and find merger responsible for labeling
-
name
:
Process commit and find merger responsible for labeling
id
:
commit
id
:
commit
run
:
echo "::set-output name=me
r
ge
r
::$(python .github/process_commit.py ${{ github.sha }})"
run
:
echo "::set-output name=me
ssa
ge::$(python .github/process_commit.py ${{ github.sha }})"
-
name
:
Ping merger responsible for labeling if necessary
-
name
:
Ping merger responsible for labeling if necessary
if
:
${{ steps.commit.outputs.me
r
ge
r
!= '' }}
if
:
${{ steps.commit.outputs.me
ssa
ge != '' }}
uses
:
mshick/add-pr-comment@v1
uses
:
mshick/add-pr-comment@v1
env
:
env
:
GITHUB_TOKEN
:
${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN
:
${{ secrets.GITHUB_TOKEN }}
with
:
with
:
message
:
|
message
:
${{ steps.commit.outputs.message }}
Hey ${{ steps.commit.outputs.merger }}!
You merged this PR, but labels were not properly added. Please add a primary and secondary label
(See https://github.com/pytorch/audio/blob/main/.github/process_commit.py)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment