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: deploy validate doesn\'t require a project #691

Merged
merged 2 commits into from
Jul 11, 2023

Conversation

WillieRuemmele
Copy link
Contributor

@WillieRuemmele WillieRuemmele commented Jul 10, 2023

What does this PR do?

In certain scenarios, when using --metadata-dir the project deploy validate command doesn't require a project, but requiresProject=true so it would throw an error

remove that line so it can be executed outside of a project

What issues does this PR fix or reference?

@W-13721102@
forcedotcom/cli#2275

 ➜  ../oss/plugin-deploy-retrieve/bin/dev project deploy validate --metadata-dir temp --async --target-org [email protected] 
Validating Deployment of vundefined metadata to [email protected] using the v58.0 SOAP API.
Deploy ID: 0AfDH00001iUqjP0AS
Deploy has been queued.

Run "sf project deploy resume --job-id 0AfDH00001iUqjP0AS" to resume watching the deploy.
Run "sf project deploy report --job-id 0AfDH00001iUqjP0AS" to get the latest status.
Run "sf project deploy cancel --job-id 0AfDH00001iUqjP0AS" to cancel the deploy.

➜  scratches 
 ➜  sf project deploy validate --metadata-dir temp --async --target-org [email protected] 
    RequiresProjectError: This command is required to run from within a Salesforce project directory.
    Code: RequiresProjectError

@cristiand391
Copy link
Member

QA notes:

test setup using dreamhoues

✅ can validate a deployment of a project in mdapi format outside the sfdx project:

➜  gh sf project deploy validate --metadata-dir dreamhouse-lwc/mdapi --concise --target-org dreamhouse
Validating Deployment of vundefined metadata to [email protected] using the v58.0 SOAP API.
Deploy ID: 0Af0400000kmsfKCAQ
Status: Succeeded | ████████████████████████████████████████ | 91/91 Components (Erro

Test Results Summary
Passing: 11
Failing: 0
Total: 11
Time: 3777

Successfully validated the deployment (0Af0400000kmsfKCAQ).
Run "sf project deploy quick --job-id 0Af0400000kmsfKCAQ" to execute this deploy
➜  gh echo $?
0

❌ can't do a quick deploy of the validated deploy when outside of an sfdx project:

➜  gh sf project deploy quick --job-id 0Af0400000kmsfKCAQ --target-org dreamhouse
    RequiresProjectError: This command is required to run from within a Salesforce project directory.
    Code: RequiresProjectError
➜  gh echo $?
1

force mdapi deploy allows this use case:

➜  gh sf force mdapi deploy --validateddeployrequestid 0Af0400000kmsfKCAQ --target-org dreamhouse
Warning: We plan to deprecate this command in the future. Try using the "project deploy start" command instead.
Deploy ID: 0Af0400000kmsybCAA
Deploy has been queued.

Run sfdx force:mdapi:deploy:cancel -i 0Af0400000kmsybCAA -u [email protected] to cancel the deploy.
Run sfdx force:mdapi:deploy:report -i 0Af0400000kmsybCAA -u [email protected] to get the latest status.
➜  gh sf force mdapi deploy report -i 0Af0400000kmsybCAA -u [email protected]
Warning: We plan to deprecate this command in the future. Try using the "project deploy start" and "project deploy report" pair instead.
Warning: The "-u" flag has been deprecated. Use "--target-org | -o" instead.
Deploy ID: 0Af0400000kmsybCAA
Status: Succeeded
Deployed: 91/91 Errors: 0
Tests Complete: 0/0 Errors: 0

❌ after doing an async deploy, can't resume or get a report of it outside of an sfdx project:

➜  gh sf project deploy validate --metadata-dir dreamhouse-lwc/mdapi --concise --target-org dreamhouse --async
Validating Deployment of vundefined metadata to [email protected] using the v58.0 SOAP API.
Deploy ID: 0Af0400000kmuOVCAY
Deploy has been queued.

Run "sf project deploy resume --job-id 0Af0400000kmuOVCAY" to resume watching the dep
loy.
Run "sf project deploy report --job-id 0Af0400000kmuOVCAY" to get the latest status.
Run "sf project deploy cancel --job-id 0Af0400000kmuOVCAY" to cancel the deploy.

➜  gh sf project deploy resume --job-id 0Af0400000kmuOVCAY
    RequiresProjectError: This command is required to run from within a Salesforce project directory.
    Code: RequiresProjectError
➜  gh sf project deploy report --job-id 0Af0400000kmuOVCAY
    RequiresProjectError: This command is required to run from within a Salesforce project directory.
    Code: RequiresProjectError

✅ get error about missing sfdx project if doing a source-format deploy

➜  gh sf project deploy validate --source-dir dreamhouse-lwc/force-app/ -o dreamhouse
Error (1): This directory does not contain a valid Salesforce DX project.

the error is different from the current implementation but still valid:

➜  gh sf project deploy validate --source-dir dreamhouse-lwc/force-app/ -o dreamhouse
    RequiresProjectError: This command is required to run from within a Salesforce project directory.
    Code: RequiresProjectError

@cristiand391
Copy link
Member

QA updates

❌ can't do a quick deploy of the validated deploy when outside of an sfdx project:

✅ fixed:

➜  gh sf project deploy validate --metadata-dir dreamhouse-lwc/mdapi --concise --target-org dreamhouse --wait 30
Validating Deployment of vundefined metadata to [email protected] using the v58.0 SOAP API.
Deploy ID: 0Af0400000kp5rkCAA
Status: Succeeded | ████████████████████████████████████████ | 91/91 Components (Errors:0) | 11/11 Tests (Errors:0)

Test Results Summary
Passing: 11
Failing: 0
Total: 11
Time: 4744

Successfully validated the deployment (0Af0400000kp5rkCAA).
Run "sf project deploy quick --job-id 0Af0400000kp5rkCAA" to execute this deploy
➜  gh sf project deploy quick --job-id 0Af0400000kp5rkCAA
Deploy ID: 0Af0400000kp5rkCAA

Validated Source
==============================================================================================================================
| State     Name                                Type                     Path
| ───────── ─────────────────────────────────── ──────────────────────── ─────────────────────────────────────────────────────
| Unchanged FileUtilities                       ApexClass                classes/FileUtilities.cls
...
| Unchanged sample_data_properties              StaticResource           staticresources/sample_data_properties.resource

Test Results Summary
Passing: 11
Failing: 0
Total: 11
Time: 4744

Successfully deployed (0Af0400000kp5rkCAA).

Screenshot 2023-07-11 at 11 23 14

❌ after doing an async deploy, can't resume or get a report of it outside of an sfdx project:

✅ fixed

project deploy report

➜  gh sf project deploy validate --metadata-dir dreamhouse-lwc/mdapi --concise --target-org dreamhouse --async
Validating Deployment of vundefined metadata to [email protected] using the v58.0 SOAP API.
Deploy ID: 0Af0400000kp720CAA
Deploy has been queued.

Run "sf project deploy resume --job-id 0Af0400000kp720CAA" to resume watching the deploy.
Run "sf project deploy report --job-id 0Af0400000kp720CAA" to get the latest status.
Run "sf project deploy cancel --job-id 0Af0400000kp720CAA" to cancel the deploy.

# also tested with `--use-most-recent`
➜  gh sf project deploy report --job-id 0Af0400000kp720CAA
0Af0400000kp720CAA... Pending

Deploy Info
===================================================
| Key                      Value
| ──────────────────────── ────────────────────────
| checkOnly                true
| createdBy                00504000004RbUi
| createdByName            User User
| createdDate              2023-07-11T14:24:14.000Z
| done                     false
| id                       0Af0400000kp720CAA
| ignoreWarnings           false
| lastModifiedDate         2023-07-11T14:24:14.000Z
| numberComponentErrors    0
| numberComponentsDeployed 0
| numberComponentsTotal    0
| numberTestErrors         0
| numberTestsCompleted     0
| numberTestsTotal         0
| rollbackOnError          true
| runTestsEnabled          false
| status                   Pending
| success                  false

Deploy Options
================================================
| Key              Value
| ──────────────── ─────────────────────────────
| concise          true
| target-org       [email protected]
| async            true
| test-level       RunLocalTests
| ignore-conflicts true
| dry-run          true
| api              SOAP
| wait             33
| isMdapi          true
| job-id           0Af0400000kp720CAA

project deploy resume

➜  gh sf project deploy resume --job-id 0Af0400000kp720CAA
Deploy ID: 0Af0400000kp720CAA
Status: Succeeded | ████████████████████████████████████████ | 91/91 Components (Errors:0) | 11/11 Tests (Errors:0)

Test Results Summary
Passing: 11
Failing: 0
Total: 11
Time: 4104

@cristiand391 cristiand391 merged commit b253c65 into main Jul 11, 2023
@cristiand391 cristiand391 deleted the wr/noProjectValidate branch July 11, 2023 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants