Skip to content

Commit 65219fe

Browse files
GitHub actions: add new automation to limit directory sizes
After discovering in August that Zend/tests had over 2500 entries, and that GitHub limits the display to only the first 1000 entries, I filed phpGH-15631 and sent a whole slew of patches to split up that directory and organize the tests a bit better. After the most recent patch, phpGH-17920, there are now once again fewer than 1,000 entries in that directory (for what seems to be the first time since the PHP 5.3 development cycle). Add a new GitHub action to the test suite that will ensure that no directory gets above 1,000 items - while the Zend/tests directory was the only one that had already hit that limit, there isn't much harm in checking all of the directories, and some of the extensions have hundreds of tests already and could conceivably hit the limit at some point. Closes phpGH-15631
1 parent 13108bb commit 65219fe

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: Verify directories are not too big
2+
runs:
3+
using: composite
4+
steps:
5+
- shell: bash
6+
run: bash "${GITHUB_WORKSPACE}/.github/actions/verify-directory-sizes/script.sh"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
set +x
5+
6+
# Bash script to check directory sizes, we want to keep each directory under
7+
# at most 1000 entries so that the GitHub online interface can be used to
8+
# browse without excluding files
9+
MAX_DIR_SIZE=0
10+
MAX_DIR_NAME=0
11+
12+
# This is enforced limit
13+
DIR_SIZE_LIMIT=1000
14+
15+
check_directory () {
16+
local CURR_DIR=$1
17+
local CURR_DIR_SIZE=$(ls -l $CURR_DIR | wc -l)
18+
if [ "$CURR_DIR_SIZE" -gt "$DIR_SIZE_LIMIT" ]; then
19+
# Show the same message but in red
20+
echo -e "\033[0;31m$CURR_DIR has $CURR_DIR_SIZE entries\033[0m"
21+
else
22+
echo "$CURR_DIR has $CURR_DIR_SIZE entries"
23+
fi
24+
if [ "$CURR_DIR_SIZE" -gt "$MAX_DIR_SIZE" ]; then
25+
MAX_DIR_SIZE=$CURR_DIR_SIZE
26+
MAX_DIR_NAME=$CURR_DIR
27+
fi
28+
29+
# Sending stderr to /dev/null is used to suppress errors about no such
30+
# file or directory when a directory has no sub directories
31+
local SUBDIRS=$(ls -d $CURR_DIR*/ 2>/dev/null)
32+
for SUBDIR in $SUBDIRS
33+
do
34+
check_directory $SUBDIR
35+
done
36+
}
37+
38+
check_directory ./
39+
40+
echo "Biggest directory: $MAX_DIR_NAME"
41+
echo "Size: $MAX_DIR_SIZE"
42+
43+
if [ "$MAX_DIR_SIZE" -gt "$DIR_SIZE_LIMIT" ]; then
44+
echo -e "\033[0;31mMaximum allowed size: $DIR_SIZE_LIMIT\033[0m"
45+
# Action is unsuccessful
46+
exit 1
47+
fi

.github/workflows/push.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ jobs:
136136
- name: Verify generated files are up to date
137137
if: ${{ !matrix.asan }}
138138
uses: ./.github/actions/verify-generated-files
139+
- name: Verify directories are not too big
140+
if: ${{ !matrix.asan }}
141+
uses: ./.github/actions/verify-directory-sizes
139142
LINUX_X32:
140143
if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
141144
name: LINUX_X32_DEBUG_ZTS

0 commit comments

Comments
 (0)