From 302a603b4b439cc75d5d795518a32d2c73e7ff33 Mon Sep 17 00:00:00 2001 From: "Kornev, Nikita" Date: Mon, 1 Sep 2025 16:20:04 +0200 Subject: [PATCH 1/2] [CI] Add a workflow to check ready PRs This workflow checks for ready-to-merge PRs - if a PR is open, not a draft, passed all checks, and has been approved, it will ping @intel/llvm-gatekeepers if this group has not already been mentioned or if the last mention was more than $days days ago. --- .../sycl-check-ready-to-merge-prs.yml | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/sycl-check-ready-to-merge-prs.yml diff --git a/.github/workflows/sycl-check-ready-to-merge-prs.yml b/.github/workflows/sycl-check-ready-to-merge-prs.yml new file mode 100644 index 0000000000000..93100d5d71a29 --- /dev/null +++ b/.github/workflows/sycl-check-ready-to-merge-prs.yml @@ -0,0 +1,50 @@ +# This workflow checks for ready-to-merge PRs - if a PR is open, not a draft, +# passed all checks, and has been approved, it will ping @intel/llvm-gatekeepers +# if this group has not already been mentioned or if the last mention was more +# than $days days ago. + +name: Check ready-to-merge PRs + +on: + schedule: + - cron: '0 * * * *' # every hour + workflow_dispatch: + +jobs: + notify-ready-prs: + runs-on: ubuntu-latest + steps: + - name: Check + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Number of days before repeating the gatekeepers ping + days=3 + days_in_seconds=$((days*24*60*60)) + + # Function to ping gatekeepers and print debug info + ping_gatekeepers() { + pr_number=$1 + gh pr comment "$pr_number" --repo intel/llvm --body "@intel/llvm-gatekeepers please consider merging" + echo "Pinged @intel/llvm-gatekeepers for https://github.com/intel/llvm/pull/$pr_number" + } + + # Get the list of suitable PRs + prs=$(gh pr list --search "is:open review:approved draft:no status:success" --repo intel/llvm --json number --jq '.[].number') + now=$(date -u +%s) + for pr in $prs; do + # Get the timestamp of the latest comment mentioning @intel/llvm-gatekeepers + latest_ts=$(gh pr view $pr --repo intel/llvm --json comments \ + --jq '[.comments[] | select(.body | test("@intel/llvm-gatekeepers")) | .createdAt] | last') + # If there is no previous mention, ping the gatekeepers + if [[ -z "$latest_ts" ]]; then + ping_gatekeepers "$pr" + # If the latest mention is older than $days, ping the gatekeepers again + else + comment_time=$(date -u -d "$latest_ts" +%s) + age=$((now - comment_time)) + if (( age >= days_in_seconds )); then + ping_gatekeepers "$pr" + fi + fi + done From caa706d6ecf3af29b13e1deabb00c44445d26685 Mon Sep 17 00:00:00 2001 From: "Kornev, Nikita" Date: Tue, 2 Sep 2025 18:14:33 +0200 Subject: [PATCH 2/2] apply suggestions --- .github/workflows/sycl-check-ready-to-merge-prs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/sycl-check-ready-to-merge-prs.yml b/.github/workflows/sycl-check-ready-to-merge-prs.yml index 93100d5d71a29..12239a31082e1 100644 --- a/.github/workflows/sycl-check-ready-to-merge-prs.yml +++ b/.github/workflows/sycl-check-ready-to-merge-prs.yml @@ -10,8 +10,12 @@ on: - cron: '0 * * * *' # every hour workflow_dispatch: +permissions: read-all + jobs: notify-ready-prs: + permissions: + pull-requests: write runs-on: ubuntu-latest steps: - name: Check