-
Notifications
You must be signed in to change notification settings - Fork 236
Expand file tree
/
Copy pathcreate-community-worlds-matrix.mjs
More file actions
72 lines (62 loc) · 1.98 KB
/
create-community-worlds-matrix.mjs
File metadata and controls
72 lines (62 loc) · 1.98 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
#!/usr/bin/env node
/**
* Generates a GitHub Actions matrix for community world testing.
* Reads from worlds-manifest.json and filters to testable community worlds.
*
* Usage: node scripts/create-community-worlds-matrix.mjs
*
* Output format (JSON):
* {
* "world": [
* {
* "id": "starter",
* "name": "Starter",
* "package": "@workflow-worlds/starter",
* "service-type": "none",
* "env-vars": "{\"WORKFLOW_TARGET_WORLD\":\"@workflow-worlds/starter\"}"
* },
* ...
* ]
* }
*/
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.join(__dirname, '..');
// Read the manifest
const manifestPath = path.join(rootDir, 'worlds-manifest.json');
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
// Filter to community worlds that can be tested in CI
const testableWorlds = manifest.worlds.filter((world) => {
// Only community worlds
if (world.type !== 'community') return false;
// Skip worlds that require external credentials (e.g., Jazz needs API keys)
if (world.requiresCredentials) return false;
return true;
});
// Build the matrix
const matrix = {
world: testableWorlds.map((world) => {
// Determine service type based on services array
let serviceType = 'none';
if (world.services && world.services.length > 0) {
// Use the first service's name as the service type
// Currently supports: mongodb, redis, surrealdb
const serviceName = world.services[0].name;
if (['mongodb', 'redis', 'surrealdb'].includes(serviceName)) {
serviceType = serviceName;
}
}
return {
id: world.id,
name: world.name,
package: world.package,
'service-type': serviceType,
'env-vars': JSON.stringify(world.env || {}),
'setup-command': world.setup || '',
};
}),
};
// Output JSON for GitHub Actions
console.log(JSON.stringify(matrix));