teluzia.Cloud Engineer · Day 107
CHAPTER 16 · CI/CD AND AUTOMATED DEPLOYMENTS

Build and test pipelines

4–5 hours including independent practice3 topics
LET’S MAKE THIS SIMPLE

What you’re learning today

A build-test pipeline is a quality checkpoint that ties a finished artifact to the exact source revision examined. Build from a defined checkout with controlled toolchain and dependencies. Record revision and artifact identity. A fresh runner helps expose accidental reliance on local files, but downloads and mutable dependencies still require control. The build’s success indicates artifact creation, not all functional correctness. Tests should check meaningful behavior, including representative errors. Commands must propagate nonzero exits so the workflow fails on broken behavior. Merely invoking a tool without checking output can create misleading green status. Distinguish unit, integration, and deployment validation coverage.

Think of it this way

A build-test pipeline is a quality checkpoint that ties a finished artifact to the exact source revision examined.

TOPIC 01 / 03Step by step

Build reproducibility

Build from a defined checkout with controlled toolchain and dependencies. Record revision and artifact identity. A fresh runner helps expose accidental reliance on local files, but downloads and mutable dependencies still require control. The build’s success indicates artifact creation, not all functional correctness. For example, a Python package build records the commit SHA and dependency lock input used by the job.

WORKED EXAMPLE
A Python package build records the commit SHA and dependency lock input used by the job.

A build starts from a particular commit, not an assumed latest branch state. It selects a documented toolchain, resolves controlled dependencies, and produces an artifact. Record those inputs so a later failure can be traced to the exact source and environment. A clean runner often reveals missing files that a developer's laptop accidentally supplied.

Reproducibility means repeating a build under stated inputs yields the intended artifact behavior. A lock file constrains dependency selection where supported. A revision identifies source content. Cached dependencies improve speed but should not replace integrity checks or mask incompatible input changes. A pipeline can build successfully while using a different package version than a prior run if inputs are mutable. Control meaningful inputs and update them deliberately. Do not claim byte-for-byte reproducibility unless it was actually demonstrated; ordinary reproducible behavior and fully deterministic bytes are related but distinct goals.

Why this matters

A Python package build records the commit SHA and dependency lock input used by the job.

A common trap

Do not overlook this operational distinction: The build’s success indicates artifact creation, not all functional correctness.

MAKE IT VISIBLE

Rehearse a release decision

A RELEASE IS A SERIES OF DECISIONS

Can you ship without losing the old version?

This browser simulation shows why tests, plan review, health validation and rollback belong in a pipeline.

1Tests
2Plan review
3Deploy
4Health check
Currently serving: v1

Ready to run

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

Build reproducibility

Build from a defined checkout with controlled toolchain and dependencies. Record revision and artifact identity. A fresh runner helps expose accidental reliance on local files, but downloads and mutable dependencies still require control. The build’s success indicates artifact creation, not all functional correctness. For example, a Python package build records the commit SHA and dependency lock input used by the job.

WORKED EXAMPLE
A Python package build records the commit SHA and dependency lock input used by the job.

A build starts from a particular commit, not an assumed latest branch state. It selects a documented toolchain, resolves controlled dependencies, and produces an artifact. Record those inputs so a later failure can be traced to the exact source and environment. A clean runner often reveals missing files that a developer's laptop accidentally supplied.

Reproducibility means repeating a build under stated inputs yields the intended artifact behavior. A lock file constrains dependency selection where supported. A revision identifies source content. Cached dependencies improve speed but should not replace integrity checks or mask incompatible input changes. A pipeline can build successfully while using a different package version than a prior run if inputs are mutable. Control meaningful inputs and update them deliberately. Do not claim byte-for-byte reproducibility unless it was actually demonstrated; ordinary reproducible behavior and fully deterministic bytes are related but distinct goals.

Why this matters

A Python package build records the commit SHA and dependency lock input used by the job.

A common trap

Do not overlook this operational distinction: The build’s success indicates artifact creation, not all functional correctness.

Tests and failure propagation

Tests should check meaningful behavior, including representative errors. Commands must propagate nonzero exits so the workflow fails on broken behavior. Merely invoking a tool without checking output can create misleading green status. Distinguish unit, integration, and deployment validation coverage. For example, python3 -m unittest -v exits unsuccessfully when an assertion fails, allowing the job to reject that revision.

WORKED EXAMPLE
python3 -m unittest -v exits unsuccessfully when an assertion fails, allowing the job to reject that revision.

A unit test invokes a calculation with valid input and checks its result, then invokes invalid input and checks the intended exception. The test runner exits nonzero when behavior violates those assertions. The workflow must preserve that exit status so a failed required test stops advancement. Piping through another command or broad error suppression can accidentally conceal failure.

An assertion checks an expected condition. Exit status tells the surrounding process whether a command succeeded. Coverage identifies which behavior the checks exercise. A green test suite only proves those selected checks passed under those inputs. Integration tests add service-boundary evidence, while deployment checks add runtime evidence. Avoid tests that merely repeat implementation statements without a meaningful independent expectation. Capture useful reports and failing input identifiers without retaining credentials. A small relevant test is stronger than many tautological checks that keep passing when the intended user outcome breaks.

Why this matters

python3 -m unittest -v exits unsuccessfully when an assertion fails, allowing the job to reject that revision.

A common trap

Do not overlook this operational distinction: Distinguish unit, integration, and deployment validation coverage.

Artifacts and evidence

Transfer explicit build outputs between jobs using artifacts or a registry rather than rebuild an untracked replacement during deployment. Preserve test reports and diagnostic metadata while excluding credentials. A deployable artifact should be the artifact that passed the required checks for the recorded revision. For example, the deploy job downloads the tested package and verifies its checksum instead of building again from a moved branch.

WORKED EXAMPLE
The deploy job downloads the tested package and verifies its checksum instead of building again from a moved branch.

The build job produces package P and its checksum, then stores them as a workflow artifact. Tests exercise P or the relevant build output. The release job retrieves that same identified output and verifies it before publication. Rebuilding from a branch during deployment can produce package Q, severing the connection between test evidence and released content.

An artifact is an output transferred between stages. A checksum helps detect content mismatch. A release record connects source revision, output identity, and checks. Artifact retention should preserve useful diagnostics without unnecessary private data. Registry digests can serve the same identity purpose for container releases. A checksum alone does not establish trustworthy origin if an attacker can replace both file and checksum, so combine it with controlled workflow and permissions. Build once and promote deliberately, recording where configuration differs without mutating the tested binary or image unexpectedly.

Why this matters

The deploy job downloads the tested package and verifies its checksum instead of building again from a moved branch.

A common trap

Do not overlook this operational distinction: A deployable artifact should be the artifact that passed the required checks for the recorded revision.

KEEP THESE WITH YOU

Today’s takeaways

Build reproducibility: Build from a defined checkout with controlled toolchain and dependencies. Record revision and artifact identity. A fresh runner helps expose accidental reliance on local files, but downloads and mutable dependencies still require control. The build’s success indicates artifact creation, not all functional correctness.

Tests and failure propagation: Tests should check meaningful behavior, including representative errors. Commands must propagate nonzero exits so the workflow fails on broken behavior. Merely invoking a tool without checking output can create misleading green status. Distinguish unit, integration, and deployment validation coverage.

Artifacts and evidence: Transfer explicit build outputs between jobs using artifacts or a registry rather than rebuild an untracked replacement during deployment. Preserve test reports and diagnostic metadata while excluding credentials. A deployable artifact should be the artifact that passed the required checks for the recorded revision.

CLOSE THE LOOP

Ready to complete this day?

Verify the practical steps and pass the knowledge check (at least two thirds correct).

Lab steps verifiedKnowledge check passed