Post

Apply Source Patches Once in Build Preparation

Apply Source Patches Once in Build Preparation

I removed duplicate patch preflight checks from the homelab build preparation scripts so each checked patch is applied once, and I expanded the source test to cover the resulting command sequence and failure behavior.

Single patch application in prepare-source scripts

In builds/harbor-core/prepare-source.py and builds/nofx/prepare-source.py, I removed the separate git apply --check invocation that ran before the real apply. The build now relies on the actual patch application to validate each patch, avoiding a second pass over the same patch set. The commit subject is refactor(build): apply checked source patches once.

Failure coverage in harbor-core source test

I updated scripts/ci/harbor-core-source-test.py to assert the exact git apply sequence for the four patches instead of only counting calls. I also added a case where one patch touches an existing file and a missing file; the test expects subprocess.CalledProcessError, the original source to remain unchanged, and no Dockerfile to be created. This is a test change, not evidence that the suite has run.

Platform engineering transfer

A platform team can use this pattern when build steps validate external source: remove redundant preflight checks, keep one apply path, and test both the command order and the no-partial-output behavior on failure. The next check is to run the updated source test in CI and confirm the failure case leaves the workspace clean.

This post is licensed under CC BY 4.0 by the author.