Skip to content

Commit f906131

Browse files
authored
Fix smoketests cache path, fix smoketest deprecation warnings (#775)
1 parent d5d7a29 commit f906131

18 files changed

Lines changed: 109 additions & 79 deletions

.github/workflows/sdk-coverage.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ on:
1616
- dev
1717
- prod
1818

19+
concurrency:
20+
group: ${{ github.event_name == 'pull_request' && 'dev' || inputs.environment }}
21+
1922
jobs:
2023
smoke-and-coverage:
2124
runs-on: ubuntu-latest

.github/workflows/smoke-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ on:
2323
- dev
2424
- prod
2525

26+
concurrency:
27+
group: ${{ inputs.environment }}
28+
2629
jobs:
2730
smoke-tests:
2831
runs-on: ubuntu-latest
@@ -37,7 +40,6 @@ jobs:
3740
uses: runloopai/setup-node@main
3841
with:
3942
node-version: '20'
40-
cache: yarn
4143

4244
- name: Install dependencies
4345
run: yarn --frozen-lockfile

examples/blueprint-with-build-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export async function recipe(ctx: RecipeContext): Promise<RecipeOutput> {
7070
dockerfile: 'FROM ubuntu:22.04\nWORKDIR /app\nCOPY . .',
7171
build_context: storageObject,
7272
},
73-
{ polling: { timeoutMs: BLUEPRINT_POLL_TIMEOUT_MS } },
73+
{ longPoll: { timeoutMs: BLUEPRINT_POLL_TIMEOUT_MS } },
7474
);
7575
cleanup.add(`blueprint:${blueprint.id}`, () => sdk.blueprint.fromId(blueprint.id).delete());
7676

examples/devbox-from-blueprint-lifecycle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export async function recipe(ctx: RecipeContext): Promise<RecipeOutput> {
4949
name: uniqueName('example-blueprint'),
5050
dockerfile: 'FROM ubuntu:22.04\nRUN echo "Hello from your blueprint"',
5151
},
52-
{ polling: { timeoutMs: BLUEPRINT_POLL_TIMEOUT_MS } },
52+
{ longPoll: { timeoutMs: BLUEPRINT_POLL_TIMEOUT_MS } },
5353
);
5454
cleanup.add(`blueprint:${blueprint.id}`, () => sdk.blueprint.fromId(blueprint.id).delete());
5555

src/resources/scenarios/scenarios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
ScenariosCursorIDPage,
2424
type ScenariosCursorIDPageParams,
2525
} from '../../pagination';
26-
import { PollingOptions } from '@runloop/api-client/lib/polling';
26+
import { LongPollRequestOptions } from '@runloop/api-client/lib/polling';
2727
import { DevboxView } from '../devboxes';
2828

2929
export class Scenarios extends APIResource {
@@ -132,7 +132,7 @@ export class Scenarios extends APIResource {
132132
*/
133133
async startRunAndAwaitEnvReady(
134134
body: ScenarioStartRunParams,
135-
options?: Core.RequestOptions & { polling?: Partial<PollingOptions<DevboxView>> },
135+
options?: LongPollRequestOptions<DevboxView>,
136136
): Promise<ScenarioRunView> {
137137
const run = await this.startRun(body, options);
138138
await this._client.devboxes.awaitRunning(run.devbox_id, options);

src/sdk.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,14 +726,12 @@ export class BlueprintOps {
726726
/**
727727
* Create a new blueprint.
728728
* @param {BlueprintCreateParams} params - Parameters for creating the blueprint.
729-
* @param {Core.RequestOptions & { polling?: Partial<PollingOptions<RunloopAPI.Blueprints.BlueprintView>> }} [options] - Request options including polling configuration.
729+
* @param {LongPollRequestOptions<RunloopAPI.Blueprints.BlueprintView>} [options] - Request options with optional long-poll configuration.
730730
* @returns {Promise<Blueprint>} A {@link Blueprint} instance.
731731
*/
732732
async create(
733733
params: BlueprintCreateParams,
734-
options?: Core.RequestOptions & {
735-
polling?: Partial<PollingOptions<RunloopAPI.Blueprints.BlueprintView>>;
736-
},
734+
options?: LongPollRequestOptions<RunloopAPI.Blueprints.BlueprintView>,
737735
): Promise<Blueprint> {
738736
return Blueprint.create(this.client, params, options);
739737
}

src/sdk/blueprint.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
BlueprintBuildLogsListView,
77
} from '../resources/blueprints';
88
import type { DevboxCreateParams, DevboxView } from '../resources/devboxes/devboxes';
9-
import type { PollingOptions } from '../lib/polling';
9+
import type { LongPollRequestOptions } from '../lib/polling';
1010
import type { IgnoreMatcher } from '../lib/ignore-matcher';
1111
import { Devbox } from './devbox';
1212
import { StorageObject } from './storage-object';
@@ -80,15 +80,13 @@ export class Blueprint {
8080
*
8181
* @param {Runloop} client - The Runloop client instance
8282
* @param {CreateParams} params - Parameters for creating the blueprint
83-
* @param {Core.RequestOptions & { polling?: Partial<PollingOptions<BlueprintView>> }} [options] - Request options with optional polling configuration
83+
* @param {LongPollRequestOptions<BlueprintView>} [options] - Request options with optional long-poll configuration
8484
* @returns {Promise<Blueprint>} A {@link Blueprint} instance with completed build
8585
*/
8686
static async create(
8787
client: Runloop,
8888
params: CreateParams,
89-
options?: Core.RequestOptions & {
90-
polling?: Partial<PollingOptions<BlueprintView>>;
91-
},
89+
options?: LongPollRequestOptions<BlueprintView>,
9290
): Promise<Blueprint> {
9391
const { build_context, build_context_dir, ...other } = params as any;
9492
let rawParams: BlueprintCreateParams;
@@ -214,14 +212,12 @@ export class Blueprint {
214212
* @private
215213
*
216214
* @param {Omit<DevboxCreateParams, 'blueprint_id' | 'snapshot_id' | 'blueprint_name'>} [params] - Additional devbox creation parameters (optional)
217-
* @param {Core.RequestOptions & { polling?: Partial<PollingOptions<DevboxView>> }} [options] - Request options with optional polling configuration
215+
* @param {LongPollRequestOptions<DevboxView>} [options] - Request options with optional long-poll configuration
218216
* @returns {Promise<Devbox>} A new {@link Devbox} instance created from this blueprint
219217
*/
220218
async createDevbox(
221219
params?: Omit<DevboxCreateParams, 'blueprint_id' | 'snapshot_id' | 'blueprint_name'>,
222-
options?: Core.RequestOptions & {
223-
polling?: Partial<PollingOptions<DevboxView>>;
224-
},
220+
options?: LongPollRequestOptions<DevboxView>,
225221
): Promise<Devbox> {
226222
const createParams: DevboxCreateParams = {
227223
...params,

src/sdk/scenario.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
ScenarioStartRunParams,
77
} from '../resources/scenarios/scenarios';
88
import type { DevboxView } from '../resources/devboxes/devboxes';
9-
import { PollingOptions } from '../lib/polling';
9+
import { LongPollRequestOptions } from '../lib/polling';
1010
import { ScenarioRun } from './scenario-run';
1111

1212
/**
@@ -177,13 +177,10 @@ export class Scenario {
177177
* ```
178178
*
179179
* @param {ScenarioRunParams} [params] - Run parameters
180-
* @param {Core.RequestOptions & { polling?: Partial<PollingOptions<DevboxView>> }} [options] - Request options with optional polling config
180+
* @param {LongPollRequestOptions<DevboxView>} [options] - Request options with optional long-poll config
181181
* @returns {Promise<ScenarioRun>} ScenarioRun instance with ready devbox
182182
*/
183-
async run(
184-
params?: ScenarioRunParams,
185-
options?: Core.RequestOptions & { polling?: Partial<PollingOptions<DevboxView>> },
186-
): Promise<ScenarioRun> {
183+
async run(params?: ScenarioRunParams, options?: LongPollRequestOptions<DevboxView>): Promise<ScenarioRun> {
187184
const runView = await this.client.scenarios.startRunAndAwaitEnvReady(
188185
{ scenario_id: this._id, ...params },
189186
options,

tests/smoketests/blueprints.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('smoketest: blueprints', () => {
2424
name: blueprintName,
2525
},
2626
{
27-
polling: { maxAttempts: 180, pollingIntervalMs: 5_000, timeoutMs: 30 * 60 * 1000 },
27+
longPoll: { timeoutMs: 30 * 60 * 1000 },
2828
},
2929
);
3030
expect(created.status).toBe('build_complete');
@@ -101,7 +101,7 @@ describe('smoketest: blueprints', () => {
101101
},
102102
},
103103
{
104-
polling: { maxAttempts: 180, pollingIntervalMs: 5_000, timeoutMs: 30 * 60 * 1000 },
104+
longPoll: { timeoutMs: 30 * 60 * 1000 },
105105
},
106106
);
107107

tests/smoketests/devboxes.test.ts

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ describe('smoketest: devboxes', () => {
4242
test.concurrent(
4343
'create devbox with authenticated tunnel in create params (deprecated polling path)',
4444
async () => {
45+
const warnSpy = jest.spyOn(console, 'warn').mockImplementation((...args: unknown[]) => {
46+
if (typeof args[0] === 'string' && args[0].includes('[runloop-api-client]')) return;
47+
process.stderr.write(`console.warn: ${args.join(' ')}\n`);
48+
});
4549
let devbox: DevboxView | undefined;
4650
try {
4751
devbox = await client.devboxes.createAndAwaitRunning(
@@ -63,6 +67,7 @@ describe('smoketest: devboxes', () => {
6367
expect(devbox.tunnel?.auth_mode).toBe('authenticated');
6468
expect(devbox.tunnel?.auth_token).toBeTruthy();
6569
} finally {
70+
warnSpy.mockRestore();
6671
if (devbox) {
6772
await client.devboxes.shutdown(devbox.id);
6873
}
@@ -178,17 +183,25 @@ describe('smoketest: devboxes', () => {
178183
);
179184

180185
test('await running (createAndAwaitRunning, deprecated polling path)', async () => {
181-
const created = await client.devboxes.createAndAwaitRunning(
182-
{
183-
name: uniqueName('smoketest-devbox2'),
184-
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
185-
},
186-
{
187-
polling: { timeoutMs: 20 * 60 * 1000 },
188-
},
189-
);
190-
expect(created.status).toBe('running');
191-
devboxId = created.id;
186+
const warnSpy = jest.spyOn(console, 'warn').mockImplementation((...args: unknown[]) => {
187+
if (typeof args[0] === 'string' && args[0].includes('[runloop-api-client]')) return;
188+
process.stderr.write(`console.warn: ${args.join(' ')}\n`);
189+
});
190+
try {
191+
const created = await client.devboxes.createAndAwaitRunning(
192+
{
193+
name: uniqueName('smoketest-devbox2'),
194+
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
195+
},
196+
{
197+
polling: { timeoutMs: 20 * 60 * 1000 },
198+
},
199+
);
200+
expect(created.status).toBe('running');
201+
devboxId = created.id;
202+
} finally {
203+
warnSpy.mockRestore();
204+
}
192205
});
193206

194207
test('list devboxes', async () => {
@@ -232,17 +245,25 @@ describe('smoketest: devboxes', () => {
232245
test.concurrent(
233246
'createAndAwaitRunning timeout (deprecated polling path)',
234247
async () => {
235-
await expect(
236-
client.devboxes.createAndAwaitRunning(
237-
{
238-
name: uniqueName('smoketest-devbox-await-running-timeout'),
239-
launch_parameters: { launch_commands: ['sleep 70'], keep_alive_time_seconds: 30 },
240-
},
241-
{
242-
polling: { timeoutMs: 100 },
243-
},
244-
),
245-
).rejects.toThrow();
248+
const warnSpy = jest.spyOn(console, 'warn').mockImplementation((...args: unknown[]) => {
249+
if (typeof args[0] === 'string' && args[0].includes('[runloop-api-client]')) return;
250+
process.stderr.write(`console.warn: ${args.join(' ')}\n`);
251+
});
252+
try {
253+
await expect(
254+
client.devboxes.createAndAwaitRunning(
255+
{
256+
name: uniqueName('smoketest-devbox-await-running-timeout'),
257+
launch_parameters: { launch_commands: ['sleep 70'], keep_alive_time_seconds: 30 },
258+
},
259+
{
260+
polling: { timeoutMs: 100 },
261+
},
262+
),
263+
).rejects.toThrow();
264+
} finally {
265+
warnSpy.mockRestore();
266+
}
246267
},
247268
SHORT_TIMEOUT * 4,
248269
);

0 commit comments

Comments
 (0)