Skip to content

Architecture / Decision records / ADR-HIS-114

ADR-HIS-114 The pull request pipeline on a shared host: Semgrep scans the files a change adds or modifies, the checks that build nothing share one job, and a Gradle build is held to two workers

Status Accepted
Decided 2026-12-01 by the pipeline change pipeline/faster-static-analysis
Record Drafted 2026-12-01; approved 2026-12-02 by the Enterprise Architecture Board
Where the rule lives platform/delivery-pipeline/lib/plan.py (static_files), platform/delivery-pipeline/bin/static-analysis (--files), platform/delivery-pipeline/bin/build-test (HIS_GRADLE_WORKERS), .github/workflows/pipeline.yml (checks, static-analysis)

Context

ADR-HIS-046 set up the pull request pipeline. Since 2026-11-26 its jobs run on self-hosted runners that share one 4-core host with each other and with the agent sessions (ADR-HIS-072). The runs of 2026-11-30 and 2026-12-01 took 33 to 77 minutes from start to end, while their jobs added up to 8 to 29 minutes. The rest was jobs waiting for a runner: short checks waited up to 33 minutes behind a long build.

Two things used most of the host's time without need: - Static analysis scanned whole folders. The static-analysis job passed Semgrep every build folder of the change, together with the folders the plan adds: a change to a screen added web/shell, and a change to web/design-system added every web package. A change of a few files took 6 to 11 minutes of Semgrep on the loaded host. - Three checks that build nothing took three runner slots. secret-scan, protected-files and link-check each took a runner, a checkout of the full history and a place in the queue, for under a minute of work each.

Decision

  1. Semgrep scans the files the change adds or modifies.
  2. The plan gives a new list, static_files: the changed files outside the documentation that still exist and are not links.
  3. bin/static-analysis --files <list> gives Semgrep those files only. As before, the scan runs on a copy that leaves out every .semgrepignore and carries the pipeline's own ignore list.
  4. The rules of Semgrep's open repository and the project's rules in semgrep/his.yml look at one file at a time. So a file the change leaves alone has no new finding, and it was scanned when the change that last touched it was merged.
  5. Without --files, the script scans its targets whole, as before. A developer uses this to scan a folder on their own host.
  6. The clinical artifacts are still validated in every folder the change touches (the plan's static, unchanged). A clinical template names its schema in another file, so a change to a schema can break a template the change does not touch.
  7. One checks job. It runs the secret scan, the protected-files check and the link check as steps of one job, on one checkout of the full history. A step runs even when an earlier one failed, so one run reports every check. The scripts and when each one runs are unchanged. The launcher reads every check run of a commit (launch_sessions.py checks), so a failing step still stops the merge.
  8. A Gradle build in build-test runs with --max-workers=2 (HIS_GRADLE_WORKERS changes it). By default, Gradle runs as many workers as the host has cores, and two Java jobs at once, beside the sessions, ask for twice the host's 4 cores. A Semgrep scan is held to two cores for the same reason. Measured on the runner host on 2026-12-01: full rebuilds of services/ess-runtime-decision (--rerun-tasks --no-build-cache), alternating the two settings.
Round Default (4 workers) 2 workers Load average during the run
1 1,624 s 1,289 s 40 to 6 during the default run, so this round cannot be compared
2 1,060 s 1,002 s 12 to 8, then 8 to 5

At comparable load, two workers were not slower (5% faster, within the noise of a shared host). The reason to keep the setting is the room it leaves to the other runner and the sessions. One build at a time was measured, so that effect is not.

Consequences

  • On the run of 2026-12-01 for a change in web/domains/adm, Semgrep scanned the whole of web/domains/adm and web/shell (10 minutes). Most of such a run was Semgrep loading its rules, not scanning: a scan of platform/supply-chain spent 510 s loading the rules and 28 s scanning (ADR-HIS-119, which bundles the rules). Scanning fewer files saves the scanning part, and the two decisions combine. Under this decision it scans only the changed screen files. A run takes two runner slots fewer.
  • A finding already on main in a file the change does not touch is not reported again on that change. A new rule from a newer pinned rule commit therefore does not find old code until that code changes. A rule upgrade is a pipeline change, which can scan the whole repository on its own host (bin/static-analysis services web platform contracts e2e).
  • The job names secret-scan, protected-files and link-check are now steps of checks. The evidence check names of a release (README.md, "The release pipeline") are not job names and do not change.
  • When the pipeline moves to GitLab (ADR-HIS-038), checks is one job with three script lines, and static_files is one more key of the plan's dotenv artifact.