Overriding default job from os matrix

I think this is the issue I’m running into but I’m thoroughly confused:

language: node_js
os:
  - linux
  - osx
jobs:
  include:
    - stage: verify definitions
      script: npm run verify-definitions

This results in 3 jobs (first 2 in parallel), exactly as desired:

  1. linux + npm test
  2. macOS + npm test
  3. linux + npm run verify definitions

However, removing the OS array doesn’t reduce the jobs by 1, as one would expect. The OS still defaults to linux, so I would expect that removing the macOS line would result in the same default linux + npm test job as above, as well as the linux + npm run verify definitions job. Instead, removing the os array reduces the jobs by two!

language: node_js
jobs:
  include:
    - stage: verify definitions
      script: npm run verify-definitions

Results in only a single job that only runs the verify-definitions script. Where did the default linux + npm test job go?

(What I really want is two jobs, in parallel. Both using the default npm install and npm test. But I want one of the jobs to run npm run clean as the before_script. )

The question by @jasonkarns from Using jobs disables matrix jobs · Issue #10229 · travis-ci/travis-ci · GitHub and I am also interested to know what is going on.

When there is only one job at the top level of the configuration (without any matrix expansion), matrix.include (and its alias jobs.include) completely defines the jobs defined in the build (so the top level job is not included in the build).

But the matrix expansion is there. How to override default job?

You can think of jobs.include completely overriding the 1x1(x1x1…) build matrix. If you want a second job, add it in jobs.include:

language: node_js
jobs:
  include:
    - stage: test
    - stage: verify definitions
      script: npm run verify-definitions