-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-justfile.js
More file actions
109 lines (93 loc) · 2.87 KB
/
generate-justfile.js
File metadata and controls
109 lines (93 loc) · 2.87 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
const fs = require("node:fs");
const {
webapps,
backends,
e2eRunners,
systemtestRunners,
dbs,
} = require("./components.json");
const makeJustE2ETestTasks = ({ frontend, backend, runner, db }) => `
ci-${runner}-${frontend}-${backend}-${db}:
COMPOSE_PROJECT_NAME="kadai-${runner}-${frontend}-${backend}-${db}" docker compose \\
--profile e2e \\
-f compose.frontend-${frontend}.yaml \\
-f compose.backend-${backend}.yaml \\
-f compose.db-${db}.yaml \\
-f compose.e2e-${runner}.yaml \\
-f compose.ci.yaml \\
up --no-build --exit-code-from e2e
test-${runner}-${frontend}-${backend}-${db}:
COMPOSE_PROJECT_NAME="kadai-${runner}-${frontend}-${backend}-${db}" docker compose \\
-f compose.frontend-${frontend}.yaml \\
-f compose.backend-${backend}.yaml \\
-f compose.db-${db}.yaml \\
-f compose.e2e-${runner}.yaml \\
up --build --exit-code-from e2e
`;
const makeJustSystemTestTasks = ({ backend, runner, db }) => `
ci-${runner}-${backend}-${db}:
COMPOSE_PROJECT_NAME="kadai-${runner}-${backend}-${db}" docker compose \\
--profile system \\
-f compose.backend-${backend}.yaml \\
-f compose.db-${db}.yaml \\
-f compose.system-${runner}.yaml \\
-f compose.ci.yaml \\
up --no-build --exit-code-from system
test-${runner}-${backend}-${db}:
COMPOSE_PROJECT_NAME="kadai-${runner}-${backend}-${db}" docker compose \\
-f compose.backend-${backend}.yaml \\
-f compose.db-${db}.yaml \\
-f compose.system-${runner}.yaml \\
up --build --exit-code-from system
`;
const makeJustStartTasks = ({ frontend, backend, db }) => `
start-${frontend}-${backend}-${db}:
COMPOSE_PROJECT_NAME="kadai-${frontend}-${backend}-${db}" docker compose \\
-f compose.frontend-${frontend}.yaml \\
-f compose.backend-${backend}.yaml \\
-f compose.db-${db}.yaml \\
-f compose.expose-ports.yaml \\
up --build
`;
const apiCombinations = backends.flatMap((b) =>
dbs.flatMap((db) => ({
backend: b.id,
db: db.id,
}))
);
const appCombinations = webapps.flatMap((f) =>
apiCombinations.map((combination) => ({
...combination,
frontend: f.id,
}))
);
const systemTestsCombinations = apiCombinations.flatMap((a) =>
systemtestRunners.flatMap((r) => ({
...a,
runner: r.id,
}))
);
const e2eTestsCombinations = appCombinations.flatMap((a) =>
e2eRunners.flatMap((r) => ({
...a,
runner: r.id,
}))
);
const contents =
`
unit-test:
@echo "No unit tests found"
` +
appCombinations.reduce(
(contents, combination) => contents + makeJustStartTasks(combination),
""
) +
e2eTestsCombinations.reduce(
(contents, combination) => contents + makeJustE2ETestTasks(combination),
""
) +
systemTestsCombinations.reduce(
(contents, combination) => contents + makeJustSystemTestTasks(combination),
""
);
fs.writeFileSync("justfile", contents);