lim 0.16.3 → 0.16.4

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.
@@ -1,4 +1,4 @@
1
- import { BaseCommand } from '../../base-command';
1
+ import { BaseCommand } from '../../../base-command';
2
2
  export default class XcodeRbe extends BaseCommand {
3
3
  static summary: string;
4
4
  static description: string;
@@ -8,6 +8,8 @@ export default class XcodeRbe extends BaseCommand {
8
8
  port: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
9
9
  daemon: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
10
  stop: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ 'auto-upload': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ 'upload-ttl': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
13
  ios: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
14
  serve: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
15
  'api-key': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
@@ -63,10 +65,12 @@ export default class XcodeRbe extends BaseCommand {
63
65
  /**
64
66
  * Block on an already-open tunnel until a stop signal, then close it and
65
67
  * best-effort stop the remote stack. Rejects if the tunnel reports a terminal
66
- * disconnect (after its own reconnect attempts are exhausted).
68
+ * disconnect (after its own reconnect attempts are exhausted). With
69
+ * autoUpload set, a watcher uploads every successful build as the named
70
+ * asset for the tunnel's lifetime.
67
71
  */
68
72
  private awaitTunnel;
69
73
  /** Print the ready banner (or JSON) for both foreground and background modes. */
70
74
  private printReady;
71
75
  }
72
- //# sourceMappingURL=rbe.d.ts.map
76
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/xcode/rbe/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAcpD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,WAAW;IAC/C,MAAM,CAAC,OAAO,SAAqF;IACnG,MAAM,CAAC,WAAW,SAKwE;IAC1F,MAAM,CAAC,QAAQ,WAMb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;;;;;MAyCV;IAEF,OAAO,CAAC,QAAQ,CAAyD;IAEnE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IA8Q1B;;;;OAIG;YACW,oBAAoB;IAsElC;;;;;OAKG;YACW,wBAAwB;IAWtC;;;;;;;;;;OAUG;YACW,SAAS;IAUvB;;;OAGG;YACW,qBAAqB;IAoGnC,sDAAsD;YACxC,UAAU;IAOxB;;;;;;;;OAQG;YACW,SAAS;IAiBvB;;;;;;OAMG;YACW,WAAW;IAyEzB,iFAAiF;IACjF,OAAO,CAAC,UAAU;CA0DnB"}
@@ -8,11 +8,11 @@ const path_1 = __importDefault(require("path"));
8
8
  const child_process_1 = require("child_process");
9
9
  const core_1 = require("@oclif/core");
10
10
  const api_1 = require("@limrun/api");
11
- const base_command_1 = require("../../base-command");
12
- const config_1 = require("../../lib/config");
13
- const progress_1 = require("../../lib/progress");
14
- const rbe_workspace_1 = require("../../lib/rbe-workspace");
15
- const rbe_session_1 = require("../../lib/rbe-session");
11
+ const base_command_1 = require("../../../base-command");
12
+ const config_1 = require("../../../lib/config");
13
+ const progress_1 = require("../../../lib/progress");
14
+ const rbe_auto_upload_1 = require("../../../lib/rbe-auto-upload");
15
+ const rbe_session_1 = require("../../../lib/rbe-session");
16
16
  class XcodeRbe extends base_command_1.BaseCommand {
17
17
  constructor() {
18
18
  super(...arguments);
@@ -21,6 +21,14 @@ class XcodeRbe extends base_command_1.BaseCommand {
21
21
  async run() {
22
22
  const { flags } = await this.parse(XcodeRbe);
23
23
  this.setParsedFlags(flags);
24
+ // Empty string would be treated as "off" by every truthiness check below,
25
+ // silently starting a tunnel without the uploads the user asked for.
26
+ // Checked before the serve branch so a hand-invoked serve child cannot
27
+ // slip past it either.
28
+ if (flags['auto-upload'] !== undefined && !flags['auto-upload']) {
29
+ this.error('--auto-upload requires a non-empty asset name.');
30
+ }
31
+ const autoUpload = flags['auto-upload'] ? { assetName: flags['auto-upload'], ttl: flags['upload-ttl'] } : undefined;
24
32
  // Serve mode: the detached child. The parent already started the stack and
25
33
  // generated the workspace config; this process only holds the tunnel and
26
34
  // tears the stack down on exit. Requires --id (the parent always passes it).
@@ -36,7 +44,7 @@ class XcodeRbe extends base_command_1.BaseCommand {
36
44
  await this.withAuth(async () => {
37
45
  const xcodeTarget = await this.resolveXcodeTarget(flags.id);
38
46
  const client = await this.resolveXcodeClient(xcodeTarget);
39
- await this.runTunnel(client, flags.port);
47
+ await this.runTunnel(client, flags.port, autoUpload);
40
48
  });
41
49
  return;
42
50
  }
@@ -44,7 +52,7 @@ class XcodeRbe extends base_command_1.BaseCommand {
44
52
  // `.limrun/` and the try-import must live at the workspace root, and failing
45
53
  // here avoids creating an instance when run outside a workspace. Walk up
46
54
  // like Bazel does, so the command works from any subdirectory.
47
- const workspaceRoot = (0, rbe_workspace_1.findBazelWorkspaceRoot)(process.cwd());
55
+ const workspaceRoot = (0, api_1.findBazelWorkspaceRoot)(process.cwd());
48
56
  if (!workspaceRoot) {
49
57
  this.error('Not inside a Bazel workspace. Run `lim xcode rbe` from within the workspace you want ' +
50
58
  'to build (a directory tree containing MODULE.bazel, WORKSPACE, or WORKSPACE.bazel).');
@@ -57,8 +65,20 @@ class XcodeRbe extends base_command_1.BaseCommand {
57
65
  // second one (and don't fail with a cryptic "port in use"); point at --stop.
58
66
  const existing = (0, rbe_session_1.readRbePidFile)(workspaceRoot);
59
67
  if (existing && (0, rbe_session_1.isProcessAlive)(existing.pid)) {
60
- this.info(`A background tunnel is already running for this workspace (PID ${existing.pid}, ` +
61
- `grpc://127.0.0.1:${existing.port}).`);
68
+ const running = `A background tunnel is already running for this workspace (PID ${existing.pid}, ` +
69
+ `grpc://127.0.0.1:${existing.port}` +
70
+ `${existing.autoUpload ? `, auto-uploading to "${existing.autoUpload}"` : ''}).`;
71
+ // A requested auto-upload config cannot be applied to a running tunnel;
72
+ // a silent success here would let CI believe uploads are armed (or the
73
+ // ttl changed) and ship a stale or early-expiring preview asset. An
74
+ // omitted --upload-ttl is not a conflict: it means keep the running ttl.
75
+ if (flags['auto-upload'] &&
76
+ (existing.autoUpload !== flags['auto-upload'] ||
77
+ (flags['upload-ttl'] !== undefined && existing.uploadTtl !== flags['upload-ttl']))) {
78
+ this.error(`${running} The requested --auto-upload config was NOT applied. ` +
79
+ 'Stop it with `lim xcode rbe --stop` and re-run.');
80
+ }
81
+ this.info(running);
62
82
  this.info('Stop it with `lim xcode rbe --stop`, then re-run to start fresh.');
63
83
  return;
64
84
  }
@@ -112,10 +132,10 @@ class XcodeRbe extends base_command_1.BaseCommand {
112
132
  // so we never leak a running stack with no client attached.
113
133
  this.reporter.start('Starting remote build execution');
114
134
  try {
115
- const initial = await (0, rbe_session_1.retryTransient)(() => client.startRbe(), {
135
+ const initial = await (0, api_1.retryTransient)(() => client.startRbe(), {
116
136
  log: (m) => this.reporter.appendLog(m),
117
137
  });
118
- const status = await (0, rbe_session_1.waitForRbeRunning)(client, initial);
138
+ const status = await (0, api_1.waitForRbeRunning)(client, initial);
119
139
  xcodeVersion = status.xcodeVersion;
120
140
  this.reporter.stop('success', `Remote build execution ready (Xcode ${xcodeVersion})`);
121
141
  break;
@@ -147,7 +167,7 @@ class XcodeRbe extends base_command_1.BaseCommand {
147
167
  }
148
168
  let generated;
149
169
  try {
150
- generated = (0, rbe_workspace_1.writeRbeWorkspaceFiles)(workspaceRoot, xcodeVersion, flags.port);
170
+ generated = (0, api_1.writeRbeWorkspaceFiles)(workspaceRoot, xcodeVersion, flags.port);
151
171
  }
152
172
  catch (err) {
153
173
  await client.stopRbe().catch(() => { });
@@ -161,7 +181,7 @@ class XcodeRbe extends base_command_1.BaseCommand {
161
181
  // builds if put in .bazelrc), hence it precedes `build` in the command.
162
182
  // Infer a real app target so the printed command is runnable as-is; fall
163
183
  // back to a placeholder when there's no single obvious target.
164
- const inferredTarget = (0, rbe_workspace_1.inferBuildTarget)(workspaceRoot);
184
+ const inferredTarget = (0, api_1.inferBuildTarget)(workspaceRoot);
165
185
  const target = inferredTarget ?? '//your:target';
166
186
  const buildCmd = `bazelisk --digest_function=sha256 build --config=limrun ${target}`;
167
187
  // --ios: create + attach a simulator so builds auto-install on it (server-side)
@@ -191,6 +211,8 @@ class XcodeRbe extends base_command_1.BaseCommand {
191
211
  xcodeVersion,
192
212
  generated,
193
213
  buildCmd,
214
+ autoUpload: flags['auto-upload'],
215
+ uploadTtl: flags['upload-ttl'],
194
216
  });
195
217
  }
196
218
  catch (err) {
@@ -226,9 +248,10 @@ class XcodeRbe extends base_command_1.BaseCommand {
226
248
  instanceId,
227
249
  background: false,
228
250
  simulatorAttached: !!simInstanceId,
251
+ autoUpload: flags['auto-upload'],
229
252
  });
230
253
  try {
231
- await this.awaitTunnel(tunnel, client);
254
+ await this.awaitTunnel(tunnel, client, autoUpload);
232
255
  }
233
256
  finally {
234
257
  await this.deleteSim(simInstanceId);
@@ -268,7 +291,7 @@ class XcodeRbe extends base_command_1.BaseCommand {
268
291
  const signalled = signalIfAlive(info.pid, 'SIGTERM');
269
292
  if (signalled) {
270
293
  for (let i = 0; i < 300 && (0, rbe_session_1.isProcessAlive)(info.pid); i++) {
271
- await (0, rbe_session_1.defaultSleep)(100); // up to ~30s for graceful teardown
294
+ await (0, api_1.defaultSleep)(100); // up to ~30s for graceful teardown
272
295
  }
273
296
  }
274
297
  // Escalate to SIGKILL if it's wedged (e.g. stuck stopping the remote stack),
@@ -277,7 +300,7 @@ class XcodeRbe extends base_command_1.BaseCommand {
277
300
  if ((0, rbe_session_1.isProcessAlive)(info.pid)) {
278
301
  forced = signalIfAlive(info.pid, 'SIGKILL');
279
302
  for (let i = 0; i < 20 && (0, rbe_session_1.isProcessAlive)(info.pid); i++) {
280
- await (0, rbe_session_1.defaultSleep)(100); // up to ~2s
303
+ await (0, api_1.defaultSleep)(100); // up to ~2s
281
304
  }
282
305
  }
283
306
  // Only drop the pidfile once the process is actually gone — otherwise a
@@ -350,7 +373,7 @@ class XcodeRbe extends base_command_1.BaseCommand {
350
373
  */
351
374
  async spawnBackgroundTunnel(opts) {
352
375
  const apiKey = this.parsedFlags?.['api-key'];
353
- const logPath = path_1.default.join(opts.workspaceRoot, rbe_workspace_1.LIMRUN_DIR, 'rbe.log');
376
+ const logPath = path_1.default.join(opts.workspaceRoot, api_1.LIMRUN_DIR, 'rbe.log');
354
377
  this.reporter.start('Starting background tunnel');
355
378
  const logFd = fs_1.default.openSync(logPath, 'w');
356
379
  const child = (0, child_process_1.spawn)(process.execPath, (0, rbe_session_1.buildServeChildArgs)({
@@ -358,6 +381,8 @@ class XcodeRbe extends base_command_1.BaseCommand {
358
381
  id: opts.instanceId,
359
382
  port: opts.port,
360
383
  apiKey,
384
+ autoUpload: opts.autoUpload,
385
+ uploadTtl: opts.uploadTtl,
361
386
  }), { detached: true, stdio: ['ignore', logFd, logFd] });
362
387
  fs_1.default.closeSync(logFd);
363
388
  child.unref();
@@ -383,7 +408,7 @@ class XcodeRbe extends base_command_1.BaseCommand {
383
408
  ready = true;
384
409
  break;
385
410
  }
386
- await (0, rbe_session_1.defaultSleep)(200);
411
+ await (0, api_1.defaultSleep)(200);
387
412
  }
388
413
  if (!ready) {
389
414
  this.reporter.stop('failure');
@@ -406,6 +431,8 @@ class XcodeRbe extends base_command_1.BaseCommand {
406
431
  instanceId: opts.instanceId,
407
432
  port: opts.port,
408
433
  ...(opts.simInstanceId ? { simInstanceId: opts.simInstanceId } : {}),
434
+ ...(opts.autoUpload ? { autoUpload: opts.autoUpload } : {}),
435
+ ...(opts.uploadTtl ? { uploadTtl: opts.uploadTtl } : {}),
409
436
  });
410
437
  this.printReady({
411
438
  port: opts.port,
@@ -416,6 +443,7 @@ class XcodeRbe extends base_command_1.BaseCommand {
416
443
  instanceId: opts.instanceId,
417
444
  background: true,
418
445
  simulatorAttached: !!opts.simInstanceId,
446
+ autoUpload: opts.autoUpload,
419
447
  pid,
420
448
  logPath,
421
449
  });
@@ -436,7 +464,7 @@ class XcodeRbe extends base_command_1.BaseCommand {
436
464
  * the child if it exits within a short liveness window, so a slow tunnel-open
437
465
  * failure would otherwise leave the remote stack running with no owner.
438
466
  */
439
- async runTunnel(client, port) {
467
+ async runTunnel(client, port, autoUpload) {
440
468
  let tunnel;
441
469
  try {
442
470
  tunnel = await this.openTunnel(client, port);
@@ -445,14 +473,24 @@ class XcodeRbe extends base_command_1.BaseCommand {
445
473
  await client.stopRbe().catch(() => { });
446
474
  this.error(`Failed to open the remote-execution tunnel: ${err instanceof Error ? err.message : String(err)}`);
447
475
  }
448
- await this.awaitTunnel(tunnel, client);
476
+ await this.awaitTunnel(tunnel, client, autoUpload);
449
477
  }
450
478
  /**
451
479
  * Block on an already-open tunnel until a stop signal, then close it and
452
480
  * best-effort stop the remote stack. Rejects if the tunnel reports a terminal
453
- * disconnect (after its own reconnect attempts are exhausted).
481
+ * disconnect (after its own reconnect attempts are exhausted). With
482
+ * autoUpload set, a watcher uploads every successful build as the named
483
+ * asset for the tunnel's lifetime.
454
484
  */
455
- async awaitTunnel(tunnel, client) {
485
+ async awaitTunnel(tunnel, client, autoUpload) {
486
+ const watcher = autoUpload ?
487
+ (0, rbe_auto_upload_1.startAutoUploadWatcher)({
488
+ client,
489
+ assetName: autoUpload.assetName,
490
+ ttl: autoUpload.ttl,
491
+ log: (msg) => this.info(msg),
492
+ })
493
+ : undefined;
456
494
  try {
457
495
  await new Promise((resolve, reject) => {
458
496
  const keepAlive = setInterval(() => { }, 1 << 30);
@@ -502,6 +540,9 @@ class XcodeRbe extends base_command_1.BaseCommand {
502
540
  });
503
541
  }
504
542
  finally {
543
+ // Awaited so an upload already in flight (a completed build's artifact)
544
+ // finishes before the stack goes down; queued ones are skipped.
545
+ await watcher?.stop();
505
546
  tunnel.close();
506
547
  await client.stopRbe().catch(() => { });
507
548
  }
@@ -515,6 +556,7 @@ class XcodeRbe extends base_command_1.BaseCommand {
515
556
  xcodeVersion: opts.xcodeVersion,
516
557
  workspaceRoot: opts.workspaceRoot,
517
558
  simulatorAttached: opts.simulatorAttached,
559
+ ...(opts.autoUpload ? { autoUpload: opts.autoUpload } : {}),
518
560
  generatedConfig: {
519
561
  buildFile: opts.generated.buildFile,
520
562
  bazelrcFragment: opts.generated.bazelrcFragment,
@@ -532,6 +574,9 @@ class XcodeRbe extends base_command_1.BaseCommand {
532
574
  this.output('');
533
575
  this.output(`Endpoint: grpc://127.0.0.1:${opts.port}`);
534
576
  this.output(`Builds: ${this.consoleBuildUrl(opts.instanceId)}`);
577
+ if (opts.autoUpload) {
578
+ this.output(`Uploads: every successful build refreshes asset "${opts.autoUpload}"`);
579
+ }
535
580
  if (opts.background) {
536
581
  this.output(`Logs: ${opts.logPath}`);
537
582
  this.output(`Stop: lim xcode rbe --stop (or: kill ${opts.pid})`);
@@ -556,6 +601,7 @@ XcodeRbe.description = 'Start the embedded Bazel Remote Build Execution stack on
556
601
  'on start) or by deleting the instance. Pass --no-daemon to keep it in the foreground.';
557
602
  XcodeRbe.examples = [
558
603
  '<%= config.bin %> xcode rbe',
604
+ '<%= config.bin %> xcode rbe --auto-upload preview/my-app --upload-ttl 24h',
559
605
  '<%= config.bin %> xcode rbe --no-daemon',
560
606
  '<%= config.bin %> xcode rbe --id <xcode-instance-ID>',
561
607
  '<%= config.bin %> xcode rbe --port 9980',
@@ -577,6 +623,16 @@ XcodeRbe.flags = {
577
623
  stop: core_1.Flags.boolean({
578
624
  description: 'Stop the background tunnel running for this workspace.',
579
625
  default: false,
626
+ exclusive: ['auto-upload'],
627
+ }),
628
+ 'auto-upload': core_1.Flags.string({
629
+ description: 'Upload every successful build as an asset with this name, automatically at build end. ' +
630
+ 'The asset is refreshed on each rebuild; upload results land in the tunnel log.',
631
+ exclusive: ['stop'],
632
+ }),
633
+ 'upload-ttl': core_1.Flags.string({
634
+ description: 'Asset TTL for --auto-upload as a Go duration (e.g. 24h, 30m).',
635
+ dependsOn: ['auto-upload'],
580
636
  }),
581
637
  ios: core_1.Flags.boolean({
582
638
  description: 'Also create an iOS simulator and attach it, so builds auto-install on it and you can watch it live. The simulator is torn down on --stop.',
@@ -630,4 +686,4 @@ function readLogTail(logPath, lines = 20) {
630
686
  return '(no log output captured)';
631
687
  }
632
688
  }
633
- //# sourceMappingURL=rbe.js.map
689
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/xcode/rbe/index.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,iDAAsC;AACtC,sCAAoC;AAEpC,qCAWqB;AACrB,wDAAoD;AACpD,gDAA0D;AAC1D,oDAAyD;AACzD,kEAAsE;AACtE,0DAQkC;AAElC,MAAqB,QAAS,SAAQ,0BAAW;IAAjD;;QA2DU,aAAQ,GAAG,IAAI,2BAAgB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAspB3E,CAAC;IAppBC,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAC3B,0EAA0E;QAC1E,qEAAqE;QACrE,uEAAuE;QACvE,uBAAuB;QACvB,IAAI,KAAK,CAAC,aAAa,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;YAChE,IAAI,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC/D,CAAC;QACD,MAAM,UAAU,GACd,KAAK,CAAC,aAAa,CAAC,CAAC,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,CAAC,CAAC;QACxG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,mFAAmF;AACnF,SAAS,WAAW,CAAC,OAAe,EAAE,KAAK,GAAG,EAAE;IAC9C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;QAC3D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,qBAAqB,CAAC;QAC/B,CAAC;QACD,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,0BAA0B,CAAC;IACpC,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ export default class XcodeRbeUpload extends BaseCommand {
3
+ static summary: string;
4
+ static description: string;
5
+ static examples: string[];
6
+ static args: {
7
+ name: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
8
+ };
9
+ static flags: {
10
+ create: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ ttl: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ 'api-key': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
+ workspace: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
16
+ };
17
+ run(): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../../src/commands/xcode/rbe/upload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,WAAW;IACrD,MAAM,CAAC,OAAO,SAA2D;IACzE,MAAM,CAAC,WAAW,SAIiF;IACnG,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,IAAI;;MAKT;IAEF,MAAM,CAAC,KAAK;;;;;;;MAcV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA2C3B"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const api_1 = require("@limrun/api");
5
+ const base_command_1 = require("../../../base-command");
6
+ const rbe_session_1 = require("../../../lib/rbe-session");
7
+ class XcodeRbeUpload extends base_command_1.BaseCommand {
8
+ async run() {
9
+ const { args, flags } = await this.parse(XcodeRbeUpload);
10
+ this.setParsedFlags(flags);
11
+ const workspaceRoot = (0, api_1.findBazelWorkspaceRoot)(process.cwd());
12
+ if (!workspaceRoot) {
13
+ this.error('Not inside a Bazel workspace. Run `lim xcode rbe upload` from within the workspace ' +
14
+ 'whose build you want to upload.');
15
+ }
16
+ // oclif's required-arg check accepts an empty string (e.g. an unset shell
17
+ // variable), which would reach the server as asset name "".
18
+ if (!args.name) {
19
+ this.error('The asset name must not be empty.');
20
+ }
21
+ const info = (0, rbe_session_1.readRbePidFile)(workspaceRoot);
22
+ // instanceId presence matters as much as liveness: without it,
23
+ // resolveXcodeTarget(undefined) would silently fall back to the most
24
+ // recent Xcode instance, uploading from the wrong place.
25
+ if (!info || !info.instanceId || !(0, rbe_session_1.isProcessAlive)(info.pid)) {
26
+ this.error('No background tunnel for this workspace. Start one with `lim xcode rbe` and run ' +
27
+ '`bazel build --config=limrun <target>` before uploading. (A foreground --no-daemon ' +
28
+ 'tunnel is not tracked here; use --auto-upload with it instead.)');
29
+ }
30
+ await this.withAuth(async () => {
31
+ const client = await this.resolveXcodeClient(await this.resolveXcodeTarget(info.instanceId));
32
+ const result = await client.uploadLatestRbeBuild({
33
+ assetName: args.name,
34
+ ...(flags.ttl && { ttl: flags.ttl }),
35
+ });
36
+ if (this.isJsonEnabled()) {
37
+ this.outputJson(result);
38
+ return;
39
+ }
40
+ // No presigned download URL here: it is 15-minute ephemeral noise in a
41
+ // terminal (matching `lim asset push`); --json carries it for scripts.
42
+ this.info(`Uploaded ${result.appName} as asset "${args.name}".`);
43
+ });
44
+ }
45
+ }
46
+ XcodeRbeUpload.summary = 'Upload the latest successful remote build as an asset';
47
+ XcodeRbeUpload.description = "Uploads the newest successful Bazel build of this workspace's running remote-execution " +
48
+ 'tunnel as a named asset, in the same artifact format `lim xcode build --upload` produces. ' +
49
+ 'Run it after `bazel build --config=limrun` succeeds. For uploads that happen automatically ' +
50
+ 'on every successful build, start the tunnel with `lim xcode rbe --auto-upload <name>` instead.';
51
+ XcodeRbeUpload.examples = [
52
+ '<%= config.bin %> xcode rbe upload preview/my-app',
53
+ '<%= config.bin %> xcode rbe upload preview/my-app --ttl 24h',
54
+ ];
55
+ XcodeRbeUpload.args = {
56
+ name: core_1.Args.string({
57
+ description: 'Asset name to upload the build as.',
58
+ required: true,
59
+ }),
60
+ };
61
+ XcodeRbeUpload.flags = {
62
+ ...base_command_1.BaseCommand.baseFlags,
63
+ // A replacement instance has no recorded build, so auto-creating on a
64
+ // vanished pidfile instance would "upload" nothing useful from a fresh
65
+ // instance the tunnel does not even point at (the serve child refuses
66
+ // creation for the same reason).
67
+ create: core_1.Flags.boolean({
68
+ ...base_command_1.BaseCommand.baseFlags.create,
69
+ default: false,
70
+ hidden: true,
71
+ }),
72
+ ttl: core_1.Flags.string({
73
+ description: 'Asset TTL as a Go duration (e.g. 24h, 30m).',
74
+ }),
75
+ };
76
+ exports.default = XcodeRbeUpload;
77
+ //# sourceMappingURL=upload.js.map
@@ -0,0 +1 @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AoB,CAAC;gBAC/C,SAAS,EAAE,IAAI,CAAC,IAAI;gBACpB,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;aACrC,CAAC,CAAC;YACH,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;gBACzB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACxB,OAAO;YACT,CAAC;YACD,uEAAuE;YACvE,uEAAuE;YACvE,IAAI,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,OAAO,cAAc,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC;;AA5EM,sBAAO,GAAG,uDAAuD,CAAC;AAClE,0BAAW,GAChB,yFAAyF;IACzF,4FAA4F;IAC5F,6FAA6F;IAC7F,gGAAgG,CAAC;AAC5F,uBAAQ,GAAG;IAChB,mDAAmD;IACnD,6DAA6D;CAC9D,CAAC;AAEK,mBAAI,GAAG;IACZ,IAAI,EAAE,WAAI,CAAC,MAAM,CAAC;QAChB,WAAW,EAAE,oCAAoC;QACjD,QAAQ,EAAE,IAAI;KACf,CAAC;CACH,CAAC;AAEK,oBAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;IACxB,sEAAsE;IACtE,uEAAuE;IACvE,sEAAsE;IACtE,iCAAiC;IACjC,MAAM,EAAE,YAAK,CAAC,OAAO,CAAC;QACpB,GAAG,0BAAW,CAAC,SAAS,CAAC,MAAM;QAC/B,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,IAAI;KACb,CAAC;IACF,GAAG,EAAE,YAAK,CAAC,MAAM,CAAC;QAChB,WAAW,EAAE,6CAA6C;KAC3D,CAAC;CACH,CAAC;kBAjCiB,cAAc"}
@@ -0,0 +1,24 @@
1
+ import type { XcodeClient } from '@limrun/api';
2
+ /**
3
+ * Watches the instance's Bazel builds and uploads every successful one as the
4
+ * named asset, so a preview link stays current with no post-build step. Runs
5
+ * inside the process that holds the RBE tunnel (the detached serve child, or
6
+ * the foreground --no-daemon command).
7
+ *
8
+ * One poll loop over the daemon's recent-builds view, which lists in-flight
9
+ * invocations plus recently finished ones with their terminal status. A build
10
+ * that starts and finishes between polls (or during a polling outage) still
11
+ * surfaces there afterwards, so nothing else is needed for reliable build-end
12
+ * delivery. The first successful poll is the baseline: builds already terminal
13
+ * at that point predate arming and are not uploaded.
14
+ */
15
+ export declare function startAutoUploadWatcher(opts: {
16
+ client: Pick<XcodeClient, 'getRecentRbeBuilds' | 'uploadLatestRbeBuild'>;
17
+ assetName: string;
18
+ ttl?: string;
19
+ log: (msg: string) => void;
20
+ pollMs?: number;
21
+ }): {
22
+ stop: () => Promise<void>;
23
+ };
24
+ //# sourceMappingURL=rbe-auto-upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rbe-auto-upload.d.ts","sourceRoot":"","sources":["../../src/lib/rbe-auto-upload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,aAAa,CAAC;AAwBhE;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,oBAAoB,GAAG,sBAAsB,CAAC,CAAC;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CA2FhC"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startAutoUploadWatcher = startAutoUploadWatcher;
4
+ const promises_1 = require("node:timers/promises");
5
+ // The daemon reports exactly these terminal statuses; anything else is in
6
+ // flight (RUNNING today; treat unknown future statuses the same so they are
7
+ // not permanently marked handled before reaching a terminal state).
8
+ const TERMINAL_STATUSES = new Set(['SUCCEEDED', 'FAILED', 'CANCELLED', 'INCOMPLETE']);
9
+ // Full upload attempts per build across polls (each already carries the SDK's
10
+ // internal transient retries), covering an asset-storage outage of a few
11
+ // minutes without letting a permanently failing upload retry forever.
12
+ const MAX_UPLOAD_ATTEMPTS = 3;
13
+ /** Whether the build provably started after `armedAt`. The wire carries
14
+ * startedAt even though the published type does not declare it yet; absent
15
+ * or unparsable values count as not-after (the conservative baseline side).
16
+ * Client/daemon clock skew is negligible against the seconds-wide window
17
+ * this disambiguates. */
18
+ function startedAfter(build, armedAt) {
19
+ const startedAt = build.startedAt;
20
+ if (!startedAt)
21
+ return false;
22
+ const t = Date.parse(startedAt);
23
+ return !Number.isNaN(t) && t >= armedAt;
24
+ }
25
+ /**
26
+ * Watches the instance's Bazel builds and uploads every successful one as the
27
+ * named asset, so a preview link stays current with no post-build step. Runs
28
+ * inside the process that holds the RBE tunnel (the detached serve child, or
29
+ * the foreground --no-daemon command).
30
+ *
31
+ * One poll loop over the daemon's recent-builds view, which lists in-flight
32
+ * invocations plus recently finished ones with their terminal status. A build
33
+ * that starts and finishes between polls (or during a polling outage) still
34
+ * surfaces there afterwards, so nothing else is needed for reliable build-end
35
+ * delivery. The first successful poll is the baseline: builds already terminal
36
+ * at that point predate arming and are not uploaded.
37
+ */
38
+ function startAutoUploadWatcher(opts) {
39
+ const { client, assetName, ttl, log } = opts;
40
+ const pollMs = opts.pollMs ?? 1000;
41
+ const abort = new AbortController();
42
+ const armedAt = Date.now();
43
+ // Abort-aware sleep so stop() never has to wait out a pending delay (the
44
+ // failure backoff can reach 10x pollMs, which would stall process exit).
45
+ const sleep = (ms) => (0, promises_1.setTimeout)(ms, undefined, { signal: abort.signal }).catch(() => undefined);
46
+ // Terminal invocations already acted on (or predating arming). Bounded by
47
+ // builds per tunnel session (one id string each; never evicted).
48
+ const handled = new Set();
49
+ const uploadAttempts = new Map();
50
+ // Serialize uploads: each ships the daemon's latest record, so a second
51
+ // build finishing mid-upload just refreshes the asset again right after.
52
+ let uploadChain = Promise.resolve();
53
+ let baselined = false;
54
+ let pollFailures = 0;
55
+ const upload = (invocationId) => {
56
+ uploadChain = uploadChain.then(async () => {
57
+ if (abort.signal.aborted)
58
+ return;
59
+ try {
60
+ const result = await client.uploadLatestRbeBuild({ assetName, ...(ttl && { ttl }) });
61
+ log(`auto-upload: uploaded ${result.appName} as "${assetName}"`);
62
+ }
63
+ catch (err) {
64
+ // The SDK already retried transient errors internally; ride out a
65
+ // longer outage by un-handling the build so the next poll re-attempts
66
+ // the whole upload. Bounded so a permanent error (e.g. a rejected
67
+ // ttl) cannot retry forever; error classification is deliberately
68
+ // avoided. A build that exhausts its attempts heals on the next one.
69
+ const attempts = (uploadAttempts.get(invocationId) ?? 0) + 1;
70
+ uploadAttempts.set(invocationId, attempts);
71
+ if (attempts < MAX_UPLOAD_ATTEMPTS && !abort.signal.aborted) {
72
+ handled.delete(invocationId);
73
+ }
74
+ log(`auto-upload: upload failed (attempt ${attempts}/${MAX_UPLOAD_ATTEMPTS}): ` +
75
+ `${err instanceof Error ? err.message : err}`);
76
+ }
77
+ });
78
+ };
79
+ const pollLoop = async () => {
80
+ while (!abort.signal.aborted) {
81
+ try {
82
+ const builds = await client.getRecentRbeBuilds();
83
+ pollFailures = 0;
84
+ for (const build of builds) {
85
+ if (!TERMINAL_STATUSES.has(build.status))
86
+ continue;
87
+ if (handled.has(build.invocationId))
88
+ continue;
89
+ handled.add(build.invocationId);
90
+ if (!baselined && !startedAfter(build, armedAt)) {
91
+ // Terminal at the first successful poll and not provably started
92
+ // after arming: predates this watcher, not ours to upload. The
93
+ // startedAt check keeps a build that started post-arm but finished
94
+ // during an initial poll-failure streak from being misclassified.
95
+ continue;
96
+ }
97
+ if (build.status === 'SUCCEEDED') {
98
+ upload(build.invocationId);
99
+ }
100
+ else {
101
+ log(`auto-upload: build ${build.invocationId} ${build.status}; skipping upload`);
102
+ }
103
+ }
104
+ baselined = true;
105
+ }
106
+ catch (err) {
107
+ // Log the first failure of a streak, then back off linearly; the
108
+ // tunnel process must survive daemon restarts and network blips.
109
+ pollFailures++;
110
+ if (pollFailures === 1) {
111
+ log(`auto-upload: polling failed: ${err instanceof Error ? err.message : err}`);
112
+ }
113
+ }
114
+ await sleep(pollMs * Math.min(pollFailures + 1, 10));
115
+ }
116
+ };
117
+ void pollLoop();
118
+ return {
119
+ // Aborting skips queued uploads, but an upload already in flight is a
120
+ // completed build's artifact: give it a bounded grace instead of
121
+ // cancelling it at process exit. The bound must stay well inside
122
+ // `--stop`'s 30s SIGKILL escalation so the tunnel teardown that follows
123
+ // (tunnel.close + stopRbe, only the child runs them) always gets its
124
+ // turn; a slower upload is abandoned, same as any process exit.
125
+ stop: () => {
126
+ abort.abort();
127
+ return Promise.race([uploadChain, (0, promises_1.setTimeout)(10000, undefined, { ref: false })]).then(() => undefined);
128
+ },
129
+ };
130
+ }
131
+ //# sourceMappingURL=rbe-auto-upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rbe-auto-upload.js","sourceRoot":"","sources":["../../src/lib/rbe-auto-upload.ts"],"names":[],"mappings":";;AAsCA,wDAiGC;AAvID,mDAA8D;AAG9D,0EAA0E;AAC1E,4EAA4E;AAC5E,oEAAoE;AACpE,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;AAEtF,8EAA8E;AAC9E,yEAAyE;AACzE,sEAAsE;AACtE,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B;;;;0BAI0B;AAC1B,SAAS,YAAY,CAAC,KAAsB,EAAE,OAAe;IAC3D,MAAM,SAAS,GAAI,KAAuC,CAAC,SAAS,CAAC;IACrE,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,K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