What is GitHub Actions' matrix strategy used for?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Matrix strategy is how you run the same job against multiple configurations without duplicating code. Define 'os: [ubuntu, windows, macos]' and GitHub spawns three parallel jobs — one per OS. Perfect for compatibility testing.
Full explanation below image
Full Explanation
The matrix strategy in GitHub Actions allows a single job definition to be run multiple times with different input variables. You define a 'matrix' of values (e.g., operating systems, language versions, feature flags) and GitHub automatically creates job instances for each combination. For example, a matrix of 3 OS values × 3 Node.js versions = 9 parallel job runs. This is commonly used for cross-platform testing, multi-version compatibility checks, and parameterized build variations. The 'include' and 'exclude' options allow fine-tuning the matrix combinations. Matrix jobs count against concurrency limits and runner availability.