diff --git a/.github/workflows/pr-size.yml b/.github/workflows/pr-size.yml index 85ef9b003..a3310247c 100644 --- a/.github/workflows/pr-size.yml +++ b/.github/workflows/pr-size.yml @@ -29,4 +29,25 @@ jobs: lib/crewai/src/crewai/cli/templates/** **/*.json **/test_durations/** - **/cassettes/** \ No newline at end of file + **/cassettes/** + + python-diff-size: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + with: + fetch-depth: 0 + - name: Enforce Python diff size limit + env: + MAX: "1500" + run: | + base="origin/${{ github.base_ref }}" + # Sum added + deleted lines across changed .py files; skip binaries ("-"). + total=$(git diff --numstat "$base...HEAD" -- '*.py' \ + | awk '$1 != "-" && $2 != "-" { sum += $1 + $2 } END { print sum + 0 }') + echo "Python churn: $total lines (limit $MAX)" + if [ "$total" -gt "$MAX" ]; then + echo "::error::Python changes total $total lines, over the $MAX-line limit. Split into smaller PRs." + git diff --numstat "$base...HEAD" -- '*.py' | sort -rn + exit 1 + fi \ No newline at end of file