Back
+20 XP
Concept

CI Workflows & Test Matrix Architecture

Continuous Integration pipelines test software across operating systems (Ubuntu, Windows, macOS) and Python versions (3.10–3.13) in parallel matrices, preventing OS-specific regressions from contaminating main branches 🚀.

python
# GitHub Actions matrix Cartesian product:
matrix = {
    "os": ["ubuntu-latest", "windows-latest", "macos-latest"],
    "python": ["3.11", "3.12", "3.13"]
}

total_jobs = len(matrix["os"]) * len(matrix["python"])
print(f"Matrix spawns {total_jobs} parallel runner jobs 🚀")

# 105. CI Workflows & Test Matrix Architecture Continuous Integration pipelines test software across operating systems (Ubuntu, Windows, macOS) and Python versions (3.10–3.13) in parallel matrices, preventing OS-specific regressions from contaminating main branches 🚀. ```python # GitHub Actions matrix Cartesian product: matrix = { "os": ["ubuntu-latest", "windows-latest", "macos-latest"], "python": ["3.11", "3.12", "3.13"] } total_jobs = len(matrix["os"]) * len(matrix["python"]) print(f"Matrix spawns {total_jobs} parallel runner jobs 🚀") ``` Pairing matrix testing with automated coverage uploads (Codecov, Coveralls) enforces minimum quality gates (e.g. "PR rejected if test coverage drops > 1%") on every commit 🛡️! --- ### Question Why must cross-platform libraries run CI test suites across an OS matrix instead of testing only on Linux? 🧠 - [ ] a. File path separators, process spawn models (`fork` vs `spawn`), and socket implementations differ across OS kernels 🚀 - [ ] b. GitHub Actions charges zero runner minutes if three OS types are included - [ ] c. Python is mathematically incapable of compiling wheels on a single operating system - [ ] d. Windows cannot run Python without an active Azure cloud subscription --- ### Challenge Given `matrix = {'os': ['ubuntu', 'windows', 'macos'], 'py': ['3.11', '3.12', '3.13']}`, calculate and print the total number of matrix combinations. 🎯 <details> <summary>Solution</summary> ```python matrix = {'os': ['ubuntu', 'windows', 'macos'], 'py': ['3.11', '3.12', '3.13']} print(len(matrix['os']) * len(matrix['py'])) ``` </details>

Checkpoint

Why must cross-platform libraries run CI test suites across an OS matrix instead of testing only on Linux? 🧠

Practice

Given `matrix = {'os': ['ubuntu', 'windows', 'macos'], 'py': ['3.11', '3.12', '3.13']}`, calculate and print the total number of matrix combinations. 🎯

Terminal
01
Tap code blocks below to assemble
Available Blocks