Skip to content
Open
Show file tree
Hide file tree
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
77 changes: 77 additions & 0 deletions .github/workflows/pr-size-warning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: PR Size and Artifact Check

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
pull-requests: read

jobs:
check-pr-size:
runs-on: ubuntu-latest

env:
GH_TOKEN: ${{ github.token }}
MAX_FILES: 50
MAX_LINES: 1000

steps:
- name: Analyze PR Size and Artifacts
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
CHANGED_FILES=${{ github.event.pull_request.changed_files }}
ADDITIONS=${{ github.event.pull_request.additions }}
DELETIONS=${{ github.event.pull_request.deletions }}
TOTAL_LINES=$((ADDITIONS + DELETIONS))

echo "PR Stats:"
echo "- Files changed: $CHANGED_FILES"
echo "- Additions: $ADDITIONS"
echo "- Deletions: $DELETIONS"
echo "- Total lines changed: $TOTAL_LINES"

WARNINGS=""

# Check for oversized PRs
if [ "$CHANGED_FILES" -gt "$MAX_FILES" ] || [ "$TOTAL_LINES" -gt "$MAX_LINES" ]; then
MSG="PR is unusually large ($CHANGED_FILES files, $TOTAL_LINES lines changed). Advisory threshold: $MAX_FILES files or $MAX_LINES lines."
echo "::warning title=Large PR Detected::$MSG"
WARNINGS="${WARNINGS}
- ⚠️ **Large PR Detected**
- $MSG
- Consider splitting this PR into smaller reviewable changes.
"
fi

# Check for generated artifact directories
FILES=$(gh pr view "$PR_NUMBER" \
--repo "${{ github.repository }}" \
--json files \
--jq '.files[].path')

if echo "$FILES" | grep -qE 'playwright-report/|test-results/'; then
MSG="Generated testing artifacts detected (playwright-report/ or test-results/). Please remove them from commits."
echo "::warning title=Generated Artifacts Included::$MSG"
WARNINGS="${WARNINGS}
- 🚫 **Generated Artifacts Detected**
- $MSG
"
fi

# Publish GitHub Step Summary
if [ -n "$WARNINGS" ]; then
{
echo "## ⚠️ PR Review Advisory"
echo
echo "$WARNINGS"
echo
echo "> This workflow is advisory only and will not fail CI."
} >> "$GITHUB_STEP_SUMMARY"
else
{
echo "## ✅ PR Size and Content Check Passed"
echo
echo "No unusually large diffs or generated artifacts detected."
} >> "$GITHUB_STEP_SUMMARY"
fi
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ Your PR should include:

Try to keep one pull request focused on one problem. If a change touches unrelated areas, split it into separate PRs when possible.

### PR Size and Generated Artifacts

To keep reviews manageable, an automated workflow will post an advisory warning if a PR exceeds **50 changed files** or **1,000 total lines**. We encourage splitting unusually large changes into smaller, focused pull requests.

Additionally, please ensure you never commit auto-generated artifacts (such as `playwright-report/`, `test-results/`, `dist/`, or `.vite/`). The workflow will flag these if they are accidentally included. If this happens, remove them using `git rm --cached -r <path>`.

## Contribution Scoring

Every merged pull request can be scored for GSSoC using labels applied by the project admin or mentor. The scoring engine reads these labels after the PR is merged, so contributors should focus on clear scope, good implementation, and complete review notes rather than self-assigning score labels.
Expand Down Expand Up @@ -404,4 +410,4 @@ Never commit these auto-generated paths:
If CI fails, run:
```bash
git rm --cached <file>
echo 'frontend/dist/' >> .gitignore
echo 'frontend/dist/' >> .gitignore
Loading