Discover the number of builds generated by a GitHub Actions matrix configuration featuring two operating systems (ubuntu-latest and windows-latest) and three Node.js versions (14.x, 16.x, and 18.x). Learn how to calculate the total number of builds for effective CI/CD pipeline setup.
Table of Contents
Question
How many builds will the following matrix produce? os: [ubuntu-latest, windows-latest] node-version: [14.x, 16.x, 18.x]
A. 6
B. 3
C. 5
Answer
A. 6
Explanation
Each operating system is paired with each version of Node for a total of 6 builds.
In the given matrix configuration, there are two variables: `os` and `node-version`. The `os` variable has two values: `ubuntu-latest` and `windows-latest`. The `node-version` variable has three values: `14.x`, `16.x`, and `18.x`.
GitHub Actions creates a build for each combination of the values provided in the matrix. To calculate the total number of builds, you need to multiply the number of values for each variable.
In this case:
- `os` has 2 values
- `node-version` has 3 values
The total number of builds is calculated as follows:
2 (os values) × 3 (node-version values) = 6 builds
Therefore, the matrix will produce 6 builds, with each build running on a different combination of operating system and Node.js version:
- ubuntu-latest with Node.js 14.x
- ubuntu-latest with Node.js 16.x
- ubuntu-latest with Node.js 18.x
- windows-latest with Node.js 14.x
- windows-latest with Node.js 16.x
- windows-latest with Node.js 18.x
Using a matrix in GitHub Actions allows you to test your code on multiple configurations simultaneously, ensuring compatibility across different environments.
GitHub Actions certification exam assessment practice question and answer (Q&A) dump including multiple choice questions (MCQ) and objective type questions, with detail explanation and reference available free, helpful to pass the GitHub Actions exam and earn GitHub Actions certification.