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

Delta check-deploy and deploy are inconsistent #932

Open
smo17 opened this issue Dec 16, 2024 · 5 comments
Open

Delta check-deploy and deploy are inconsistent #932

smo17 opened this issue Dec 16, 2024 · 5 comments

Comments

@smo17
Copy link

smo17 commented Dec 16, 2024

A few issues found with delta deployment:

  • the workflow yml does not seem to auto-generate the delta package xml on its own (had to generate the xml file from vs code with command "generate package.xml git delta" for check deploy to find changes)
  • deploy does not detect salesforce changes after delta package xml was successful in previous step and validate Ok in salesforce.
  • inconsistency because delta deploy worked successfully once between one org to another, then becomes inconsistent between check and deploy to another org.

Here's the script output example generating the delta package xml from plugin in vscode :

$ sf hardis:project:generate:gitdelta --websocket localhost:2702
[sfdx-hardis] 🦙 Please select a Git branch Look up in VsCode ⬆️
[sfdx-hardis] {"value":"feature/poc-1"}
[sfdx-hardis][command] git checkout feature/poc-1
[sfdx-hardis][command] git pull
[sfdx-hardis][command] git log --pretty=format:òòòòòò %H ò %aI ò %s ò %D ò %b ò %aN ò %aE òò --first-parent
[sfdx-hardis] 🦙 Please select the commit that you want to start from Look up in VsCode ⬆️
[sfdx-hardis] {"value":{"hash":"a766846ddc063972e2933addaa416148df30c89c","date":"2024-12-16T15:34:01+04:00","message":"TECH : Retrieve all DX source metadata","refs":"origin/uat, uat","body":"","author_name":"author_name","author_email":"[email protected]","pos":1}}
[sfdx-hardis] 🦙 Please select the commit hash that you want to go to Look up in VsCode ⬆️
[sfdx-hardis] {"value":{"hash":"e12d3bc189fa92a8015ed95a28915a4eadbf60b1","date":"2024-12-16T15:49:12+04:00","message":"POC - new account auto number field","refs":"HEAD -> feature/poc-1, origin/feature/poc-1","body":"","author_name":"author","author_email":"[email protected]","pos":0}}
[sfdx-hardis][command] git rev-parse --show-toplevel
✔ [sfdx-hardis][command] sf sgd:source:delta --from "a766846ddc063972e2933addaa416148df30c89c" --to "e12d3bc189fa92a8015ed95a28915a4eadbf60b1" --output C:\Users\author\AppData\Local\Temp\sfdx-hardis-8o6a5g --ignore-whitespace --json
[sfdx-hardis] {
  "status": 0,
  "result": {
    "error": null,
    "output": "C:\\Users\\author\\AppData\\Local\\Temp\\sfdx-hardis-8o6a5g",
    "success": true,
    "warnings": [
      "[INFORMATION] sfdx-git-delta v6 is coming soon! Read more and plan your migration: https://github.com/scolladon/sfdx-git-delta/issues/936"
    ]
  }
}

[sfdx-hardis][WARNING] stderr: (node:27972) Warning: Deprecated config name: apiVersion. Please use org-api-version instead.
(Use `node --trace-warnings ...` to show where the warning was created)

[sfdx-hardis] Generated diff package.xml at C:\Users\author\AppData\Local\Temp\sfdx-hardis-8o6a5g\package\package.xml

Generated delta xml :

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Account.AutoNumber__c</members>
        <name>CustomField</name>
    </types>
    <version>62.0</version>
</Package>

But when deploy workflow was executed, no changes were detected.
its strange because same commit diff was used as in local version.
compare commit diff sha from above and deploy logs from workflow in github:

[sfdx-hardis] [DeltaDeployment] Delta deployment has been explicitly enabled with variable ALWAYS_ENABLE_DELTA_DEPLOYMENT=true
[sfdx-hardis] [DeltaDeployment] It is recommended to use delta deployments for merges between major branches, use this config at your own responsibility
[sfdx-hardis][command] git log --pretty=format:òòòòòò %H ò %aI ò %s ò %D ò %b ò %aN ò %aE òò uat..feature/poc-1
[sfdx-hardis][command] git merge-base uat feature/poc-1
[sfdx-hardis] [DeltaDeployment] Generating git delta package.xml and destructiveChanges.xml ...
[sfdx-hardis][command] git rev-parse --show-toplevel
- [sfdx-hardis][command] sf sgd:source:delta --from "a766846ddc06[39](https://github.com/smo17/myci/actions/runs/12352063586/job/34468288498#step:5:40)72e2933addaa416148df30c89c" --to "e12d3bc189fa92a8015ed95a28915a4eadbf60b1" --output /tmp/sfdx-hardis-nd4nu --ignore-whitespace --json
9m [sfdx-hardis][command] sf sgd:source:delta --from "a766846ddc063972e2933addaa416148df30c89c" --to "e12d3bc189fa92a8015ed95a28915a4eadbf60b1" --output /tmp/sfdx-hardis-nd4nu --ignore-whitespace --json
[sfdx-hardis] {
  "status": 0,
  "result": {
    "error": null,
    "output": "/tmp/sfdx-hardis-nd4nu",
    "success": true,
    "warnings": [
      "[INFORMATION] sfdx-git-delta v6 is coming soon! Read more and plan your migration: https://github.com/scolladon/sfdx-git-delta/issues/936"
    ]
  }
}

Warning: dis][WARNING] stderr: (node:2469) Warning: Deprecated config name: apiVersion. Please use org-api-version instead.
(Use `node --trace-warnings ...` to show where the warning was created)

[sfdx-hardis] Keeping package.xml items matching with packageDelta.xml (and remove the rest)...
[sfdx-hardis] Found type CustomField, 0 items have been removed
[sfdx-hardis] [DeltaDeployment] Final Delta package.xml to deploy:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <version>62.0</version>
</Package>
[sfdx-hardis] Empty package.xml: nothing to deploy
[sfdx-hardis] No deployment to perform

Now, for inconsistency part is when check_deploy finds delta but deploy does not, this is what can be seen in the workflow logs:

[sfdx-hardis] [DeltaDeployment] Delta deployment has been explicitly enabled with variable ALWAYS_ENABLE_DELTA_DEPLOYMENT=true
[sfdx-hardis] [DeltaDeployment] It is recommended to use delta deployments for merges between major branches, use this config at your own responsibility
[sfdx-hardis] [DeltaDeployment] Generating git delta package.xml and destructiveChanges.xml ...
[sfdx-hardis][command] git rev-parse --show-toplevel
- [sfdx-hardis][command] sf sgd:source:delta --from "HEAD" --to "HEAD^" --output /tmp/sfdx-hardis-g57qwq --ignore-whitespace --json
9m [sfdx-hardis][command] sf sgd:source:delta --from "HEAD" --to "HEAD^" --output /tmp/sfdx-hardis-g57qwq --ignore-whitespace --json
[sfdx-hardis] {
  "status": 0,
  "result": {
    "error": null,
    "output": "/tmp/sfdx-hardis-g57qwq",
    "success": true,
    "warnings": [
      "[INFORMATION] sfdx-git-delta v6 is coming soon! Read more and plan your migration: https://github.com/scolladon/sfdx-git-delta/issues/9[36](https://github.com/smo17/myci/actions/runs/12353490820/job/34472713446#step:6:37)"
    ]
  }
}

Warning: dis][WARNING] stderr: (node:2428) Warning: Deprecated config name: apiVersion. Please use org-api-version instead.
(Use `node --trace-warnings ...` to show where the warning was created)

[sfdx-hardis] Keeping package.xml items matching with packageDelta.xml (and remove the rest)...
[sfdx-hardis] [DeltaDeployment] Final Delta package.xml to deploy:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <version>62.0</version>
</Package>
[sfdx-hardis] Empty package.xml: nothing to deploy
[sfdx-hardis] No deployment to perform

Any idea what can be the cause of the issue?
Thanks

@nvuillam
Copy link
Member

nvuillam commented Dec 16, 2024

Hi @smo17

I see you use ALWAYS_ENABLE_DELTA_DEPLOYMENT , forcing the delta between major orgs
This part of the feature has been quickly tested ... and your feedback show that such problem should be investigated

Meanwhile please can you try removing ALWAYS_ENABLE_DELTA_DEPLOYMENT and use delta only for feature branch to major branches ?

Otherwise, you can also configure integration with the git platform you use, and it will allow to use QuickDeploy on the previously run deployment simulation

@smo17
Copy link
Author

smo17 commented Dec 17, 2024

Actually, I am looking for CICD solution for delta deployment across all branches, main reason being to reduce deployment times.
I may have identified part of the root cause of the issue and it seems to be linked with how the dependent sfdx-git-delta plugin works.
Found this blog talking about sfdx-git-delta
https://www.salesforceben.com/salesforce-gitlab-delta-deployment-the-easy-way/

In the deploying chapter, it says

The solution is to use the HEAD to HEAD-1 comparison. This is why, before you perform the merge, it is essential that you squash the commits! By doing so, the HEAD-1 will contain all the modifications from all your commits

I will do a few tests later to check if deploy workflow works better to calculate delta files changes if when merging PR, the option to squash commits is enabled.

@nvuillam
Copy link
Member

Squashing commit is great for the first level (feature branche to integration branche for example), but if you squash between major branches, it can generate git conflicts that will complicate your work ^^

What is the total deployment time on your project ?

@smo17
Copy link
Author

smo17 commented Dec 18, 2024

Oh thanks for the heads up about squash commits.
Large projects have a lot of metadata so it depends, it can take more than 30 mins to deploy all metadata and with test class.
it is not feasible to wait such a long time for releases in production especially if we have to fix things when deploy fails.

@nvuillam
Copy link
Member

I've seen projects with 1h30 for deployment + tests, it happens ... but it's the safest way to not break your production :)

The main advantage of working with CI/CD is that you will know in advance that your deployment to production will pass :)

To summarize:

  • feature branch to major branch (integration, for example): use delta
  • integration to UAT branch: use full
  • uat to preprod: use full
  • preprod to production: use full

You can also have a RUN cycle, that will be faster ( see details here -> https://sfdx-hardis.cloudity.com/salesforce-ci-cd-hotfixes/ )

When you know that you'll have to deploy in production on thursday, you can create a draft Pull Request from preprod to main branch on tuesday, and if there are issues (there shouldn't, as your sources must be clean from the first PR merge), you have 2 days to fix them :)

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

No branches or pull requests

2 participants