Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/commands/actors/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,13 @@ Skipping push. Use --force to override.`,
run({ message: `Created version ${version} for Actor ${actor.name}.` });
}

// Sync standby mode on existing actors with actor.json
if (!isActorCreatedNow && !!actorConfig!.usesStandbyMode !== !!actor.actorStandby?.isEnabled) {
const isEnabled = !!actorConfig!.usesStandbyMode;
await actorClient.update({ actorStandby: { isEnabled } });
info({ message: `${isEnabled ? 'Enabled' : 'Disabled'} standby mode for Actor ${actor.name}.` });
}

// Build Actor on Apify and wait for build to finish
run({ message: `Building Actor ${actor.name}` });
let build = await actorClient.build(version, {
Expand Down
24 changes: 17 additions & 7 deletions test/api/commands/push.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,14 @@
);

it(
'should not enable standby mode on existing actor when usesStandbyMode is true in actor.json',
'should sync standby mode on existing actor based on usesStandbyMode in actor.json',
async () => {
// Create an actor without standby mode first
const testActorWithTitleDesc = {
...TEST_ACTOR,
name: `${TEST_ACTOR.name}-standBy-rewrite-test`,
};
const testActor = await testUserClient.actors().create(testActorWithTitleDesc);

Check failure on line 417 in test/api/commands/push.test.ts

View workflow job for this annotation

GitHub Actions / API Tests

test/api/commands/push.test.ts > [api] apify push > should sync standby mode on existing actor based on usesStandbyMode in actor.json

ApifyApiError: Some other Actor already has this name ("cli-push-fhs5k4vhxy-linux-standby-rewrite-test"). ❯ makeRequest node_modules/apify-client/dist/http_client.js:241:30 ❯ ActorCollectionClient._create node_modules/apify-client/dist/base/resource_collection_client.js:29:26 ❯ test/api/commands/push.test.ts:417:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { clientMethod: 'ActorCollectionClient.create', statusCode: 409, attempt: 1, httpMethod: 'post', path: '/v2/acts', originalStack: '\n at makeRequest (/home/runner/work/apify-cli/apify-cli/node_modules/apify-client/dist/http_client.js:241:30)\n at processTicksAndRejections (node:internal/process/task_queues:103:5)\n at ActorCollectionClient._create (/home/runner/work/apify-cli/apify-cli/node_modules/apify-client/dist/base/resource_collection_client.js:29:26)\n at /home/runner/work/apify-cli/apify-cli/test/api/commands/push.test.ts:417:22\n at file:///home/runner/work/apify-cli/apify-cli/node_modules/@vitest/runner/dist/index.js:915:20', data: undefined, _safelyParsePathFromResponse: 'Function<_safelyParsePathFromResponse>', _extractClientAndMethodFromStack: 'Function<_extractClientAndMethodFromStack>', _createApiStack: 'Function<_createApiStack>' }

Check failure on line 417 in test/api/commands/push.test.ts

View workflow job for this annotation

GitHub Actions / API Tests

test/api/commands/push.test.ts > [api] apify push > should sync standby mode on existing actor based on usesStandbyMode in actor.json

ApifyApiError: Some other Actor already has this name ("cli-push-fhs5k4vhxy-linux-standby-rewrite-test"). ❯ makeRequest node_modules/apify-client/dist/http_client.js:241:30 ❯ ActorCollectionClient._create node_modules/apify-client/dist/base/resource_collection_client.js:29:26 ❯ test/api/commands/push.test.ts:417:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { clientMethod: 'ActorCollectionClient.create', statusCode: 409, attempt: 1, httpMethod: 'post', path: '/v2/acts', originalStack: '\n at makeRequest (/home/runner/work/apify-cli/apify-cli/node_modules/apify-client/dist/http_client.js:241:30)\n at processTicksAndRejections (node:internal/process/task_queues:103:5)\n at ActorCollectionClient._create (/home/runner/work/apify-cli/apify-cli/node_modules/apify-client/dist/base/resource_collection_client.js:29:26)\n at /home/runner/work/apify-cli/apify-cli/test/api/commands/push.test.ts:417:22\n at file:///home/runner/work/apify-cli/apify-cli/node_modules/@vitest/runner/dist/index.js:915:20', data: undefined, _safelyParsePathFromResponse: 'Function<_safelyParsePathFromResponse>', _extractClientAndMethodFromStack: 'Function<_extractClientAndMethodFromStack>', _createApiStack: 'Function<_createApiStack>' }

Check failure on line 417 in test/api/commands/push.test.ts

View workflow job for this annotation

GitHub Actions / API Tests

test/api/commands/push.test.ts > [api] apify push > should sync standby mode on existing actor based on usesStandbyMode in actor.json

ApifyApiError: Some other Actor already has this name ("cli-push-fhs5k4vhxy-linux-standby-rewrite-test"). ❯ makeRequest node_modules/apify-client/dist/http_client.js:241:30 ❯ ActorCollectionClient._create node_modules/apify-client/dist/base/resource_collection_client.js:29:26 ❯ test/api/commands/push.test.ts:417:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { clientMethod: 'ActorCollectionClient.create', statusCode: 409, attempt: 1, httpMethod: 'post', path: '/v2/acts', originalStack: '\n at makeRequest (/home/runner/work/apify-cli/apify-cli/node_modules/apify-client/dist/http_client.js:241:30)\n at processTicksAndRejections (node:internal/process/task_queues:103:5)\n at ActorCollectionClient._create (/home/runner/work/apify-cli/apify-cli/node_modules/apify-client/dist/base/resource_collection_client.js:29:26)\n at /home/runner/work/apify-cli/apify-cli/test/api/commands/push.test.ts:417:22\n at file:///home/runner/work/apify-cli/apify-cli/node_modules/@vitest/runner/dist/index.js:915:20', data: undefined, _safelyParsePathFromResponse: 'Function<_safelyParsePathFromResponse>', _extractClientAndMethodFromStack: 'Function<_extractClientAndMethodFromStack>', _createApiStack: 'Function<_createApiStack>' }
actorsForCleanup.add(testActor.id);
const testActorClient = testUserClient.actor(testActor.id);

Expand All @@ -422,23 +422,33 @@
const initialActor = await testActorClient.get();
expect(initialActor?.actorStandby?.isEnabled).to.not.be.eql(true);

// Enable standby
const actorJson = JSON.parse(readFileSync(joinPath(LOCAL_CONFIG_PATH), 'utf8'));

// Enable standby in actor.json and push
actorJson.usesStandbyMode = true;
writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' });
await testRunCommand(ActorsPushCommand, {
args_actorId: testActor.id,
flags_noPrompt: true,
flags_force: true,
});

// Push to existing actor - this should update standby mode
const enabledActor = await testActorClient.get();
expect(enabledActor?.actorStandby?.isEnabled).to.be.eql(true);

// Remove usesStandbyMode from actor.json and push again (should disable)
delete actorJson.usesStandbyMode;
writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' });
await testRunCommand(ActorsPushCommand, {
args_actorId: testActor.id,
flags_noPrompt: true,
flags_force: true,
});

const updatedActor = await testActorClient.get();
const disabledActor = await testActorClient.get();
expect(disabledActor?.actorStandby?.isEnabled).to.be.eql(false);

Check failure on line 449 in test/api/commands/push.test.ts

View workflow job for this annotation

GitHub Actions / API Tests

test/api/commands/push.test.ts > [api] apify push > should sync standby mode on existing actor based on usesStandbyMode in actor.json

AssertionError: expected true to deeply equal false - Expected + Received - false + true ❯ test/api/commands/push.test.ts:449:57

// Verify standby is not enabled after push
expect(updatedActor?.actorStandby?.isEnabled).to.not.be.eql(true);
if (updatedActor) await testActorClient.delete();
if (disabledActor) await testActorClient.delete();
},
TEST_TIMEOUT,
);
Expand Down
Loading