-
Notifications
You must be signed in to change notification settings - Fork 0
chore: implement final branch protection and workflow tweaks #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
79da81a
2f420eb
1dfc2e2
d8c76ce
c1df0af
7a1c836
b21ad30
72fc5a0
d53f21c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,18 @@ | ||
| { | ||
| "timestamp": "2025-07-31 23:00:07 UTC", | ||
| "branch": "fix/pr-validation-check-changed-files", | ||
| "commit": "8677efd1f17264fe17c796320fac412fe9c149f1", | ||
| "message": "fix(ci): Only run Swift checks on PRs with Swift changes | ||
| "timestamp": "2025-08-01 06:28:22 UTC", | ||
| "branch": "chore/restore-protection", | ||
| "commit": "72fc5a03625ed521ef835f336b5e15c73fc6ae04", | ||
| "message": "chore: complete architecture reorganization and cleanup | ||
|
|
||
| - Check if PR contains Swift file changes before running SwiftLint | ||
| - Skip Swift-specific checks (TODO/FIXME, security) for non-Swift PRs | ||
| - Fixes CI failures on workflow-only PRs like #244-#248 | ||
| - Reorganized Infrastructure-Storage with proper source structure | ||
| - Updated Services-Business and Services-External modules | ||
| - Enhanced Foundation layer with proper configurations | ||
| - Updated UI components and feature views | ||
| - Cleaned up Xcode project files and schemes | ||
| - Added new foundation models and core functionality | ||
| - Updated supporting files and test configurations | ||
|
|
||
| This properly handles PRs that only modify workflows, scripts, or | ||
| documentation without triggering Swift-related validations." | ||
| 🤖 Generated with [Claude Code](https://claude.ai/code) | ||
|
|
||
| Co-Authored-By: Claude <noreply@anthropic.com>" | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,114 @@ | ||||||
| name: Commit Limits | ||||||
|
|
||||||
| on: | ||||||
| pull_request: | ||||||
| types: [opened, synchronize, reopened] | ||||||
| push: | ||||||
| branches: [main, dev] | ||||||
|
|
||||||
| jobs: | ||||||
| lint-commits: | ||||||
| name: Check commit sizes and branch naming | ||||||
| runs-on: ubuntu-latest | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v4 | ||||||
| with: | ||||||
| fetch-depth: 0 | ||||||
|
|
||||||
| - name: Check branch naming convention | ||||||
| if: github.event_name == 'pull_request' | ||||||
| run: | | ||||||
| branch_name="${{ github.head_ref }}" | ||||||
|
|
||||||
| # Define valid branch prefixes | ||||||
| valid_prefixes="feat|fix|docs|style|refactor|test|chore|perf|ci|build|revert" | ||||||
|
|
||||||
| # Check if branch follows naming convention | ||||||
| if ! echo "$branch_name" | grep -E "^($valid_prefixes)/" > /dev/null; then | ||||||
| echo "❌ Branch name '$branch_name' doesn't follow naming convention" | ||||||
| echo "Branch names must start with one of: feat/, fix/, docs/, style/, refactor/, test/, chore/, perf/, ci/, build/, revert/" | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| echo "✅ Branch name follows convention" | ||||||
|
|
||||||
| - name: Check commit sizes | ||||||
| run: | | ||||||
| # For PRs, check all commits in the PR | ||||||
| if [ "${{ github.event_name }}" == "pull_request" ]; then | ||||||
| commits=$(git rev-list ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}) | ||||||
| else | ||||||
| # For pushes, just check the latest commit | ||||||
| commits=$(git rev-parse HEAD) | ||||||
| fi | ||||||
|
|
||||||
| failed=false | ||||||
|
|
||||||
| for commit in $commits; do | ||||||
| echo "Checking commit $commit" | ||||||
|
|
||||||
| # Get commit stats | ||||||
| files_changed=$(git diff-tree --no-commit-id --name-only -r $commit | wc -l) | ||||||
| lines_added=$(git diff-tree --no-commit-id --numstat -r $commit | awk '{sum+=$1} END {print sum}') | ||||||
| lines_deleted=$(git diff-tree --no-commit-id --numstat -r $commit | awk '{sum+=$2} END {print sum}') | ||||||
|
||||||
| lines_deleted=$(git diff-tree --no-commit-id --numstat -r $commit | awk '{sum+=$2} END {print sum}') | |
| lines_deleted=$(git diff-tree --no-commit-id --numstat -r $commit | awk '{sum+=$2} END {print sum+0}') |
Copilot
AI
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This arithmetic operation could fail if lines_added or lines_deleted are empty strings (when commits have no changes). The variables should be validated or defaulted to 0 before this calculation.
| total_lines=$((lines_added + lines_deleted)) | |
| total_lines=$(( ${lines_added:-0} + ${lines_deleted:-0} )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The awk command will output an empty string when there are no lines to sum, which could cause issues in arithmetic operations. Consider adding a default value:
awk '{sum+=$1} END {print sum+0}'to ensure it always outputs a number.