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

sf project deploy validate : Can not use option --test-level: NoTestRun #3023

Open
nvuillam opened this issue Sep 16, 2024 · 10 comments · May be fixed by salesforcecli/plugin-deploy-retrieve#1167
Labels
investigating We're actively investigating this issue validated Version information for this issue has been validated

Comments

@nvuillam
Copy link

nvuillam commented Sep 16, 2024

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 either

Steps 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

image

System Information

$ sf version --json --verbose
 »   Warning: sfdx-hardis is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.
{
  "architecture": "win32-x64",
  "cliVersion": "@salesforce/cli/2.58.7",
  "nodeVersion": "node-v20.16.0",
  "osVersion": "Windows_NT 10.0.22631",
  "rootPath": "C:\\Users\\33614\\AppData\\Roaming\\npm\\node_modules\\@salesforce\\cli",
  "shell": "C:\\Program Files\\Git\\usr\\bin\\bash.exe",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.2 (core)",
    "@oclif/plugin-commands 4.0.13 (core)",
    "@oclif/plugin-help 6.2.10 (core)",
    "@oclif/plugin-not-found 3.2.18 (core)",
    "@oclif/plugin-plugins 5.4.6 (core)",
    "@oclif/plugin-search 1.2.7 (core)",
    "@oclif/plugin-update 4.5.5 (core)",
    "@oclif/plugin-version 2.2.11 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.13 (core)",
    "@oclif/plugin-which 3.2.12 (core)",
    "@salesforce/cli 2.58.7 (core)",
    "apex 3.4.8 (core)",
    "api 1.2.1 (core)",
    "auth 3.6.54 (core)",
    "data 3.6.5 (core)",
    "deploy-retrieve 1.17.6 (user) published 389 days ago (Wed Aug 23 2023) (latest is 3.12.10)",
    "dev 2.4.2 (user) published 20 days ago (Mon Aug 26 2024)",
    "info 3.4.3 (core)",
    "limits 3.3.29 (core)",
    "marketplace 1.2.25 (core)",
    "org 4.5.7 (core)",
    "packaging 2.8.6 (user) published 2 days ago (Sat Sep 14 2024)",
    "schema 3.3.26 (core)",
    "settings 2.3.16 (core)",
    "sobject 1.4.33 (core)",
    "source 3.5.18 (core)",
    "telemetry 3.6.10 (core)",
    "templates 56.3.17 (core)",
    "trust 3.7.27 (core)",
    "user 3.5.29 (core)",
    "@salesforce/sfdx-scanner 3.23.0 (user) published 174 days ago (Tue Mar 26 2024) (latest is 4.5.0)",
    "lightning-flow-scanner 2.22.0 (user) published 155 days ago (Sun Apr 14 2024) (latest is 2.34.0)",
    "sfdmu 4.36.0 (user) published 8 days ago (Sat Sep 07 2024)",
    "sfdx-essentials 2.12.0 (user) published 1007 days ago (Tue Dec 14 2021)",
    "sfdx-git-delta 5.44.0 (user) published 3 days ago (Fri Sep 13 2024)",
    "sfdx-hardis 5.0.0 (link) C:\\git\\pro\\sfdx-hardis2",
    "texei-sfdx-plugin 2.7.0 (user) published 6 days ago (Tue Sep 10 2024)"
  ]
@nvuillam nvuillam added the investigating We're actively investigating this issue label Sep 16, 2024
Copy link

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.

@shetzel
Copy link
Contributor

shetzel commented Sep 16, 2024

You can use this command: sf project deploy start --dry-run --test-level NoTestRun

@nvuillam
Copy link
Author

@shetzel i know but ... will it allow me to use quickDeploy after ?
I need that :)

@nvuillam
Copy link
Author

@shetzel i made a PR :)

@shetzel
Copy link
Contributor

shetzel commented Sep 17, 2024

@nvuillam that command with --dry-run still does a "check-only" deploy so you can use the ID for the subsequent quick deploy.

See #2688
and #2470 (comment)

@nvuillam
Copy link
Author

@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 ? :)

@shetzel
Copy link
Contributor

shetzel commented Sep 25, 2024

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.

@JaydeepGo
Copy link

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.

@shetzel
Copy link
Contributor

shetzel commented Oct 14, 2024

@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.

https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_deployRecentValidation.htm

@nvuillam
Copy link
Author

@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 :)

  • --test-level must be able to accept "NoTestRun"
  • --ignore-warnings and --ignore-conflicts can be used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating We're actively investigating this issue validated Version information for this issue has been validated
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants