Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/check_size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Check file sizes

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check for images larger than 150KB
run: |
MAX_SIZE="150k"
LARGE_FILES=$(find img -type f -size +$MAX_SIZE)
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The find command assumes the img directory exists. If the directory doesn't exist or is empty, the command will fail. Add -d flag or use a path check to handle this gracefully: find . -path ./img -prune -o -path ./img -type f -size +$MAX_SIZE -print or check if the directory exists first with [ -d img ] && ...

Suggested change
LARGE_FILES=$(find img -type f -size +$MAX_SIZE)
LARGE_FILES=$([ -d img ] && find img -type f -size +$MAX_SIZE)

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The workflow only checks files in the img directory but doesn't filter by file type. Consider adding file extension filtering to specifically target image files (e.g., -name '*.jpg' -o -name '*.png' -o -name '*.gif' -o -name '*.jpeg') to avoid false positives from non-image files.

Suggested change
LARGE_FILES=$(find img -type f -size +$MAX_SIZE)
LARGE_FILES=$(find img -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.gif' \) -size +$MAX_SIZE)

Copilot uses AI. Check for mistakes.

if [ -n "$LARGE_FILES" ]; then
echo "❌ Found images larger than $MAX_SIZE:"
echo "$LARGE_FILES" | while read -r file; do
du -h "$file"
done
exit 1
else
echo "✅ All images are within $MAX_SIZE limit"
fi