Closed nvuillam closed 3 weeks ago
Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.
You can use this command: sf project deploy start --dry-run --test-level NoTestRun
@shetzel i know but ... will it allow me to use quickDeploy after ? I need that :)
@shetzel i made a PR :)
@nvuillam that command with --dry-run
still does a "check-only" deploy so you can use the ID for the subsequent quick deploy.
See https://github.com/forcedotcom/cli/discussions/2688 and https://github.com/forcedotcom/cli/issues/2470#issuecomment-1721450764
@shetzel I'm sorry but it does not work using start --dry-run
and NoTestRun
"context": "DeployMetadataQuick",
"data": {
"errorCode": "sf:INVALID_ID_FIELD",
"message": "INVALID_ID_FIELD: Source validate did not run tests in the org"
},
"stack": "CannotQuickDeployError: Job ID can't be used for quick deployment. Possible reasons include the deployment hasn't been validated, has already been deployed, or the validation expired because you ran it more than 10 days ago.
I don't know what this validate command can be used for, if it can not ignore warnings and can not be called with NoTestRun :(
Would you consider accepting enhancements ? :)
That's the Metadata API enforcement, not CLI. If you're quick deploying to production then tests are required. I'm pretty sure that's a rule regardless of what's being deployed. If you're quick deploying to non-prod then that enforcement isn't there.
Hi @nvuillam
you can simply run sf project deploy start
command for both with/without test run.
sf project deploy start --manifest ./manifest/package.xml --dry-run --test-level RunSpecifiedTests --tests testRecordsTest
The new sf project deploy start
command will trigger the Quick Deploy Option if validation meets the following condition. Same as sfdx force:source:deploy
.
1. The components have been validated successfully for the target environment within the last 10 days.
2. As part of the validation, Apex tests in the target org have passed.
3. Code coverage requirements are met.
* If all tests in the org or all local tests are run, overall code coverage is at least 75%, and Apex triggers have some coverage.
* If specific tests are run with the RunSpecifiedTests test level, each class and trigger that was deployed is covered by at least 75% individually.
@nvuillam - would it solve your usecase if the --test-level
default value was removed from the validate command? In theory, that leaves it up to the org whether it needs to run tests or not based on what's deployed. That might satisfy the quick deploy requirements so that it can be used. If you're able to test it out and confirm we could move forward with that.
@shetzel i moved all calls to deploy start --dry-run, but if validate is able to handle the options I need, i'll gladly switch back :)
circling back to this...
sf project deploy validate
's goal is to validate deployments that can be quick-deployed later.
Allowing --test-level
to be NoTestRun
would invalidate the quick deploy and sf project deploy quick
will not work.
If someone can test Steve's suggestion in a prod org and confirm it allows deploy quicks we can consider supporting it, in my testing that didn't work. https://github.com/forcedotcom/cli/issues/3023#issuecomment-2412020863
Summary
sf project deploy validate : Can not use value
--test-level: NoTestRun
If I want to validate the future deployment of a single layout, I should be able to do so without running test classes :)
Note:
--ignore-warnings
is not accepted eitherSteps To Reproduce
Any call to sf project deploy validate with
--test-level: NoTestRun
Expected result
Deployment validation without running test classes
Actual result
Error (1): Expected --test-level=NoTestRun to be one of: RunAllTestsInOrg, RunLocalTests, RunSpecifiedTests
Additional information
System Information