4.5.10 · HinglishSoftware Engineering

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

1,912 words9 min readRead in English

4.5.10 · Coding › Software Engineering


1. Core definitions


2. Pipeline stages KYA hain? (standard order)

Figure — CI - CD — pipeline stages, GitHub Actions - GitLab CI concepts
Stage WHAT karta hai WHY yahan rakha hai
Source / Trigger Event fire hota hai (push, PR, tag) Bina cause ke kuch nahi chalta
Build / Compile Code ko runnable form mein badlo, deps install karo Jo build hi nahi hoga usse test nahi kar sakte
Lint / Static analysis Style + obvious bugs, koi execution nahi Super sasta, fail fast
Test Unit → integration → e2e Behaviour prove karo; ordered cheap→expensive
Package Artifact banao (image, binary) Sirf tab worth karta hai jab tests pass ho jayein
Deploy (staging) Test environment mein ship karo Prod-jaise conditions mein verify karo
Deploy (prod) Users ko ship karo (gated/auto) Final delivery

3. HOW platforms isko model karte hain

# GitHub Actions — .github/workflows/ci.yml
name: CI
on: [push, pull_request]           # trigger
jobs:
  test:                            # a job
    runs-on: ubuntu-latest         # the runner
    steps:
      - uses: actions/checkout@v4  # reusable action
      - run: npm ci                # build/install
      - run: npm test              # test step
# GitLab CI — .gitlab-ci.yml
stages: [build, test, deploy]      # ordered stages
unit-test:
  stage: test
  script:
    - npm ci
    - npm test
  needs: [build-job]               # DAG dependency

4. Ek chota "derivation": kyun parallelism + caching matter karta hai


5. Worked example: ek failing pipeline padhna


6. Common mistakes (Steel-manned)


Recall Feynman: ek 12-saal ke bachche ko samjhao

Tum aur friends mil ke ek giant LEGO castle banate ho. Jab bhi koi brick add karta hai, ek robot turant check karta hai: kya castle abhi bhi khada hai? kya theek lag raha hai? Agar haan, toh robot castle ki photocopy karta hai aur copy display shelf par rakh deta hai. CI woh robot hai jo har nayi brick fast check karta hai; CD woh robot hai jo safe copies shelf par rakhta hai. Har waqt chhote checks karne se end mein kabhi pata nahi chalta ki poora tower tedha tha.


7. Connections

  • Version Control & Git Branching — pipelines branches/PRs/tags se trigger hote hain.
  • Automated Testing — Unit vs Integration vs E2E — test stage ka dil.
  • Docker & Containerization — runners aur artifacts usually containers/images hote hain.
  • Infrastructure as Code — deploy stages environments ko declaratively provision karte hain.
  • DevOps Principles & Shift-Left — woh philosophy jo CI/CD operationalize karta hai.
  • Amdahl's Law — kyun parallel speedup capped hoti hai.

Flashcards

CI ka kya matlab hai aur iska core idea kya hai?
Continuous Integration — changes ko frequently ek shared branch mein merge karo, har merge auto-build aur auto-test karta hai.
Continuous Delivery aur Continuous Deployment mein kya fark hai?
Delivery mein production se pehle ek manual approval gate hota hai; Deployment bina kisi human gate ke automatically production mein release karta hai.
Pipeline stages ko cheap/fast pehle kyun order kiya jaata hai?
"Fail fast / shift left" — broken code ko sabse saste check (lint) se pakdo slow stages (deploy) ke liye pay karne se pehle.
GitHub Actions hierarchy?
Workflow ➜ Job ➜ Step (ek step ek action use kar sakta hai).
GitLab CI hierarchy?
Pipeline ➜ Stage ➜ Job.
Same stage ke jobs: serial ya parallel?
Parallel; stages khud sequentially chalta hain.
n independent jobs ko m runners par parallel wall-clock time ka formula?
.
n independent jobs ke liye maximum useful runners ki sankhya?
m = n; usse zyada koi extra speedup nahi.
Runner/agent kya hai?
Woh VM/container jo actually pipeline jobs execute karta hai.
Artifact kya hai?
Ek file/output jo ek stage produce karta hai aur baad ke stages ke liye store hoti hai (binary, image, report).
Secrets ko pipeline YAML mein kyun nahi daalna chahiye?
YAML git history mein committed hoti hai; platform ke masked secret store ka use karo.
GitLab CI mein needs: kya enable karta hai?
Ek DAG taaki ek job apni dependencies finish hote hi start ho sake, poore pehle wale stage ka wait kiye bina.
CI mein dependencies cache kyun karo?
Install repeated/deterministic/large hoti hai; cache restore karna (time c ≪ d) har run mein d−c bachata hai.

Concept Map

motivates

includes

includes

frequent merges trigger

ordered set of

ordered by

executed on

produce

packages

modeled in GitHub as

modeled in GitLab as

jobs parallel, stages sequential

Bugs jaldi pakdo to sasta

CI CD robot

Continuous Integration

Continuous Delivery/Deployment

Pipeline

Stages

Shift left cheap fail first

Runner / Agent

Artifact

Workflow to Job to Step

Pipeline to Stage to Job