@@ -779,25 +779,32 @@ runs:
779
779
echo "Running Vale with config .github/docs/vale/.vale.ini"
780
780
if [ -n "$FILES_TO_CHECK" ]; then
781
781
echo "Using space-separated file list for Vale"
782
- vale --no-exit --output=JSON --config=.github/docs/vale/.vale.ini $FILES_TO_CHECK > "$TEMP_DIR/vale_results.json" 2>/dev/null || true
782
+ # Use xargs to properly handle each file as a separate argument
783
+ echo "$FILES_TO_CHECK" | xargs vale --no-exit --output=JSON --config=.github/docs/vale/.vale.ini > "$TEMP_DIR/vale_results.json" 2>/dev/null || true
783
784
elif [ -n "$MD_FILES_CSV" ]; then
784
785
# Convert CSV to space-separated for command line
785
786
echo "Using converted CSV file list for Vale"
786
- FILE_LIST=$(echo "$MD_FILES_CSV" | tr ',' ' ')
787
- vale --no-exit --output=JSON --config=.github/docs/vale/.vale.ini $FILE_LIST > "$TEMP_DIR/vale_results.json" 2>/dev/null || true
787
+ # Use xargs to properly handle each file as a separate argument
788
+ echo "$MD_FILES_CSV" | tr ',' '\n' | xargs vale --no-exit --output=JSON --config=.github/docs/vale/.vale.ini > "$TEMP_DIR/vale_results.json" 2>/dev/null || true
788
789
else
789
790
echo "No files to check with Vale"
790
791
echo "[]" > "$TEMP_DIR/vale_results.json"
791
792
fi
792
793
793
794
# Process results from JSON output
794
795
if [ -f "$TEMP_DIR/vale_results.json" ]; then
796
+ # Check if the file is empty (which is valid but not valid JSON)
797
+ if [ ! -s "$TEMP_DIR/vale_results.json" ]; then
798
+ echo "Empty results file, treating as success"
799
+ echo "[]" > "$TEMP_DIR/vale_results.json"
800
+ fi
801
+
795
802
# Make sure the JSON output is valid
796
803
if jq empty "$TEMP_DIR/vale_results.json" 2>/dev/null; then
797
804
VALE_OUTPUT=$(cat "$TEMP_DIR/vale_results.json")
798
805
799
- # Check if there are any issues
800
- if [ "$VALE_OUTPUT" = "[]" ] || [ "$(echo "$VALE_OUTPUT" | jq 'length')" -eq 0 ]; then
806
+ # Handle empty array case explicitly
807
+ if [ "$VALE_OUTPUT" = "" ] || [ "$VALE_OUTPUT" = " []" ] || [ "$(echo "$VALE_OUTPUT" | jq 'length')" -eq 0 ]; then
801
808
echo "Vale check passed : No style issues found"
802
809
echo "status=success" >> $GITHUB_OUTPUT
803
810
echo "message=No style issues found in $FILE_COUNT files" >> $GITHUB_OUTPUT
@@ -806,16 +813,18 @@ runs:
806
813
ISSUE_COUNT=$(echo "$VALE_OUTPUT" | jq 'length')
807
814
echo "Vale found $ISSUE_COUNT style issues in $FILE_COUNT files"
808
815
809
- # Group issues by file for better readability
810
- echo "$VALE_OUTPUT" | jq -r 'group_by(.Path) | .[] | .[0].Path + ":" + (. | length | tostring) + " issues"'
816
+ # Group issues by file for better readability (with safety check)
817
+ echo "$VALE_OUTPUT" | jq -r 'try ( group_by(.Path) | .[] | .[0].Path + ":" + (. | length | tostring) + " issues") // "Could not group issues"'
811
818
812
819
# Show details of first 10 issues
813
820
echo "First 10 issues (detail):"
814
- echo "$VALE_OUTPUT" | jq -r '.[] | "\(.Path):\(.Line):\(.Column) - \(.Message) (\(.Check))"' | head -10
821
+ echo "$VALE_OUTPUT" | jq -r 'try ( .[] | "\(.Path):\(.Line):\(.Column) - \(.Message) (\(.Check))") // "Error displaying issues "' | head -10
815
822
816
823
echo "status=warning" >> $GITHUB_OUTPUT
817
824
echo "message=Found $ISSUE_COUNT style issues in $FILE_COUNT files" >> $GITHUB_OUTPUT
818
- echo "issues=$VALE_OUTPUT" >> $GITHUB_OUTPUT
825
+ # Limit the size of the issues output to avoid any GitHub Actions limits
826
+ ISSUES_TRUNCATED=$(echo "$VALE_OUTPUT" | jq 'if length > 50 then .[0:50] else . end')
827
+ echo "issues=$ISSUES_TRUNCATED" >> $GITHUB_OUTPUT
819
828
fi
820
829
else
821
830
echo "Warning : Vale produced invalid JSON output, treating as success"
0 commit comments