GH-200 - Author and manage workflows - Section 1.5

Generate job variations with strategy and matrix, applying include and exclude, fail-fast and max-parallel to control build coverage and cost.

Generate parallel job variations with strategy and matrix, and use include to add combinations and exclude to remove them. Tune fail-fast and max-parallel to balance coverage against runner cost and build time.

strategy matrixinclude and excludefail-fastmax-parallel

Practice question for this objective

Free sampleAuthor and manage workflowshard

A matrix defines os with two values and node with two values, expanding into four jobs. The team needs one additional job that uses an os value already in the matrix paired with a node value that is not listed, without enlarging the other combinations. Which matrix key produces exactly that one extra job?

strategy:
  matrix:
    os: [ubuntu-latest, windows-latest]
    node: [18, 20]
    <key>:
      - os: ubuntu-latest
        node: 22
  • Ainclude, because a pair whose node value is absent from the base matrix is added as a brand new combination instead of extending an existing one. Correct
  • Bexclude, because listing the os and node pair under exclude appends it to the generated set as a distinct extra combination to build.
  • Cmax-parallel, because capping concurrency lets the runner schedule one supplementary node version alongside the four matrix jobs already defined.
  • Dfail-fast, because disabling it instructs the matrix to expand a recovery combination for any node version that is otherwise missing.
Use matrix include to add a new combination when its values do not match any existing expanded entry. When an include entry shares a key value such as os but introduces a value not present in the base axis, GitHub Actions cannot fold it into an existing combination, so it appends a separate job. Here ubuntu-latest with node 22 is added as a fifth job while the four base combinations remain untouched. exclude removes jobs, and max-parallel and fail-fast never alter the set of combinations.

Why A is correct: include adds a fresh combination when the pair does not match any expanded entry, so node 22 with ubuntu-latest becomes one extra job while the original four are left unchanged.

Why B is wrong: Tempting because exclude also takes os and node pairs, but exclude removes matching combinations from the expansion rather than adding new ones, so it cannot create the extra job.

Why C is wrong: Tempting because max-parallel governs the matrix, but it only limits how many jobs run at once. It does not define combinations, so it cannot introduce an additional node 22 job.

Why D is wrong: Tempting because fail-fast also sits under strategy, but it only controls cancellation of siblings on failure. It never adds combinations, so no node 22 job would appear.

See more GH-200 practice questions, answers explained.

More in this domain

Back to all Author and manage workflows objectives, or the GH-200 cert hub.

Examworthy is not affiliated with or endorsed by GitHub. Original, blueprint-aligned practice material only.