The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

How CI should handle stale pushes queued behind a Salesforce deployment (opens in a new tab)

You will learn the three policies for dealing with superseded pushes while a Salesforce deployment is running, and the condition that decides which are safe.

Why read this

You will also see why cancelling a deployment is only a request to Salesforce.

State-based jobs

  • Compare the whole branch with the org
  • Skipping a push is safe
  • The sha is only a label

Delta-style jobs

  • Deploy only one push's files
  • Skipping a push drops its changes
  • Safe only if bundled into the next run
State-based and delta-style jobs respond differently when a push is skipped

Salesforce allows one deployment per org at a time, and a deployment with tests can take a long time. When new commits arrive during a running deployment, a pipeline that runs every job in order can spend most of its time deploying changes that a later push already contains. The article uses a 25-minute deployment and three pushes as its example, and notes that the third push would go live an hour after it was made.

The article sets out three policies. Running every job keeps a record of each merge and suits production deployments. Skipping stale waiting jobs drops the middle push but lets the running job finish, which suits busy orgs. Latest wins cancels the running job and drops the waiting ones, which suits validations on pull request or integration branches where only the newest commit matters.

The deciding condition is whether each job deploys the whole branch or only the files changed in one push. State-based jobs compare the whole branch with the org, so skipping an intermediate push is safe. Delta-style jobs deploy only one push’s changes, so skipping one would drop them unless the tool bundles them into the next run. The article also warns that cancelling is a request to Salesforce, not an instant stop, and that a small deployment can finish before the cancel arrives. Building this with GitHub Actions concurrency stops the workflow but not a deployment already submitted to Salesforce, so the script must send the cancel and wait for confirmation.

The article closes with rules for any pipeline: supersede only within the same source, handle validations and deployments separately, never supersede a rollback, and provide a way to move an urgent job to the front. Its suggested default is latest wins for validations and run every job for production deployments. The piece is written by the author of Diffbridge and includes a description of how that tool implements these options.

Read the original at dev.to (opens in a new tab)

Worth reading?

Must-read

Sharding Apex tests across CI jobs with renmy runtime (opens in a new tab)

You will learn how to split one Apex test suite into parallel slices across CI runners, how classes are balanced by recorded duration, and when sharding is not worth the overhead.

Why read this

The article gives a working GitHub Actions matrix and explains how to merge the JUnit results.

  1. Balance classes by recorded duration
  2. Run each slice on its own CI job
  3. Merge the shard JUnit XML results
Sharding assigns each test class to exactly one runner, then the results are merged

The article explains how to split one Apex test suite into parallel slices across CI runners using renmy runtime, a local Salesforce Apex runtime from Renmy UG that runs tests on the CI machine against an embedded PostgreSQL instead of in a Scratch Org or sandbox. The author argues that sharding was impossible in an org-based workflow, because every extra runner would need its own org, deploy and place in the org’s test queue. With a local runtime, the command renmy test –shard N/M runs one slice of the suite, and the wall-clock time falls to roughly the slowest shard plus setup, though total compute rises slightly. The runtime was previously called Nimbus, and the author notes that this is the same tool under a new name.

Sharding works at the level of whole test classes, so each class’s @testSetup runs once and its records remain consistent with an unsharded run. Classes are balanced using durations recorded in .nimbus/test-durations.json, and projects without that history fall back to an even split by class name. Because each shard computes the partition independently, every job must see the same durations file, which the author recommends committing or restoring from a cache. The article supplies a GitHub Actions matrix with fail-fast disabled, a per-shard JUnit file, and an always-run publishing step. It also shows how to merge results either through the shard attribute that the JUnit XML carries or by uploading artifacts and publishing them from a job that runs after the matrix.

The piece also covers coverage and caching. A shard measures coverage only for the tests it runs, so whole-suite coverage needs a single process, and the article points to renmy deploy –min-coverage and renmy coverage diff for gating. Shards can share a cache of parsed ASTs and the binary to reduce cold-start time.

Finally, the author warns that sharding is not worth its overhead for suites that finish within about a minute, since each shard repeats checkout, installation and database startup. Alternatives suggested first are parallel workers within one job, caching, and an external PostgreSQL service container. Sharding is recommended when the test step alone runs for several minutes. A slow class sets a floor on its shard’s time, and order-dependent tests can surface when classes move between shards. Running on a CI runner belongs to the Team tier, which is free during the public beta, and JUnit and Cobertura output are Pro features.

Read the original at dev.to (opens in a new tab)

Worth reading?