relayrunner 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +49 -7
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -54,7 +54,11 @@ const HelloMessage = z.object({
54
54
  isolated: z.object({
55
55
  os,
56
56
  arch: arch$1
57
- }).optional()
57
+ }).optional(),
58
+ vm: z.object({
59
+ cpus: z.number().int().positive().max(1e4),
60
+ memoryGb: z.number().int().positive().max(1e5)
61
+ }).optional().catch(void 0)
58
62
  });
59
63
  const StatusMessage = z.object({
60
64
  v: version$1,
@@ -170,7 +174,7 @@ function parse(version) {
170
174
  ] : null;
171
175
  }
172
176
  // version.ts
173
- const cliVersion = "0.9.0";
177
+ const cliVersion = "0.9.2";
174
178
  // paths.ts
175
179
  function relayrunnerHome() {
176
180
  return resolve(process.env.RELAYRUNNER_HOME || join(homedir(), ".relayrunner"));
@@ -1307,6 +1311,21 @@ function vmSize(slots, wanted = {}, cores = availableParallelism(), memoryBytes
1307
1311
  memoryGb: wanted.memoryGb ?? Math.min(16, Math.max(2, Math.floor(gb / 2 / slots)))
1308
1312
  };
1309
1313
  }
1314
+ const NO_DNS = 3;
1315
+ const DNS_CHECK = `for try in 1 2 3 4 5; do
1316
+ RES_OPTIONS="timeout:1 attempts:1" getent ahostsv4 github.com >/dev/null && exit 0
1317
+ done
1318
+ exit ${NO_DNS}`;
1319
+ const DNS_FAILURE = /Temporary failure resolving|Could not resolve host|Name or service not known/;
1320
+ function dnsMessage(base) {
1321
+ return `Linux VMs on this Mac can't look up hostnames, though the Mac itself can.
1322
+ VPN or DNS filtering software often causes this, even when it's disconnected or its app is closed. Quit it fully, then run \`relayrunner connect\` again.
1323
+
1324
+ To check, this should print an address:
1325
+ container run --rm ${base} getent ahostsv4 github.com
1326
+
1327
+ To run jobs on the Mac without VMs for now, use \`relayrunner connect --no-isolated\`.`;
1328
+ }
1310
1329
  async function prepareIsolation(options) {
1311
1330
  const command = options.command ?? "container";
1312
1331
  const log = options.log ?? (() => {});
@@ -1336,6 +1355,15 @@ async function prepareIsolation(options) {
1336
1355
  ]) !== 0) throw fail("ISOLATED_IMAGE", `Could not download ${base}.`);
1337
1356
  if (!options.image) mine.push(base);
1338
1357
  }
1358
+ const noDns = () => fail("ISOLATED_DNS", dnsMessage(base));
1359
+ if (await tool([
1360
+ "run",
1361
+ "--rm",
1362
+ base,
1363
+ "sh",
1364
+ "-c",
1365
+ DNS_CHECK
1366
+ ]) === NO_DNS) throw noDns();
1339
1367
  const image = jobImage(base, !options.image);
1340
1368
  mine.push(image);
1341
1369
  if (!await hasImage(image)) {
@@ -1344,14 +1372,16 @@ async function prepareIsolation(options) {
1344
1372
  try {
1345
1373
  writeFileSync(join(context, "Dockerfile"), dockerfile(base, !options.image));
1346
1374
  writeFileSync(join(context, "start.sh"), START_SCRIPT);
1347
- if (await tool([
1375
+ const build = await capture(command, [
1348
1376
  "build",
1349
1377
  "--progress",
1350
1378
  "plain",
1351
1379
  "--tag",
1352
1380
  image,
1353
1381
  context
1354
- ]) !== 0) throw fail("ISOLATED_IMAGE", `Could not build the job image from ${base}.`);
1382
+ ], debug);
1383
+ if (build.code !== 0 && DNS_FAILURE.test(build.output)) throw noDns();
1384
+ if (build.code !== 0) throw fail("ISOLATED_IMAGE", `Could not build the job image from ${base}.`);
1355
1385
  } finally {
1356
1386
  rmSync(context, {
1357
1387
  recursive: true,
@@ -1453,7 +1483,10 @@ function isolatedLauncher(isolation) {
1453
1483
  }
1454
1484
  };
1455
1485
  }
1456
- function call(command, args, debug, quiet = false) {
1486
+ async function call(command, args, debug, quiet = false) {
1487
+ return (await capture(command, args, debug, quiet)).code;
1488
+ }
1489
+ function capture(command, args, debug, quiet = false) {
1457
1490
  return new Promise((resolve) => {
1458
1491
  const child = spawn(command, args, { stdio: [
1459
1492
  "ignore",
@@ -1468,7 +1501,10 @@ function call(command, args, debug, quiet = false) {
1468
1501
  child.stderr.on("data", keep);
1469
1502
  const done = (code, extra = "") => {
1470
1503
  debug.write(`$ ${command} ${args.join(" ")}\n${output}${extra}exit ${code}`);
1471
- resolve(code);
1504
+ resolve({
1505
+ code,
1506
+ output
1507
+ });
1472
1508
  };
1473
1509
  child.once("error", (error) => done(null, `${error.message}\n`));
1474
1510
  child.once("close", (code) => done(code));
@@ -3291,6 +3327,7 @@ async function connectMachine(args) {
3291
3327
  let launchers = [];
3292
3328
  let vmLauncher;
3293
3329
  let isolatedOnly;
3330
+ let vmSize;
3294
3331
  if (isolated) {
3295
3332
  const firewall = firewallInstalled();
3296
3333
  if (firewall) log(args["local-network"] ? "The firewall on this Mac is on, so --local-network has no effect. Turn it off with `relayrunner firewall off`." : "The firewall on this Mac is on.");
@@ -3303,6 +3340,10 @@ async function connectMachine(args) {
3303
3340
  debug: debugLog()
3304
3341
  });
3305
3342
  runnerVersion = isolation.runnerVersion;
3343
+ vmSize = {
3344
+ cpus: isolation.cpus,
3345
+ memoryGb: isolation.memoryGb
3346
+ };
3306
3347
  const launcher = isolatedLauncher(isolation);
3307
3348
  if (args.macos) vmLauncher = launcher;
3308
3349
  else {
@@ -3353,7 +3394,8 @@ async function connectMachine(args) {
3353
3394
  ...platform,
3354
3395
  runnerVersion,
3355
3396
  cliVersion,
3356
- device
3397
+ device,
3398
+ ...vmSize && { vm: vmSize }
3357
3399
  },
3358
3400
  slots,
3359
3401
  runJob: async (run, slot, report) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relayrunner",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Run GitHub Actions jobs on your machine through the RelayRunner gateway.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {