-
-
Notifications
You must be signed in to change notification settings - Fork 753
241 lines (206 loc) · 7.15 KB
/
test.yml
File metadata and controls
241 lines (206 loc) · 7.15 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
name: Test
# Story 6.1: Specialized testing (security, build, integration, performance)
# Cross-platform compatibility testing moved to ci.yml
# NOTE: Only runs on push to main (PRs use ci.yml for validation)
on:
push:
branches: [main]
paths-ignore:
- 'docs/**'
- '*.md'
- '.aios/**'
- 'squads/**'
workflow_dispatch:
concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: '20'
jobs:
# NOTE: Lint job removed (Story 6.1) - handled by ci.yml
security-audit:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run security audit
run: |
npm audit --audit-level=moderate || echo "Security audit completed with warnings"
- name: Run penetration test
run: |
if [ -f "security/penetration-test.js" ]; then
cd security
node penetration-test.js
else
echo "Penetration test not found, skipping"
fi
build-test:
runs-on: ubuntu-latest
strategy:
matrix:
package: [core, memory, security, performance, telemetry, workspace]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build packages
run: npm run build:packages
- name: Test package build
run: |
PACKAGE="${{ matrix.package }}"
case "$PACKAGE" in
"workspace")
PKG_DIR="."
PKG_NAME="@synkra/aios-core"
;;
"core")
PKG_DIR=".aios-core"
PKG_NAME="@synkra/aios-core/core"
;;
*)
PKG_DIR="$PACKAGE"
PKG_NAME="@synkra/aios-core/$PACKAGE"
;;
esac
echo "Testing package: $PKG_NAME in directory: $PKG_DIR"
# Check if package.json exists
if [ -f "$PKG_DIR/package.json" ]; then
echo "✅ package.json exists"
# Check if entry points exist
if [ -f "$PKG_DIR/index.js" ]; then
echo "✅ index.js exists"
else
echo "❌ index.js missing"
exit 1
fi
# Validate package.json
node -e "
const pkg = require('./$PKG_DIR/package.json');
if (pkg.name !== '$PKG_NAME') {
console.error('❌ Package name mismatch');
process.exit(1);
}
console.log('✅ Package validation passed');
"
else
echo "❌ package.json not found in $PKG_DIR"
exit 1
fi
integration-test:
runs-on: ubuntu-latest
needs: [security-audit, build-test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Test workspace integration
run: |
# Test that workspace can be required
node -e "
try {
const workspace = require('./index.js');
console.log('✅ Workspace module loaded successfully');
if (workspace.AIOS) {
console.log('✅ AIOS class available');
} else {
console.error('❌ AIOS class not found');
process.exit(1);
}
// Test health check
const aios = new workspace.AIOS();
const health = aios.healthCheck();
console.log('✅ Health check passed:', health);
} catch (error) {
console.error('❌ Workspace integration test failed:', error.message);
process.exit(1);
}
"
- name: Test individual packages
run: |
for pkg in .aios-core memory security performance telemetry; do
if [ -d "$pkg" ] && [ -f "$pkg/package.json" ]; then
echo "Testing package: $pkg"
node -e "
try {
const pkg = require('./$pkg');
console.log('✅ Package $pkg loaded successfully');
} catch (error) {
console.error('❌ Package $pkg failed to load:', error.message);
process.exit(1);
}
"
else
echo "Skipping $pkg - not found"
fi
done
performance-test:
runs-on: ubuntu-latest
needs: [build-test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run performance analysis
run: |
if [ -f "performance/run-critical-path-analysis.js" ]; then
cd performance
node run-critical-path-analysis.js
else
echo "Performance analysis not found, skipping"
fi
# NOTE: Cross-platform compatibility testing removed (Story 6.1)
# Now handled by ci.yml cross-platform job (only on main branch push)
summary:
runs-on: ubuntu-latest
needs: [security-audit, build-test, integration-test, performance-test]
if: always()
steps:
- name: Test Summary
run: |
echo "## 📊 Test Results Summary"
echo ""
echo "| Test Suite | Status |"
echo "|------------|--------|"
echo "| Security Audit | ${{ needs.security-audit.result == 'success' && '✅ Passed' || '❌ Failed' }} |"
echo "| Build Test | ${{ needs.build-test.result == 'success' && '✅ Passed' || '❌ Failed' }} |"
echo "| Integration Test | ${{ needs.integration-test.result == 'success' && '✅ Passed' || '❌ Failed' }} |"
echo "| Performance Test | ${{ needs.performance-test.result == 'success' && '✅ Passed' || '❌ Failed' }} |"
echo ""
echo "Note: Linting handled by ci.yml (Story 6.1)"
echo ""
# Overall status
if [ "${{ needs.security-audit.result }}" = "success" ] && \
[ "${{ needs.build-test.result }}" = "success" ] && \
[ "${{ needs.integration-test.result }}" = "success" ] && \
[ "${{ needs.performance-test.result }}" = "success" ]; then
echo "🎉 All critical tests passed!"
echo "✅ Ready for deployment"
else
echo "❌ Some tests failed - review before deploying"
exit 1
fi