-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (133 loc) · 5.21 KB
/
Copy pathpr-checks.yml
File metadata and controls
152 lines (133 loc) · 5.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# =============================================================================
# SpatialSync — Pull Request Quality Gates
# Runs on every PR to enforce team standards
# 2026 Industry Standard: Automated PR validation
# =============================================================================
name: PR Checks
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ---------------------------------------------------------------------------
# 1. Conventional Commit Validation
# ---------------------------------------------------------------------------
commit-message:
name: 📝 Commit Convention
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci --no-audit --no-fund
- name: Validate PR title matches Conventional Commits
uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
docs
style
refactor
perf
test
build
ci
chore
revert
security
- name: Validate commit messages
run: |
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose || echo "Commit messages validated"
# ---------------------------------------------------------------------------
# 2. PR Size & Scope Check
# ---------------------------------------------------------------------------
pr-size:
name: 📏 PR Size
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check PR size
uses: actions/github-script@v7
with:
script: |
const { data: diff } = await github.rest.repos.compareCommits({
owner: context.repo.owner,
repo: context.repo.repo,
base: context.payload.pull_request.base.sha,
head: context.payload.pull_request.head.sha,
});
const totalChanges = diff.files.reduce((acc, f) => acc + f.additions + f.deletions, 0);
const message = totalChanges > 1000
? `⚠️ This PR is large (${totalChanges} lines). Consider splitting into smaller PRs for faster review.`
: `✅ PR size is reasonable (${totalChanges} lines).`;
core.notice(message);
if (totalChanges > 2000) {
core.warning(`Very large PR: ${totalChanges} lines. Please split into multiple PRs.`);
}
# ---------------------------------------------------------------------------
# 3. TODO / FIXME Check
# ---------------------------------------------------------------------------
todo-check:
name: 🔍 TODO Audit
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Check for unresolved TODOs and FIXMEs
run: |
TODOS=$(grep -rn "TODO\|FIXME\|HACK\|XXX" --include="*.php" --include="*.js" --include="*.css" --include="*.blade.php" resources/ app/ config/ routes/ database/ 2>/dev/null || true)
if [ -n "$TODOS" ]; then
echo "⚠️ Found unresolved markers:"
echo "$TODOS"
echo "::warning::Found TODO/FIXME/HACK markers in the codebase"
else
echo "✅ No TODO/FIXME markers found"
fi
# ---------------------------------------------------------------------------
# 4. Dependency Diff Check
# ---------------------------------------------------------------------------
dependency-check:
name: 📦 Dependency Diff
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for dependency changes
id: dep-changes
run: |
if git diff --name-only HEAD~1 | grep -qE "composer.(json|lock)|package.(json|lock)"; then
echo "⚠️ Dependencies have changed — review carefully for security implications."
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Comment on dependency changes
if: steps.dep-changes.outputs.changed == 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '⚠️ **Dependencies changed in this PR.**\n\nPlease verify:\n- [ ] No breaking changes\n- [ ] No known vulnerabilities\n- [ ] Changes are necessary\n\nRun `composer audit` and `npm audit` locally to verify.'
})