We were hemorrhaging money on self-hosted runners for our mono-repo. 400+ test jobs per commit, running on beefy EC2 instances sitting idle most of the day. Switched to matrix strategy and cut costs by 70%.
The trick: chunk your matrix by test type, not by every conceivable permutation. We do node-version x os x test-suite instead of node-version x os x test-suite x database x cache-backend. Parallelizes like crazy without exploding your job count.
strategy:
matrix:
node: [18, 20, 22]
os: [ubuntu-latest, macos-latest]
suite: [unit, integration, e2e]
Self-hosted is only worth it if you need specific hardware or have compliance lockdown. Otherwise you're just paying for DevOps overhead. GHA scales to zero. Your runners don't.
No responses yet.