From 90b8dd5aa9a35613842731259f3faab52e67143b Mon Sep 17 00:00:00 2001 From: bracesproul Date: Mon, 26 Aug 2024 11:43:59 -0700 Subject: [PATCH 1/3] infra[patch]: Fix comment regex --- .github/workflows/spam-comment-filter.yml | 2 +- .../langchain-scripts/src/tests/check_regex.test.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 libs/langchain-scripts/src/tests/check_regex.test.ts diff --git a/.github/workflows/spam-comment-filter.yml b/.github/workflows/spam-comment-filter.yml index b96f08f5896a..ecb632327ac6 100644 --- a/.github/workflows/spam-comment-filter.yml +++ b/.github/workflows/spam-comment-filter.yml @@ -19,7 +19,7 @@ jobs: id: regex_check run: | REGEX='^download\s+(?:https?:\/\/)?[\w-]+(\.[\w-]+)+[^\s]+\s+password:\s*.+\s+in the installer menu, select\s*.+$' - if echo "${{ github.event.comment.body }}" | grep -qiE "$REGEX"; then + if echo "${{ github.event.comment.body }}" | tr '\n' ' ' | grep -qiP "$REGEX"; then echo "REGEX_MATCHED=true" >> $GITHUB_OUTPUT else echo "REGEX_MATCHED=false" >> $GITHUB_OUTPUT diff --git a/libs/langchain-scripts/src/tests/check_regex.test.ts b/libs/langchain-scripts/src/tests/check_regex.test.ts new file mode 100644 index 000000000000..bd749d28768e --- /dev/null +++ b/libs/langchain-scripts/src/tests/check_regex.test.ts @@ -0,0 +1,13 @@ +import { test, expect } from '@jest/globals'; + +test("REGEX WORKS", () => { + const regex = /^download\s+(?:https?:\/\/)?[\w-]+(\.[\w-]+)+[^\s]+\s+password:\s*.+\s+in the installer menu, select\s*.+$/i + + const comment = `Download +https://www.mediafire.com/file/wpwfw3bpd8gsjey/fix.rar/file +password: changeme +In the installer menu, select "gcc."` + + expect(regex.test(comment.toLowerCase())).toBe(true); +}) + From b23a4000beb8af212a11436a3dd8961420bb60f0 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Mon, 26 Aug 2024 11:48:54 -0700 Subject: [PATCH 2/3] chore: lint files --- libs/langchain-scripts/src/tests/check_regex.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/langchain-scripts/src/tests/check_regex.test.ts b/libs/langchain-scripts/src/tests/check_regex.test.ts index bd749d28768e..924fe819924c 100644 --- a/libs/langchain-scripts/src/tests/check_regex.test.ts +++ b/libs/langchain-scripts/src/tests/check_regex.test.ts @@ -1,13 +1,13 @@ -import { test, expect } from '@jest/globals'; +import { test, expect } from "@jest/globals"; test("REGEX WORKS", () => { - const regex = /^download\s+(?:https?:\/\/)?[\w-]+(\.[\w-]+)+[^\s]+\s+password:\s*.+\s+in the installer menu, select\s*.+$/i + const regex = + /^download\s+(?:https?:\/\/)?[\w-]+(\.[\w-]+)+[^\s]+\s+password:\s*.+\s+in the installer menu, select\s*.+$/i; const comment = `Download https://www.mediafire.com/file/wpwfw3bpd8gsjey/fix.rar/file password: changeme -In the installer menu, select "gcc."` +In the installer menu, select "gcc."`; expect(regex.test(comment.toLowerCase())).toBe(true); -}) - +}); From 27dcf57db4632af391cc53c3b151e08f5af61181 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Mon, 26 Aug 2024 11:49:14 -0700 Subject: [PATCH 3/3] cr --- .../langchain-scripts/src/tests/check_regex.test.ts | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 libs/langchain-scripts/src/tests/check_regex.test.ts diff --git a/libs/langchain-scripts/src/tests/check_regex.test.ts b/libs/langchain-scripts/src/tests/check_regex.test.ts deleted file mode 100644 index 924fe819924c..000000000000 --- a/libs/langchain-scripts/src/tests/check_regex.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { test, expect } from "@jest/globals"; - -test("REGEX WORKS", () => { - const regex = - /^download\s+(?:https?:\/\/)?[\w-]+(\.[\w-]+)+[^\s]+\s+password:\s*.+\s+in the installer menu, select\s*.+$/i; - - const comment = `Download -https://www.mediafire.com/file/wpwfw3bpd8gsjey/fix.rar/file -password: changeme -In the installer menu, select "gcc."`; - - expect(regex.test(comment.toLowerCase())).toBe(true); -});