hardisgroupcom / sfdx-hardis

Swiss-army-knife Toolbox for Salesforce. Orchestrates base commands and assist users with interactive wizards to make much more than native sfdx + Allows you to define a complete CI/CD Pipeline and Schedule a daily Metadata backup & monitoring of your orgs
https://sfdx-hardis.cloudity.com
GNU Affero General Public License v3.0
194 stars 35 forks source link

Scratch Org - Expiration & Push Sources #566

Closed gabeclarke closed 6 months ago

gabeclarke commented 7 months ago

Hi, first- love the work you have done! It's amazing how much simpler this makes standing up a ci/cd pipeline.

I did have a question or two, on this page https://sfdx-hardis.cloudity.com/hardis/scratch/create/

when running the hardis:scratch:create command (or through the UI) during the "push sources" step, how do you determine what package to attempt to deploy to the scratch org? It does not appear to be based on the package.xml in the branch at time of scratch org creation. Is it based on some variable in .sfdx-hardis.yml?

In addition, is there a way to manipulate the expiry date for the scratch org running this command (or through the UI)? I have tried setting the variable in the project-scratch json but the hardis:scratch:create command does not seem to take it into account and defaults to 30 days each time.

Thanks!

nvuillam commented 7 months ago

@gabeclarke > The packages that will be installed are in config/.sfdx-hardis.yml , in installedPackages property, as in the following example

image

You can automatically fill this property by using the following command in VsCode sfdx-hardis menu (with your org where packages are installe as the default org)

image

About duration, it is defined with the following line

this.scratchOrgDuration = (process.env.SCRATCH_ORG_DURATION || isCI) && this.pool === false ? 1 : 30;

It means that you can override it by defining an env variable SCRATCH_ORG_DURATION=10 for example

Maybe it would be easier to override if we can define it in .sfdx-hardis.yml ? If so I can make a PR, or you can even do it if you are in a hurry :) ( i'll provide guidance)

gabeclarke commented 6 months ago

Thanks so much for the fast response! I think I was a bit too rushed with my word choice in my initial question.

After the packages identified in config/.sfdx-hardis.yml are installed, I believe there is a follow up step called Push Sources. Where does hardis:scratch:create determine these sources to push? Does it try to deploy everything from the devhub to the scratch org, or everything in my current branch? I'm probably missing something obvious there but appreciate any guidance you can give!

On the topic of scratch org duration, I would love to submit a PR for it as an env variable. I think this is something my team will tweak frequently when we spin up scratch org pools so we will definitely get value out of it.

nvuillam commented 6 months ago

@gabeclarke it's exactly the same than when you call sfdx force:source:push from your local computer: it will push

If you are reusing a scratch org (after a PR for example), it will push only the diff since your last push :)

Note: equivalent of sfdx force:source:push with SF CLI v2 seems to be sf project deploy start --target-org myscratch --ignore-conflicts --wait 10

nvuillam commented 6 months ago

@gabeclarke your PR has been released in 4.28.4 :)

Please can you confirm it's ok with scratchOrgDuration in .sfdx-hardis.yml ? :)

gabeclarke commented 6 months ago

Yes thanks, I can confirm the variable works as expected!