# GitHub Actions matrix build takes 40 minutes. How do I cut it down without losing coverage?

Source: https://gitshowcase.com/forum/discuss/github-actions-matrix-build-takes-40-minutes-how-do-i-cut-it-down/
Site: GitShowcase Forum, category CI/CD and GitHub Actions
Published: 2026-11-27. Updated: 2026-11-28. Replies: 2.

## Question by Fitz O., 2026-11-27

Our agency maintains a TypeScript monorepo for a client and the CI workflow has crept up to about 40 minutes on every pull request. It is one job with a matrix of 3 Node versions across 3 operating systems, plus a test step that runs unit and integration tests together. Everyone is starting to merge without waiting, which is the opposite of what CI is for.

The relevant part of the workflow:

```yaml
jobs:
  test:
    strategy:
      matrix:
        node: [18, 20, 22]
        os: [ubuntu-latest, windows-latest, macos-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node }}
          cache: npm
      - run: npm ci
      - run: npm test
```

The client insists we keep the coverage, so deleting entries is a hard sell. What is the realistic way to make this faster? Should I split the jobs, reduce the matrix, cache more, or something I have not thought of? I would like to understand where the time goes before I change things.

## Reply 1 by Anand R., 2026-11-28

Before changing anything, look at the per job durations in the run summary. The wall time of a matrix is the slowest single entry, not the sum, as long as runners are available. If macOS or Windows is the slow one, that is where to look. Also check how long `npm ci` takes versus `npm test`. I have seen "tests are slow" turn out to be "install is slow".

## Reply 2 by Fitz O., 2026-11-28

@Anand R. good point, I had not looked at install versus test. Install turns out to be a large part of the Windows entry, so the cache fix should help there first.

---
Cite as: GitShowcase Forum, "GitHub Actions matrix build takes 40 minutes. How do I cut it down without losing coverage?", https://gitshowcase.com/forum/discuss/github-actions-matrix-build-takes-40-minutes-how-do-i-cut-it-down/, accessed 2026-11-28.
