Commit abc2d31
authored
Speed up CI from ~11m to under 3m (#96)
## 🥞 Stacked PR
Use this [link](https://github.com/databricks/sdk-js/pull/96/files) to
review incremental changes.
- [**stack/speed-up-ci**](#96)
[[Files changed](https://github.com/databricks/sdk-js/pull/96/files)]
## Summary
Cuts the CI gate wall time from ~10m 49s to ~2m 27s (−77%) by removing
redundant build work between jobs and sharding the lint, typecheck, and
build jobs across four package-name ranges.
## Why
CI on this repo has 60+ packages and was taking over 10 minutes
end-to-end, which is painful for iteration. Two compounding problems:
1. **Every non-build job reran the full build.** Each of `lint`,
`typecheck`, `test`, and `test-browser` ran `npm run build` as its first
step, which builds all 63 packages (~3m 51s on the CI runners). Turbo's
task graph already declares `lint/typecheck/test.dependsOn: ["^build"]`,
which means Turbo will build only the upstream packages each task
actually needs (usually `core`, `databricks`, `auth` — 3 packages,
~30s). The explicit build step was pure duplicate work.
2. **Lint, typecheck, and build were single jobs processing 62 packages
on one runner.** Turbo parallelizes tasks within a job, but a CI runner
has limited cores, so ESLint in particular saturated at ~5m 27s wall
time. Nothing was sharing the load across additional runners.
A Turbo remote cache would solve both by sharing cached task outputs
across jobs and across runs, but the infra to host one isn't set up for
this repo, so this PR takes a simpler route that uses only what we
already have.
## What changed
### Interface changes
- **`npm run checks`** — New root script that runs `turbo run lint
format:check` in a single invocation, so local dev has a one-liner for
both pre-commit checks.
### Behavioral changes
None for anything the SDK exposes. Only CI runtime and parallelism
change.
### Internal changes
- **Removed the redundant `Build packages` step** from the `lint`,
`typecheck`, `test`, and `test-browser` jobs. Each of these tasks has
`dependsOn: ["^build"]` in `turbo.json`, so Turbo now builds only the ~3
upstream packages each task needs. The dedicated `build` job still
exercises a full build of every package.
- **Sharded `lint`, `typecheck`, and `build` across four package-name
ranges** using a GitHub Actions matrix: `[a-c]*`, `[d-l]*`, `[m-r]*`,
`[s-z]*`. The four ranges cover all of a-z, so a new package added under
any letter is picked up automatically. The `build` job additionally
keeps its existing `node-version: ['22', '24']` matrix, so sharding
multiplies it into 8 build jobs.
- **Shard dispatch reuses the existing npm scripts** with the filter
appended as a CLI argument: `npm run <script> --
--filter='@databricks/sdk-${{ matrix.shard }}'`. npm appends args after
`--` verbatim to the script command, so turbo receives
`--filter=<value>` as its own flag before it parses any task-args
separator.
## How is this tested?
Ran the workflow on this branch and measured:
| Stage | Gate wall time |
| --- | --- |
| Before any changes | ~10m 49s |
| After removing redundant build steps | 6m 45s (−38%) |
| After sharding lint only | 5m 40s (−48%) |
| After sharding lint + typecheck + build | **2m 27s (−77%)** |
Latest green run:
https://github.com/databricks/sdk-js/actions/runs/24778267054. The
slowest individual shard is `Lint ([s-z]*)` at ~2m 18s; the remaining
gate time is GitHub Actions runner startup and `npm ci`. Further
reductions would need a remote Turbo cache or more shards (diminishing
returns — startup alone is ~30s).
Also verified locally that the four shards together cover exactly the 62
lintable packages (union of `turbo run lint --filter=...` across the
four ranges equals the full package list).1 parent 4b26764 commit abc2d31
2 files changed
Lines changed: 19 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| |||
43 | 49 | | |
44 | 50 | | |
45 | 51 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 52 | + | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
| |||
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | 86 | | |
86 | | - | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | 120 | | |
123 | 121 | | |
124 | 122 | | |
| |||
153 | 151 | | |
154 | 152 | | |
155 | 153 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | 154 | | |
160 | 155 | | |
161 | 156 | | |
162 | 157 | | |
163 | 158 | | |
164 | 159 | | |
165 | 160 | | |
166 | | - | |
| 161 | + | |
167 | 162 | | |
168 | 163 | | |
169 | 164 | | |
170 | 165 | | |
171 | 166 | | |
172 | 167 | | |
173 | 168 | | |
| 169 | + | |
174 | 170 | | |
175 | 171 | | |
176 | 172 | | |
| |||
194 | 190 | | |
195 | 191 | | |
196 | 192 | | |
197 | | - | |
| 193 | + | |
198 | 194 | | |
199 | 195 | | |
200 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
0 commit comments