-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from embeddings-benchmark/add_commit_check
Create check_file_sizes.yml
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Check File Sizes | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
check-file-size: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # This ensures we get the full history | ||
|
||
- name: Check file sizes | ||
run: | | ||
MAX_SIZE_BYTES=$((10 * 1024 * 1024)) # 10MB in bytes | ||
# Get list of files changed in this PR | ||
FILES_CHANGED=$(git diff --name-only --diff-filter=d ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) | ||
# Check each file | ||
for file in $FILES_CHANGED; do | ||
if [ -f "$file" ]; then | ||
size=$(stat -c%s "$file") | ||
if [ $size -gt $MAX_SIZE_BYTES ]; then | ||
echo "Error: $file is larger than 10MB (size: $size bytes)" | ||
exit 1 | ||
fi | ||
fi | ||
done | ||
echo "All files are within the size limit." |