Copy edge E2E runner config in CI

This commit is contained in:
Jeppe Bundgaard
2026-04-24 21:11:08 +02:00
parent 15250ad227
commit 0253cfc676
4 changed files with 67 additions and 25 deletions
+5
View File
@@ -510,6 +510,10 @@ function closeSocket(socket) {
socket.close();
}
function shouldCopyGatewayConfig() {
return /^(1|true|yes)$/i.test(String(process.env.EDGE_GATEWAY_E2E_COPY_CONFIG || "").trim());
}
function collectMessages(rows) {
return Array.isArray(rows)
? rows
@@ -602,6 +606,7 @@ async function main() {
"--heartbeat-seconds",
"3",
"--skip-compose-up",
...(shouldCopyGatewayConfig() ? ["--copy-config"] : []),
], {
cwd: rootDir,
stdio: "inherit",
+44 -22
View File
@@ -56,6 +56,7 @@ Options:
--tail <lines> Log lines for the logs action. Default: 200
--skip-compose-up Do not start the local Docker Compose stack before start.
--skip-build Do not rebuild the test gateway image before start.
--copy-config Copy generated config into the container instead of bind mounting it.
`);
}
@@ -150,6 +151,7 @@ export function parseArgs(argv = process.argv.slice(2)) {
tail: "200",
skipComposeUp: false,
skipBuild: false,
copyConfig: false,
};
for (let index = 0; index < rest.length; index += 1) {
@@ -204,6 +206,9 @@ export function parseArgs(argv = process.argv.slice(2)) {
case "--skip-build":
options.skipBuild = true;
break;
case "--copy-config":
options.copyConfig = true;
break;
case "--help":
case "-h":
options.help = true;
@@ -361,35 +366,51 @@ async function startContainer({
containerName,
hostname,
configDir,
copyConfig,
}) {
const networkName = resolveComposeNetworkName(rootDir);
const mountedConfigDir = toDockerMountPath(configDir);
const containerConfigPath = copyConfig
? `/tmp/${DEFAULT_CONFIG_FILE_NAME}`
: `/config/${DEFAULT_CONFIG_FILE_NAME}`;
const createArgs = [
copyConfig ? "create" : "run",
...(copyConfig ? [] : ["-d"]),
"--name",
containerName,
"--hostname",
hostname,
"--restart",
"unless-stopped",
"--network",
networkName,
...(copyConfig ? [] : ["-v", `${mountedConfigDir}:/config`]),
imageTag,
"--config",
containerConfigPath,
];
await removeContainer(containerName);
await runCommand(
"docker",
[
"run",
"-d",
"--name",
containerName,
"--hostname",
hostname,
"--restart",
"unless-stopped",
"--network",
networkName,
"-v",
`${mountedConfigDir}:/config`,
imageTag,
"--config",
`/config/${DEFAULT_CONFIG_FILE_NAME}`,
],
{
await runCommand("docker", createArgs, {
cwd: rootDir,
stdio: "inherit",
});
if (copyConfig) {
await runCommand("docker", [
"cp",
path.join(configDir, DEFAULT_CONFIG_FILE_NAME),
`${containerName}:${containerConfigPath}`,
], {
cwd: rootDir,
stdio: "inherit",
}
);
});
await runCommand("docker", ["start", containerName], {
cwd: rootDir,
stdio: "inherit",
});
}
}
async function printStatus({ imageTag, configDir, containerName }) {
@@ -469,6 +490,7 @@ async function main() {
containerName: options.containerName,
hostname: options.hostname,
configDir,
copyConfig: options.copyConfig,
});
process.stdout.write(`Test gateway container started.
+6
View File
@@ -52,6 +52,12 @@ test("parseArgs accepts help without an explicit action", () => {
assert.equal(options.help, true);
});
test("parseArgs accepts copy config mode", () => {
const options = parseArgs(["start", "--copy-config"]);
assert.equal(options.copyConfig, true);
});
test("buildGatewayConfig applies defaults for a dockerized gateway", () => {
const config = buildGatewayConfig({});