4.5.10 · D4Software Engineering

Exercises — CI - CD — pipeline stages, GitHub Actions - GitLab CI concepts

2,699 words12 min readBack to topic

Before we start, four symbols reappear throughout. Let us earn them once, in plain words, so no line ahead uses an undefined thing:

Figure — CI - CD — pipeline stages, GitHub Actions - GitLab CI concepts

Level 1 — Recognition

Recall Solution 1.1

WHAT the words mean: "merge frequently + auto build + auto test" is exactly the definition of Continuous Integration (CI). Delivery and Deployment are about producing/shipping an artifact, which is not happening here. Answer: CI (Continuous Integration).

Recall Solution 1.2
  • GitHub Actions: WorkflowJobStep.
  • GitLab CI: PipelineStageJob. WHY watch out: the word "Job" sits at different depths in the two systems. In GitLab a Stage groups Jobs; in GitHub a Job groups Steps.
Recall Solution 1.3

WHY this order: cheapest-and-fastest-to-fail goes first so you never pay for slow work when a 2-second check already proves the code is broken (the "shift-left" idea). Answer: Build → Lint → Test → Package → Deploy. Mnemonic from the parent note: Be Lazy, Test, Package, Deploy.


Level 2 — Application

Recall Solution 2.1

WHAT: stages run sequentially — each waits for the previous to pass — so we simply add. WHY add (not max): they are dependent, so no overlap is possible.

Recall Solution 2.2

WHY parallel: the 6 shards are independent, so the only limit is runner availability. Waves: waves. Each wave costs one . Look at figure s01: 3 runners chew through 3 shards per wave, so 6 shards = exactly 2 clean waves.

Recall Solution 2.3

WHAT: caching swaps the repeated, deterministic install for a cheap restore .

  • Before: s.
  • After: s.
  • Saved per run: s.

Level 3 — Analysis

Recall Solution 3.1

(a) min. (b) Waves , so min. Speedup . (c) With : waves still, so min — no change. WHY no change: jobs on runners is one full wave of 5 plus a leftover wave of 3; that leftover wave still costs a whole . See figure s02 — the total-time curve is flat until you reach .

Figure — CI - CD — pipeline stages, GitHub Actions - GitLab CI concepts
Recall Solution 3.2

WHAT is the minimum: the fastest you can ever go is one wave, min, reached when , i.e. . Smallest such : . WHY not : waves → min, still not minimal. So more runners help only up to — the Amdahl-style cap (Amdahl's Law).

Recall Solution 3.3

WHY Test is skipped: stages run sequentially with fail-fast — if an earlier stage fails, later stages are skipped, not run. So Test being "skipped" means an earlier stage went red. Which stage: the Lint / static-analysis stage (it runs before Test). The fix is to read the earliest red stage, not the most visible one. "Passes on my laptop" is irrelevant because the failing stage isn't Test at all.


Level 4 — Synthesis

Recall Solution 4.1

Build and Deploy are sequential single-job stages, so they always add: . (a) Serial Test . Total min. (b) Parallel Test waves min. Total min. (c) Fastest Test = one wave, needs . Then Test min. Total min. WHY the floor is 13, not lower: Build (6) and Deploy (3) are serial and cannot be parallelised here — they set a hard floor of min plus at least one Test wave of .

Recall Solution 4.2

WHAT: each shard saves per run; there are 10 shards and runs. WHY cache: dependency install is repeated, deterministic and large — the textbook memoization candidate (Docker & Containerization caches layers the same way).


Level 5 — Mastery

Recall Solution 5.1

WHAT: even with infinite runners, the parallel part shrinks toward but the serial part stays fixed. (a) Minimum total min (parallel part in the ideal limit). (b) Max speedup . WHY capped: this is Amdahl's Law — the serial fraction sets a hard ceiling; speedup can never exceed no matter how many runners you add. Figure s03 shows the curve flattening toward the 15-min floor.

Figure — CI - CD — pipeline stages, GitHub Actions - GitLab CI concepts
Recall Solution 5.2

Budget for Test: min available. Each wave costs min, so we may afford at most waves (5 waves ; 6 waves ). Waves needed: . Check : waves min. Total . ✓ Check : waves min. Total . ✗ Answer: runners.

Recall Solution 5.3

Why it feels right: the job genuinely needs the value, and the YAML is the config the job reads. Why it is unsafe: the YAML is committed to the repo, so the secret lives in git history forever, readable by anyone who ever clones — even after you "delete" it. Fix: store it in the platform secret store (GitHub: ${{ secrets.API_KEY }}; GitLab: masked CI/CD variable). The runner injects it at run time; it never touches version control. See Version Control & Git Branching on why history is immutable.


Connections

  • Parent topic — CI/CD — every formula here is built from its pipeline model.
  • Amdahl's Law — the hard cap behind exercises 3.1, 3.2 and 5.1.
  • Automated Testing — Unit vs Integration vs E2E — what the parallel shards actually run.
  • Docker & Containerization — why runners are clean containers (exercise 3.3) and how caches work.
  • DevOps Principles & Shift-Left — the philosophy behind "cheapest-fails-first" ordering.
Recall Self-test summary

Serial stages add ::: Parallel jobs in one stage ::: Runners stop helping when ::: (one wave, ) Cache saving per run ::: Amdahl max speedup ::: , e.g.