-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tatsat Mishra <[email protected]>
- Loading branch information
Tatsat Mishra
committed
May 30, 2024
1 parent
c583894
commit f481ebc
Showing
1 changed file
with
54 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,54 @@ | ||
name: 'PR Size Checker' | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
MAX_LINE_CHANGED: 1200 # Maximum number of lines changed allowed | ||
TARGET_BRANCH: main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [macos-latest, ubuntu-latest, windows-latest] | ||
permissions: | ||
actions: read | ||
contents: read | ||
deployments: read | ||
packages: none | ||
steps: | ||
# checkout your code with your git history | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- id: get_total_lines_changed | ||
run: | | ||
size=$(git diff --stat origin/${{ env.TARGET_BRANCH }} \ | ||
| grep -v .lock \ | ||
| grep -v Bin \ | ||
| awk -F"|" '{ print $2 }' \ | ||
| awk '{ print $1 }' \ | ||
| sed '/^$/d' \ | ||
| paste -sd+ - \ | ||
| bc) | ||
echo "size=${size}" >> $GITHUB_ENV | ||
echo "" | ||
echo "Total lines changed (note: *.lock files are excluded from this count): " | ||
echo $size | ||
shell: bash | ||
- run: | | ||
if [[ $size -gt ${{ env.MAX_LINE_CHANGED }} ]] | ||
then | ||
echo "Warning - total lines changed is greater than" ${{ env.MAX_LINE_CHANGED }}. | ||
echo "Please consider breaking this PR down." | ||
exit 1 | ||
fi | ||
shell: bash |