From 04ef154193f669a348e82c4ebd2c949fd15c7df1 Mon Sep 17 00:00:00 2001 From: EncodedVenom Date: Sat, 19 Oct 2024 19:47:26 -0400 Subject: [PATCH 1/8] Unit testing init PR --- .github/workflows/analysis.yaml | 1 + .github/workflows/gh-warn-luau-analyze.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .github/workflows/gh-warn-luau-analyze.sh diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index f3d07bec..27da3619 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -17,3 +17,4 @@ jobs: - name: Analyze run: | output=$(luau-analyze src || true) # Suppress errors for now. + ./gh-warn-luau-analyze.sh "$output" diff --git a/.github/workflows/gh-warn-luau-analyze.sh b/.github/workflows/gh-warn-luau-analyze.sh new file mode 100644 index 00000000..9fa07e31 --- /dev/null +++ b/.github/workflows/gh-warn-luau-analyze.sh @@ -0,0 +1,19 @@ +# Parse the output and generate GitHub Actions warnings +while IFS="" read -r line || [ -n "$line" ]; do + + # Check if the line contains the error format + if [[ "$line" == *"TypeError:"* ]]; then + # Extract the file name and line number using string manipulation + file_line="${line%%:*}" # Get the part before the first colon + message="${line#*: TypeError: }" # Get the message after "TypeError: " + + # Extract the file and line number + file="${file_line%(*}" # Get the file name (everything before the '(') + location="${file_line#*()}"; # Get the part inside parentheses (line and column) + line_number="${location%%,*}"; # Extract the line number + column_number="${location#*,}"; # Extract the column number + + # Generate GitHub Actions warning + echo "::warning file=${file},line=${line_number},col=${column_number}::${message}" + fi +done From d5dc64be1bc4f4fb56aa66e6a40cb6b40995bb1b Mon Sep 17 00:00:00 2001 From: EncodedVenom Date: Sat, 19 Oct 2024 19:49:13 -0400 Subject: [PATCH 2/8] change location --- .github/workflows/analysis.yaml | 2 +- {.github/workflows => scripts}/gh-warn-luau-analyze.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {.github/workflows => scripts}/gh-warn-luau-analyze.sh (100%) diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index 27da3619..e116f01a 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -17,4 +17,4 @@ jobs: - name: Analyze run: | output=$(luau-analyze src || true) # Suppress errors for now. - ./gh-warn-luau-analyze.sh "$output" + ./scripts/gh-warn-luau-analyze.sh "$output" diff --git a/.github/workflows/gh-warn-luau-analyze.sh b/scripts/gh-warn-luau-analyze.sh similarity index 100% rename from .github/workflows/gh-warn-luau-analyze.sh rename to scripts/gh-warn-luau-analyze.sh From fefbd19b38125fab7f8fbd8ea28b00d640c2deae Mon Sep 17 00:00:00 2001 From: EncodedVenom Date: Sat, 19 Oct 2024 19:52:21 -0400 Subject: [PATCH 3/8] get around permissions --- .github/workflows/analysis.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index e116f01a..00fc8be2 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -17,4 +17,4 @@ jobs: - name: Analyze run: | output=$(luau-analyze src || true) # Suppress errors for now. - ./scripts/gh-warn-luau-analyze.sh "$output" + bash scripts/gh-warn-luau-analyze.sh "$output" From c697030ec4d8a24a096999672f20e8746f42e3e1 Mon Sep 17 00:00:00 2001 From: EncodedVenom Date: Sat, 19 Oct 2024 19:53:43 -0400 Subject: [PATCH 4/8] debug --- scripts/gh-warn-luau-analyze.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/gh-warn-luau-analyze.sh b/scripts/gh-warn-luau-analyze.sh index 9fa07e31..b2afd74b 100644 --- a/scripts/gh-warn-luau-analyze.sh +++ b/scripts/gh-warn-luau-analyze.sh @@ -1,6 +1,8 @@ # Parse the output and generate GitHub Actions warnings while IFS="" read -r line || [ -n "$line" ]; do + echo "$line" + # Check if the line contains the error format if [[ "$line" == *"TypeError:"* ]]; then # Extract the file name and line number using string manipulation From a8004011cc9ec87513936cac4ee3e08d129b190d Mon Sep 17 00:00:00 2001 From: EncodedVenom Date: Sat, 19 Oct 2024 19:55:54 -0400 Subject: [PATCH 5/8] change to file --- .github/workflows/analysis.yaml | 4 ++-- scripts/gh-warn-luau-analyze.sh | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index 00fc8be2..a11b2843 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -16,5 +16,5 @@ jobs: - name: Analyze run: | - output=$(luau-analyze src || true) # Suppress errors for now. - bash scripts/gh-warn-luau-analyze.sh "$output" + (luau-analyze src || true) > analyze-log.txt # Suppress errors for now. + cat analyze-log.txt | ./scripts/gh-warn-luau-analyze.sh diff --git a/scripts/gh-warn-luau-analyze.sh b/scripts/gh-warn-luau-analyze.sh index b2afd74b..81b170a5 100644 --- a/scripts/gh-warn-luau-analyze.sh +++ b/scripts/gh-warn-luau-analyze.sh @@ -1,4 +1,3 @@ -# Parse the output and generate GitHub Actions warnings while IFS="" read -r line || [ -n "$line" ]; do echo "$line" From b365fc8c1c15097450f574aea9d130c7ea293306 Mon Sep 17 00:00:00 2001 From: EncodedVenom Date: Sat, 19 Oct 2024 19:58:09 -0400 Subject: [PATCH 6/8] Parenthesis --- .github/workflows/analysis.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index a11b2843..3723bcf8 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -17,4 +17,4 @@ jobs: - name: Analyze run: | (luau-analyze src || true) > analyze-log.txt # Suppress errors for now. - cat analyze-log.txt | ./scripts/gh-warn-luau-analyze.sh + cat analyze-log.txt | (bash ./scripts/gh-warn-luau-analyze.sh) From 9878df20ba0396ffeb4791ba6af7d1cf29dcb935 Mon Sep 17 00:00:00 2001 From: EncodedVenom Date: Sat, 19 Oct 2024 20:02:05 -0400 Subject: [PATCH 7/8] Use bash entirely --- .github/workflows/analysis.yaml | 2 +- scripts/gh-warn-luau-analyze.sh | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index 3723bcf8..f3b491a5 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -17,4 +17,4 @@ jobs: - name: Analyze run: | (luau-analyze src || true) > analyze-log.txt # Suppress errors for now. - cat analyze-log.txt | (bash ./scripts/gh-warn-luau-analyze.sh) + bash ./scripts/gh-warn-luau-analyze.sh analyze-log.txt diff --git a/scripts/gh-warn-luau-analyze.sh b/scripts/gh-warn-luau-analyze.sh index 81b170a5..a0cd996a 100644 --- a/scripts/gh-warn-luau-analyze.sh +++ b/scripts/gh-warn-luau-analyze.sh @@ -1,6 +1,4 @@ -while IFS="" read -r line || [ -n "$line" ]; do - - echo "$line" +cat $1 | while IFS="" read -r line || [ -n "$line" ]; do # Check if the line contains the error format if [[ "$line" == *"TypeError:"* ]]; then From acc6e40aed55aa4fec4c034920a405c607f69843 Mon Sep 17 00:00:00 2001 From: EncodedVenom Date: Sat, 19 Oct 2024 20:04:29 -0400 Subject: [PATCH 8/8] Simplify script maybe? --- scripts/gh-warn-luau-analyze.sh | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/scripts/gh-warn-luau-analyze.sh b/scripts/gh-warn-luau-analyze.sh index a0cd996a..9eecd07f 100644 --- a/scripts/gh-warn-luau-analyze.sh +++ b/scripts/gh-warn-luau-analyze.sh @@ -1,18 +1,13 @@ -cat $1 | while IFS="" read -r line || [ -n "$line" ]; do +# Read the input file line by line +while IFS= read -r line; do + # Use regex to capture file name, line number, column number, and message + if [[ $line =~ ^(.+)\(([0-9]+),([0-9]+)\):\ (.+)$ ]]; then + file="${BASH_REMATCH[1]}" + line_number="${BASH_REMATCH[2]}" + column_number="${BASH_REMATCH[3]}" + message="${BASH_REMATCH[4]}" - # Check if the line contains the error format - if [[ "$line" == *"TypeError:"* ]]; then - # Extract the file name and line number using string manipulation - file_line="${line%%:*}" # Get the part before the first colon - message="${line#*: TypeError: }" # Get the message after "TypeError: " - - # Extract the file and line number - file="${file_line%(*}" # Get the file name (everything before the '(') - location="${file_line#*()}"; # Get the part inside parentheses (line and column) - line_number="${location%%,*}"; # Extract the line number - column_number="${location#*,}"; # Extract the column number - - # Generate GitHub Actions warning - echo "::warning file=${file},line=${line_number},col=${column_number}::${message}" + # Format output for GitHub Actions + echo "::warning file=$file,line=$line_number,col=$column_number::${message}" fi -done +done < "$1" \ No newline at end of file