From cf68ceb5da3e52d4a36cd0eb90e2d9675ea23443 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Sun, 12 Jan 2025 23:51:59 -0600 Subject: [PATCH 1/7] Increase pcregrep buffer size --- .github/workflows/label.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 8cc6ef100a..f742748b0e 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -37,14 +37,16 @@ jobs: # Download just the diff so it is harder to accidentally run any code from the pull request. gh pr diff --repo TurboWarp/extensions "$PR_NUMBER" > pr.diff - # Note that pcregrep exits with success on any match, failure on no match - if pcregrep -M "^--- /dev/null\n\+\+\+ b/extensions/" pr.diff; then + # Note that pcregrep exits with success on any match, failure on no match or internal buffer overflow. + # To avoid errors on big diffs like compressed SVGs, increase the internal buffer size dramatically. + # This is pretty big and uses ~50MB of RAM but the machines can fit that just fine. + if pcregrep --buffer-size 16777216 -M "^--- /dev/null\n\+\+\+ b/extensions/" pr.diff; then # Example: # --- /dev/null # +++ b/extensions/DangoCat/extension.js gh pr edit --repo TurboWarp/extensions "$PR_NUMBER" --add-label "$LABEL_NEW_EXTENSION" got_any_specific_label=true - elif pcregrep "^\+\+\+ b/extensions/" pr.diff; then + elif pcregrep --buffer-size 16777216 "^\+\+\+ b/extensions/" pr.diff; then # Example: # --- a/extensions/DangoCat/extension.js # +++ b/extensions/DangoCat/extension.js From 49e733a1c472827b299c67f1f1283b5db0273040 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Sun, 12 Jan 2025 23:52:43 -0600 Subject: [PATCH 2/7] Print the diff --- .github/workflows/label.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index f742748b0e..c1332b41db 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -37,6 +37,9 @@ jobs: # Download just the diff so it is harder to accidentally run any code from the pull request. gh pr diff --repo TurboWarp/extensions "$PR_NUMBER" > pr.diff + # Print diff for debugging + cat pr.diff + # Note that pcregrep exits with success on any match, failure on no match or internal buffer overflow. # To avoid errors on big diffs like compressed SVGs, increase the internal buffer size dramatically. # This is pretty big and uses ~50MB of RAM but the machines can fit that just fine. From eebd54f7a353092ad9b6518857b0542e2dd30279 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Sun, 12 Jan 2025 23:55:42 -0600 Subject: [PATCH 3/7] Add more printing --- .github/workflows/label.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index c1332b41db..f68fad087e 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -34,6 +34,8 @@ jobs: got_any_specific_label=false if [[ "$BASE_REF" == "master" ]]; then + echo "Download diff" + # Download just the diff so it is harder to accidentally run any code from the pull request. gh pr diff --repo TurboWarp/extensions "$PR_NUMBER" > pr.diff @@ -47,12 +49,14 @@ jobs: # Example: # --- /dev/null # +++ b/extensions/DangoCat/extension.js + echo "Labeling $LABEL_NEW_EXTENSION" gh pr edit --repo TurboWarp/extensions "$PR_NUMBER" --add-label "$LABEL_NEW_EXTENSION" got_any_specific_label=true elif pcregrep --buffer-size 16777216 "^\+\+\+ b/extensions/" pr.diff; then # Example: # --- a/extensions/DangoCat/extension.js # +++ b/extensions/DangoCat/extension.js + echo "Labeling $LABEL_CHANGE_EXTENSION" gh pr edit --repo TurboWarp/extensions "$PR_NUMBER" --add-label "$LABEL_CHANGE_EXTENSION" got_any_specific_label=true fi @@ -62,6 +66,7 @@ jobs: # Any PR that didn't get a specific label will go into other, for a human to look at. if [[ "$got_any_specific_label" == "false" ]]; then + echo "Labeling $LABEL_OTHER" gh pr edit --repo TurboWarp/extensions "$PR_NUMBER" --add-label "$LABEL_OTHER" fi env: From bf641aa68df60447e81fc254d0296077da300226 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Sun, 12 Jan 2025 23:58:03 -0600 Subject: [PATCH 4/7] Unhardcode repo --- .github/workflows/label.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index f68fad087e..36d25b01d8 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -12,7 +12,7 @@ jobs: label-pull-request: runs-on: ubuntu-latest - # This workflow is not useful to forks without significantly updating the workflow script. + # Disabled by default for forks since this is probably not useful. if: ${{ github.repository == 'TurboWarp/extensions' }} permissions: @@ -37,7 +37,7 @@ jobs: echo "Download diff" # Download just the diff so it is harder to accidentally run any code from the pull request. - gh pr diff --repo TurboWarp/extensions "$PR_NUMBER" > pr.diff + gh pr diff --repo "$GH_REPO" "$PR_NUMBER" > pr.diff # Print diff for debugging cat pr.diff @@ -50,14 +50,14 @@ jobs: # --- /dev/null # +++ b/extensions/DangoCat/extension.js echo "Labeling $LABEL_NEW_EXTENSION" - gh pr edit --repo TurboWarp/extensions "$PR_NUMBER" --add-label "$LABEL_NEW_EXTENSION" + gh pr edit --repo "$GH_REPO" "$PR_NUMBER" --add-label "$LABEL_NEW_EXTENSION" got_any_specific_label=true elif pcregrep --buffer-size 16777216 "^\+\+\+ b/extensions/" pr.diff; then # Example: # --- a/extensions/DangoCat/extension.js # +++ b/extensions/DangoCat/extension.js echo "Labeling $LABEL_CHANGE_EXTENSION" - gh pr edit --repo TurboWarp/extensions "$PR_NUMBER" --add-label "$LABEL_CHANGE_EXTENSION" + gh pr edit --repo "$GH_REPO" "$PR_NUMBER" --add-label "$LABEL_CHANGE_EXTENSION" got_any_specific_label=true fi else @@ -67,9 +67,10 @@ jobs: # Any PR that didn't get a specific label will go into other, for a human to look at. if [[ "$got_any_specific_label" == "false" ]]; then echo "Labeling $LABEL_OTHER" - gh pr edit --repo TurboWarp/extensions "$PR_NUMBER" --add-label "$LABEL_OTHER" + gh pr edit --repo "$GH_REPO" "$PR_NUMBER" --add-label "$LABEL_OTHER" fi env: PR_NUMBER: "${{ github.event.number }}" BASE_REF: "${{ github.base_ref }}" GH_TOKEN: "${{ github.token }}" + GH_REPO: "${{ github.repository }}" From 2f84ea191554b065ced14c84c5de4f0e1254305d Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Sun, 12 Jan 2025 23:59:20 -0600 Subject: [PATCH 5/7] Avoid unnecessary use of cat --- .github/workflows/label.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 36d25b01d8..8677114bab 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -37,10 +37,7 @@ jobs: echo "Download diff" # Download just the diff so it is harder to accidentally run any code from the pull request. - gh pr diff --repo "$GH_REPO" "$PR_NUMBER" > pr.diff - - # Print diff for debugging - cat pr.diff + gh pr diff --repo "$GH_REPO" "$PR_NUMBER" | tee pr.diff # Note that pcregrep exits with success on any match, failure on no match or internal buffer overflow. # To avoid errors on big diffs like compressed SVGs, increase the internal buffer size dramatically. From 555fa978679436d99b96f11f1dd8fbda5f8f2c0d Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Mon, 13 Jan 2025 00:01:59 -0600 Subject: [PATCH 6/7] update string --- .github/workflows/label.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 8677114bab..5997302a08 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -34,7 +34,7 @@ jobs: got_any_specific_label=false if [[ "$BASE_REF" == "master" ]]; then - echo "Download diff" + echo "Downloading pull request diff" # Download just the diff so it is harder to accidentally run any code from the pull request. gh pr diff --repo "$GH_REPO" "$PR_NUMBER" | tee pr.diff From 68de451df69b1141e330d5c727b8007c77255d46 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Mon, 13 Jan 2025 00:02:18 -0600 Subject: [PATCH 7/7] update the other logs --- .github/workflows/label.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 5997302a08..3d620df919 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -46,14 +46,14 @@ jobs: # Example: # --- /dev/null # +++ b/extensions/DangoCat/extension.js - echo "Labeling $LABEL_NEW_EXTENSION" + echo "Adding label: $LABEL_NEW_EXTENSION" gh pr edit --repo "$GH_REPO" "$PR_NUMBER" --add-label "$LABEL_NEW_EXTENSION" got_any_specific_label=true elif pcregrep --buffer-size 16777216 "^\+\+\+ b/extensions/" pr.diff; then # Example: # --- a/extensions/DangoCat/extension.js # +++ b/extensions/DangoCat/extension.js - echo "Labeling $LABEL_CHANGE_EXTENSION" + echo "Adding label: $LABEL_CHANGE_EXTENSION" gh pr edit --repo "$GH_REPO" "$PR_NUMBER" --add-label "$LABEL_CHANGE_EXTENSION" got_any_specific_label=true fi @@ -63,7 +63,7 @@ jobs: # Any PR that didn't get a specific label will go into other, for a human to look at. if [[ "$got_any_specific_label" == "false" ]]; then - echo "Labeling $LABEL_OTHER" + echo "Adding label: $LABEL_OTHER" gh pr edit --repo "$GH_REPO" "$PR_NUMBER" --add-label "$LABEL_OTHER" fi env: