forked from Rezmason/matrix
-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (146 loc) · 5.41 KB
/
Copy pathmaster-branch-protection.yml
File metadata and controls
178 lines (146 loc) · 5.41 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Master Branch Protection
# This workflow provides status checks for pull requests targeting the master branch
# It serves as a branch protection mechanism by ensuring code quality before merging
on:
pull_request:
branches: [ master, main ]
push:
branches: [ master, main ]
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
validate-matrix:
name: Validate Matrix Application
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '18'
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Validate code formatting with Prettier
run: |
echo "Checking code formatting..."
npx prettier --check --use-tabs --print-width 160 "index.html" "./js/**/*.js" "./lib/gpu-buffer.js" "./scripts/**/*.mjs" "./tests/**/*.js" || {
echo "❌ Code formatting check failed!"
echo "Run: npx prettier --write --use-tabs --print-width 160 \"index.html\" \"./js/**/*.js\" \"./lib/gpu-buffer.js\" \"./scripts/**/*.mjs\" \"./tests/**/*.js\""
exit 1
}
echo "✅ Code formatting is correct"
- name: Install dependencies and run automated tests
run: |
npm ci
npx playwright install --with-deps chromium
npm test
- name: Start Matrix application server
run: |
echo "Starting Matrix application server..."
python3 -m http.server 8000 &
SERVER_PID=$!
echo "SERVER_PID=$SERVER_PID" >> $GITHUB_ENV
# Wait for server to start
sleep 3
- name: Test Matrix application endpoints
run: |
echo "Testing Matrix application endpoints..."
# Test main page loads
if curl -f -s "http://localhost:8000/" > /dev/null; then
echo "✅ Main page loads successfully"
else
echo "❌ Main page failed to load"
exit 1
fi
# Test with suppressWarnings parameter
if curl -f -s "http://localhost:8000/?suppressWarnings=true" > /dev/null; then
echo "✅ Page with suppressWarnings loads successfully"
else
echo "❌ Page with suppressWarnings failed to load"
exit 1
fi
# Test version parameter
if curl -f -s "http://localhost:8000/?version=classic&suppressWarnings=true" > /dev/null; then
echo "✅ Classic version loads successfully"
else
echo "❌ Classic version failed to load"
exit 1
fi
# Test effect parameter with new neutral naming
if curl -f -s "http://localhost:8000/?effect=rainbow&suppressWarnings=true" > /dev/null; then
echo "✅ Rainbow effect loads successfully"
else
echo "❌ Rainbow effect failed to load"
exit 1
fi
# Test backward compatibility with legacy effect names
if curl -f -s "http://localhost:8000/?effect=pride&suppressWarnings=true" > /dev/null; then
echo "✅ Legacy pride effect (backward compatibility) loads successfully"
else
echo "❌ Legacy pride effect (backward compatibility) failed to load"
exit 1
fi
echo "✅ All endpoint tests passed"
- name: Validate JavaScript modules
run: |
echo "Validating JavaScript modules..."
# Check if main JavaScript files exist and are valid
if [ ! -f "js/main.js" ]; then
echo "❌ Main JavaScript file missing"
exit 1
fi
if [ ! -f "js/config.js" ]; then
echo "❌ Config JavaScript file missing"
exit 1
fi
node --check js/main.js
node --check js/config.js
node --check js/effects.js
node --check js/webgl/stripePass.js
node --check js/webgpu/stripePass.js
echo "✅ JavaScript modules are valid"
- name: Validate HTML structure
run: |
echo "Validating HTML structure..."
if [ ! -f "index.html" ]; then
echo "❌ index.html is missing"
exit 1
fi
# Check for required elements (case-insensitive)
if ! grep -iq "<!doctype html>" index.html; then
echo "❌ Missing DOCTYPE declaration"
exit 1
fi
# Check for canvas creation in JavaScript (dynamically created)
if ! grep -q "createElement.*canvas\|canvas.*createElement" js/main.js; then
echo "❌ Missing canvas creation in JavaScript"
exit 1
fi
echo "✅ HTML structure is valid"
- name: Cleanup
if: always()
run: |
if [ ! -z "$SERVER_PID" ]; then
kill $SERVER_PID || true
fi
security-scan:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@v0.35.0
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: 'trivy-results.sarif'