Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: quick deploy polling uses the new deploy ID #815

Merged
merged 1 commit into from
Nov 17, 2023
Merged
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
18 changes: 11 additions & 7 deletions src/commands/project/deploy/quick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,13 @@ export default class DeployMetadataQuick extends SfCommand<DeployResultJson> {
const deployOpts = cache.get(jobId) ?? ({} as DeployOptions);
const org = flags['target-org'] ?? (await Org.create({ aliasOrUsername: deployOpts['target-org'] }));
const api = await resolveApi(this.configAggregator);
const connection = org.getConnection(flags['api-version']);

const mdapiDeploy = new MetadataApiDeploy({
usernameOrConnection: org.getConnection(flags['api-version']),
// This is the ID of the deploy (of the validated metadata)
const deployId = await connection.metadata.deployRecentValidation({
id: jobId,
apiOptions: {
rest: api === API['REST'],
},
rest: api === API['REST'],
});
// This is the ID of the deploy (of the validated metadata)
const deployId = await mdapiDeploy.deployRecentValidation(api === API['REST']);
this.log(`Deploy ID: ${chalk.bold(deployId)}`);

if (flags.async) {
Expand All @@ -109,6 +106,13 @@ export default class DeployMetadataQuick extends SfCommand<DeployResultJson> {
return asyncFormatter.getJson();
}

const mdapiDeploy = new MetadataApiDeploy({
usernameOrConnection: connection,
id: deployId,
apiOptions: {
rest: api === API['REST'],
},
});
const result = await mdapiDeploy.pollStatus({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The polling was reusing the MetadataApiDeploy instance created from the validation ID (aka jobId) so it was polling for the validation deploy status, not the deployRecentValidation status.

frequency: Duration.seconds(1),
timeout: flags.wait,
Expand Down
22 changes: 21 additions & 1 deletion test/commands/deploy/metadata/quick.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('deploy metadata quick NUTs', () => {
});

describe('--job-id', () => {
it('should deploy previously validated deployment', async () => {
it('should deploy previously validated deployment (async)', async () => {
const validation = await testkit.execute<DeployResultJson>('project:deploy:validate', {
args: '--source-dir force-app',
json: true,
Expand All @@ -97,6 +97,26 @@ describe('deploy metadata quick NUTs', () => {
exitCode: 0,
});
assert(deploy);
assert(deploy.result.id !== validation.result.id, 'deploy result ID should not be the validation ID');
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
});

it('should deploy previously validated deployment (poll)', async () => {
const validation = await testkit.execute<DeployResultJson>('project:deploy:validate', {
args: '--source-dir force-app',
json: true,
exitCode: 0,
});
assert(validation);
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);

const deploy = await testkit.execute<DeployResultJson>('project:deploy:quick', {
args: `--job-id ${validation.result.id} --wait 20`,
json: true,
exitCode: 0,
});
assert(deploy);
assert(deploy.result.id !== validation.result.id, 'deploy result ID should not be the validation ID');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion verifies the correct behavior. If you remove the fix from quick.ts these tests will fail.

await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
});

Expand Down