Repository navigation
324 lines (274 loc) · 12.6 KB
/
Copy pathtest.bridge.yml
File metadata and controls
324 lines (274 loc) · 12.6 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
name: Bridge Tests
on:
push:
branches: [main, develop]
paths:
- 'axioms/**/*.fcm'
- '.bridge/**'
- 'actions/**'
tags-ignore:
- '**'
pull_request:
branches: [main, develop]
paths:
- 'axioms/**/*.fcm'
- '.bridge/**'
- 'actions/**'
jobs:
bridge-validation:
name: Bridge Architecture Validation
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global --add safe.directory /github/workspace
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml
- name: Run Bridge Test Harness
run: |
echo "=== Running Complete Bridge Test Suite ==="
python .bridge/test-harness.py --all
- name: Validate Architecture Purity
run: |
echo "=== Validating FCM Architecture Purity ==="
if [ -f .bridge/validator.py ]; then
python .bridge/validator.py
else
echo "Running shell-based validation..."
bash .bridge/validate.sh
fi
- name: Test Generated Actions Structure
run: |
echo "=== Testing Generated Action Structure ==="
# Check that all generated actions have required files
for action_dir in actions/core/*/; do
if [ -d "$action_dir" ]; then
action_name=$(basename "$action_dir")
echo "Checking action: $action_name"
# Check for required files
if [ ! -f "$action_dir/action.yml" ]; then
echo "❌ Missing action.yml in $action_name"
exit 1
fi
if [ ! -f "$action_dir/Dockerfile" ]; then
echo "❌ Missing Dockerfile in $action_name"
exit 1
fi
# Check for generation markers in generated actions
if [ -f "$action_dir/.bridge-sync" ]; then
echo "✅ $action_name has bridge sync file"
# Verify action.yml has generation header
if grep -q "# Generated from" "$action_dir/action.yml"; then
echo "✅ $action_name action.yml has generation header"
else
echo "❌ $action_name action.yml missing generation header"
exit 1
fi
else
echo "⚠️ $action_name appears to be manually created (no .bridge-sync)"
fi
echo ""
fi
done
- name: Test FCM-to-Action Generation
run: |
echo "=== Testing FCM-to-Action Generation ==="
# Test generation with minimal FCM
if [ -f .bridge/tests/fixtures/minimal.fcm ]; then
echo "Testing generation with minimal.fcm..."
if [ -f .bridge/generator.py ]; then
# Python-based generation
python .bridge/generator.py .bridge/tests/fixtures/minimal.fcm
else
# Shell-based generation
bash .bridge/generate.sh .bridge/tests/fixtures/minimal.fcm
fi
# Verify output
if [ -f actions/core/minimal/action.yml ]; then
echo "✅ Successfully generated action from minimal FCM"
else
echo "❌ Failed to generate action from minimal FCM"
exit 1
fi
else
echo "⚠️ Minimal test FCM not found, skipping generation test"
fi
- name: Verify GitHub Actions Compatibility
run: |
echo "=== Verifying GitHub Actions Compatibility ==="
# Check that all action.yml files are valid YAML
for action_yml in actions/core/*/action.yml; do
if [ -f "$action_yml" ]; then
action_name=$(basename "$(dirname "$action_yml")")
echo "Validating $action_name..."
# Basic YAML validation using Python
python -c "
import yaml
import sys
try:
with open('$action_yml', 'r') as f:
content = f.read()
# Skip header comments for YAML parsing
yaml_content = '\n'.join(line for line in content.split('\n') if not line.strip().startswith('#'))
config = yaml.safe_load(yaml_content)
# Check required GitHub Action fields
required_fields = ['name', 'runs']
missing = [field for field in required_fields if field not in config]
if missing:
print(f'❌ Missing required fields in $action_name: {missing}')
sys.exit(1)
# Check runs configuration
if 'using' not in config['runs']:
print(f'❌ Missing runs.using in $action_name')
sys.exit(1)
print(f'✅ $action_name is valid GitHub Action')
except Exception as e:
print(f'❌ Error validating $action_name: {e}')
sys.exit(1)
"
fi
done
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: bridge-test-results
path: |
.bridge/test-results.json
.bridge/validation-report.txt
retention-days: 30
- name: Comment Test Results
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
let comment = '## 🔗 Bridge Test Results\n\n';
try {
// Read test results if available
if (fs.existsSync('.bridge/test-results.json')) {
const results = JSON.parse(fs.readFileSync('.bridge/test-results.json', 'utf8'));
const summary = results.summary;
comment += `### Test Summary\n`;
comment += `- **Total Tests**: ${summary.total}\n`;
comment += `- **Passed**: ${summary.passed} ✅\n`;
comment += `- **Failed**: ${summary.failed} ${summary.failed > 0 ? '❌' : ''}\n`;
comment += `- **Skipped**: ${summary.skipped} ⏭️\n`;
const successRate = summary.total > 0 ? (summary.passed / summary.total * 100).toFixed(1) : 0;
comment += `- **Success Rate**: ${successRate}%\n\n`;
if (summary.failed > 0) {
comment += `### Failed Tests\n`;
const failedTests = results.tests.filter(t => t.status === 'failed');
failedTests.forEach(test => {
comment += `- ❌ **${test.name}**: ${test.message}\n`;
});
comment += '\n';
}
} else {
comment += 'Test results file not found.\n\n';
}
} catch (error) {
comment += `Error reading test results: ${error.message}\n\n`;
}
comment += `### Architecture Status\n`;
comment += `- FCM Definitions: \`axioms/\`\n`;
comment += `- Generated Actions: \`actions/core/\`\n`;
comment += `- Bridge Infrastructure: \`.bridge/\`\n\n`;
comment += `For detailed results, check the workflow artifacts.`;
// Post comment
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
action-tests:
name: Test Generated Actions
runs-on: ubuntu-latest
needs: bridge-validation
if: success()
steps:
- name: Checkout Repository
uses: actions/checkout@v7
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global --add safe.directory /github/workspace
- name: Test Tag Operations Action
run: |
echo "=== Testing Tag Operations Action ==="
# Test the generated tag-operations action if it exists
if [ -d "actions/core/tag-operations" ]; then
echo "Found generated tag-operations action"
# For now, just verify the structure since we can't run Docker in this context
echo "Verifying action structure..."
if [ -f "actions/core/tag-operations/action.yml" ] && \
[ -f "actions/core/tag-operations/Dockerfile" ] && \
[ -f "actions/core/tag-operations/entrypoint.sh" ]; then
echo "✅ Tag operations action has complete structure"
else
echo "❌ Tag operations action missing required files"
exit 1
fi
else
echo "⚠️ Generated tag-operations action not found"
fi
- name: Validate Action Inputs/Outputs
run: |
echo "=== Validating Action Interfaces ==="
# Check that generated actions have sensible inputs/outputs
for action_dir in actions/core/*/; do
if [ -f "$action_dir/action.yml" ] && [ -f "$action_dir/.bridge-sync" ]; then
action_name=$(basename "$action_dir")
echo "Checking interface for $action_name..."
# Use Python to parse and validate the action interface
python -c "
import yaml
import sys
try:
with open('$action_dir/action.yml', 'r') as f:
content = f.read()
# Skip header comments
yaml_content = '\n'.join(line for line in content.split('\n') if not line.strip().startswith('#'))
config = yaml.safe_load(yaml_content)
# Validate inputs
inputs = config.get('inputs', {})
if not inputs:
print(f'⚠️ $action_name has no inputs')
else:
for input_name, input_config in inputs.items():
if 'description' not in input_config:
print(f'❌ $action_name input {input_name} missing description')
sys.exit(1)
if 'required' not in input_config:
print(f'❌ $action_name input {input_name} missing required field')
sys.exit(1)
print(f'✅ $action_name has {len(inputs)} valid inputs')
# Validate outputs
outputs = config.get('outputs', {})
if outputs:
for output_name, output_config in outputs.items():
if 'description' not in output_config:
print(f'❌ $action_name output {output_name} missing description')
sys.exit(1)
print(f'✅ $action_name has {len(outputs)} valid outputs')
except Exception as e:
print(f'❌ Error validating $action_name interface: {e}')
sys.exit(1)
"
fi
done