Skip to content

PR metadata check: few tweaks and wait for the Manifest workflow explicitly #90806

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

Merged
Merged
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
12 changes: 1 addition & 11 deletions .github/workflows/pr_metadata_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,4 @@ jobs:
- name: Run the check script
run: |
./scripts/ci/do_not_merge.py -p "${{ github.event.pull_request.number }}"
empty_pr_description:
if: ${{ github.event.pull_request.body == '' }}
name: PR Description
runs-on: ubuntu-24.04
steps:
- name: Check for PR description
run: |
echo "Pull request description cannot be empty."
exit 1
python -u scripts/ci/do_not_merge.py -p "${{ github.event.pull_request.number }}"
45 changes: 43 additions & 2 deletions scripts/ci/do_not_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
# SPDX-License-Identifier: Apache-2.0

import argparse
import datetime
import os
import sys
import time

import github

Expand All @@ -24,6 +26,30 @@ def parse_args(argv):
return parser.parse_args(argv)


WAIT_FOR_WORKFLOWS = set({"Manifest"})
WAIT_FOR_DELAY_S = 60


def workflow_delay(repo, pr):
print(f"PR is at {pr.head.sha}")

while True:
runs = repo.get_workflow_runs(head_sha=pr.head.sha)

completed = set()
for run in runs:
print(f"{run.name}: {run.status} {run.conclusion} {run.html_url}")
if run.status == "completed" and run.conclusion == "success":
completed.add(run.name)

if WAIT_FOR_WORKFLOWS.issubset(completed):
return

ts = datetime.datetime.now()
print(f"wait: {ts} completed={completed}")
time.sleep(WAIT_FOR_DELAY_S)


def main(argv):
args = parse_args(argv)

Expand All @@ -32,11 +58,26 @@ def main(argv):
repo = gh.get_repo("zephyrproject-rtos/zephyr")
pr = repo.get_pull(args.pull_request)

workflow_delay(repo, pr)

print(f"pr: {pr.html_url}")

fail = False

for label in pr.get_labels():
print(f"label: {label.name}")

if label.name in DNM_LABELS:
print(f"Pull request is labeled as \"{label.name}\".")
print("This workflow fails so that the pull request cannot be merged.")
sys.exit(1)
fail = True

if not pr.body:
print("Pull request is description is empty.")
fail = True

if fail:
print("This workflow fails so that the pull request cannot be merged.")
sys.exit(1)


if __name__ == "__main__":
Expand Down
Loading