Skip to content

Commit

Permalink
ci: add unparsable check in fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
benfdking committed Dec 22, 2024
1 parent 1fb290e commit aeb9a31
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,10 @@ jobs:
python-version: ${{ matrix.python-version }}
- run: make python_install
- run: make ci
check-no-unparsable:
name: Check no unparsable files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: chmod +x ./.hacking/scripts/check_for_unparsable.sh
- run: ./.hacking/scripts/check_for_unparsable.sh
45 changes: 45 additions & 0 deletions .hacking/scripts/check_for_unparsable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
#
# Usage:
# ./check_pattern.sh "your_grep_pattern" [file1 file2 file3 ...]
#
# Examples:
# # Use the default directory if no files are provided
# ./check_pattern.sh "unparsable:"
#
# # Provide explicit files or directories
# ./check_pattern.sh "error|fail" logs/*.log
#
# Exit codes:
# 0 - Pattern NOT found in any file
# 1 - Pattern found in at least one file

pattern="unparsable:"
shift # Shift so $@ now contains only filenames (if any)

# If no files are specified, default to looking in crates/lib-dialects/test/fixtures/dialects/***/*.yml
if [[ $# -eq 0 ]]; then
set -- crates/lib-dialects/test/fixtures/dialects/**\/*.yml
fi

found=0
files_found=()

for filename in "$@"; do
# Use extended regular expressions (-E). -q ensures grep is quiet (no output).
if grep -qE "$pattern" "$filename" 2>/dev/null; then
found=1
files_found+=("$filename")
fi
done

# If found in any file, list them
if [[ $found -eq 1 ]]; then
echo "Pattern '$pattern' found in:"
for file in "${files_found[@]}"; do
echo " $file"
done
fi

# Exit with 1 if found, otherwise 0
exit $found

0 comments on commit aeb9a31

Please sign in to comment.