When I save a class in the developer console, it is pretty fast, is there a way to emulate the same with an ant deployment?
When you save a class in the Developer Console, the remainder of your metadata is already present in the org. Scratch orgs always start from an empty slate, so you must perform all of the required deployments to populate the org with metadata.
I see a couple of potential routes to achieve speedups here, but nothing that's going to be a silver bullet. One key question for me is what exactly the relationship is between these repos, and what stage you're at in the development process when a PR is made against one of them. You definitely want to do a full test pass across your entire application before you move to production, and it is beneficial to get that pass done as early in the development lifecycle as possible to catch bugs early.
Flatten your dependency tree/increase the modularity of your code. If you can reduce the scope of metadata that needs to be deployed just to effectively test changes in one module, you may be able to dramatically reduce your overall build times.
For example, if you have nine modules, and eight of them simply depend upon a single base module (rather than depending upon one other as well), you may be able to reduce the scope of deployment required for feature tests, and reserve deploying the whole application for an integration test pass. Each PR would just test the module changed with that base module, rather than deploying all nine modules.
- Ensure that you are not repeatedly running the same tests. For example, if your deploys are all running with
RunAllTests
test level, you're burning excess time running the same tests over and over again.
- Prebuild and cache scratch orgs with everything save one module deployed so that you can quickly deploy just one module and test it. It's a little harder for me to see how this would work in your situation, but it's something worth considering depending on the overall shape of your development process - particularly if these repos actually do build packages rather than just unmanaged deployments. Having nine modules would definitely increase the complexity of building this out and cost you more scratch orgs.
Incidentally, there is really no reason to use Ant deployments with scratch orgs. Salesforce DX itself is perfectly capable of deploying both Metadata API source and Salesforce DX format source, and that would mean that you need only one tool.
70-80 minutes is not an outrageous time for a very large, very complex project to do a complete org build. I think the key here is going to be understanding what you actually have to deploy to create a viable test org for each change that's made.
-l RunLocalTests
ant
then check fortestLevel
in antsf:deploy
.