Reviewer · CI/CD
Guard against silent CI failures
CI/CD scripts must be written so that partial failures or state changes don't silently produce misleading success results. Specifically: 1. **Cleanup/trap logic must run in the correct context.** If a script `cd`s into another directory (e.g., to clone and build a dependency), any `trap ... EXIT` or cleanup function that uses relative paths (artifact...
CI/CD scripts must be written so that partial failures or state changes don’t silently produce misleading success results. Specifically:
- Cleanup/trap logic must run in the correct context. If a script
cds into another directory (e.g., to clone and build a dependency), anytrap ... EXITor cleanup function that uses relative paths (artifact uploads, globs) must first restore the original working directory, or use absolute paths. Otherwise the glob silently matches nothing, the step appears to pass, and no artifact/comment is ever produced.
cleanup() {
local exit_status=$?
cd "$KIBANA_DIR" # restore context before using relative paths
buildkite-agent artifact upload "target/.../**/*" || true
...
}
trap cleanup EXIT
-
Guard destructive/bulk actions (e.g.
--prune, label deprecation) against partial success. If a step depends on multiple independent sources (e.g. EIS models + LLM Gateway models) and only some succeed, do not run a global prune/cleanup that treats the missing source’s data as “stale” — this can incorrectly delete or deprecate valid state. Only enable such actions when all expected sources reported successfully. -
Make retries and idempotency keys scoped correctly. When a script can be retried (e.g. a build job retry), base idempotency keys or session identifiers on the unique retry unit (job ID), not a shared build ID, so a retried job doesn’t incorrectly reuse another attempt’s session/state.
-
Propagate consistent identifiers across distributed steps. When a pipeline resolves state once (e.g. a SHA, branch name, build ID) and passes work to later, independently-run steps, pass that resolved identifier explicitly instead of letting each step re-resolve it independently (e.g. via
git rev-parsein a detached checkout, which can yieldHEADinstead of the real branch). This keeps results reproducible and comparable across runs, and avoids drift when the referenced dependency changes between steps.
Avoid swallowing errors with || true or similar without first confirming the operation’s preconditions are met; prefer explicit checks and clear warnings/failures over quietly skipping expected side effects.