[llvm] Release note test v2 (PR #94774)

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 7 10:35:37 PDT 2024


https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/94774

None

>From 5ec4fdc3d1ffcd7d6a1cfab8cc533822ab736df1 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 7 Jun 2024 10:23:28 -0700
Subject: [PATCH 1/4] [workflows] Fix release note request workflow

We need to use the issue-write workflow to write the comments, because
pull_request targets don't have permissions to write comments.
---
 .github/workflows/issue-write.yml             |  1 +
 .github/workflows/pr-request-release-note.yml |  9 ++++++++-
 llvm/utils/git/github-automation.py           | 11 ++++++++++-
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/issue-write.yml b/.github/workflows/issue-write.yml
index e003be006c4e1..153734972e846 100644
--- a/.github/workflows/issue-write.yml
+++ b/.github/workflows/issue-write.yml
@@ -5,6 +5,7 @@ on:
     workflows:
       - "Check code formatting"
       - "Check for private emails used in PRs"
+      - "PR Request Release Note"
     types:
       - completed
 
diff --git a/.github/workflows/pr-request-release-note.yml b/.github/workflows/pr-request-release-note.yml
index 5e48ce7aee2e2..fc72d5a144575 100644
--- a/.github/workflows/pr-request-release-note.yml
+++ b/.github/workflows/pr-request-release-note.yml
@@ -2,7 +2,6 @@ name: PR Request Release Note
 
 permissions:
   contents: read
-  pull-requests: write
 
 on:
   pull_request:
@@ -41,3 +40,11 @@ jobs:
             --token "$GITHUB_TOKEN" \
             request-release-note \
             --pr-number ${{ github.event.pull_request.number}}
+
+
+      - uses: actions/upload-artifact at 26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
+        if: always()
+        with:
+          name: workflow-args
+          path: |
+            comments
diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index 1766ccb38ba25..350bc92ed6766 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -11,6 +11,7 @@
 import argparse
 from git import Repo  # type: ignore
 import html
+import json
 import github
 import os
 import re
@@ -653,7 +654,15 @@ def request_release_note(token: str, repo_name: str, pr_number: int):
         mention = f"@{submitter}"
 
     comment = f"{mention} (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix.  When you are done, please add the release:note label to this PR. "
-    pr.as_issue().create_comment(comment)
+    try:
+        pr.as_issue().create_comment(comment)
+    except:
+        # Failed to create comment so emit file instead
+        with open(comments, "w") as file:
+            data = [
+                {'body' : comment}
+            ]
+            json.dump(data, file)
 
 
 parser = argparse.ArgumentParser()

>From 9aa12e1b876f2150ebb896dd1c94212c71443ee6 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 7 Jun 2024 10:31:31 -0700
Subject: [PATCH 2/4] XXX: Debug

---
 .github/workflows/pr-request-release-note.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.github/workflows/pr-request-release-note.yml b/.github/workflows/pr-request-release-note.yml
index fc72d5a144575..cf7e7a431acad 100644
--- a/.github/workflows/pr-request-release-note.yml
+++ b/.github/workflows/pr-request-release-note.yml
@@ -11,7 +11,6 @@ on:
 jobs:
   request-release-note:
     if: >-
-      github.repository_owner == 'llvm' &&
       startsWith(github.ref, 'refs/heads/release')
 
     runs-on: ubuntu-latest

>From 8c0f2526b5005963ea4a5ecf14a345cfeef4d5e1 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 7 Jun 2024 10:34:29 -0700
Subject: [PATCH 3/4] Fix

---
 llvm/utils/git/github-automation.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index 350bc92ed6766..46d05dab005c2 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -658,9 +658,9 @@ def request_release_note(token: str, repo_name: str, pr_number: int):
         pr.as_issue().create_comment(comment)
     except:
         # Failed to create comment so emit file instead
-        with open(comments, "w") as file:
+        with open("comments", "w") as file:
             data = [
-                {'body' : comment}
+                {"body" : comment}
             ]
             json.dump(data, file)
 

>From 632cd6e352b99a5c37d6468f25a404805b3fd841 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 7 Jun 2024 10:27:40 -0700
Subject: [PATCH 4/4] XXX: Temp fix

---
 .github/workflows/temp | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 .github/workflows/temp

diff --git a/.github/workflows/temp b/.github/workflows/temp
new file mode 100644
index 0000000000000..e69de29bb2d1d



More information about the llvm-commits mailing list