ci: run client linters on changed files
Created by: valerybugakov
Context
We lint all css
and ts
files on every PR, which is wasteful, especially for pull requests where a small number of files are affected. We can lint only files changed in a pull request to save some CI resources and make the feedback cycle faster.
Changes
- Run
stylelint
andeslint
only on changed files in PRs. Onmain
all files will be linted as usual. - Run
stylelint
on all.scss
files in the client folder instead of explicitly listing a set of packages to check. Because we relied on the manually updated list of packages to check, some recently added client packages were ignored here. - Changed npm scripts format for lint commands:
- Use
_
to mark internal commands used by other npm scripts. - Uncouple lint commands from libraries used for linting. E.g.,
eslint
->lint:js
. It allows usingyarn prettier
to call theprettier
binary instead of calling our npm script, which is useful during local development. - Use a consistent format for lint npm commands in the client codebase –
lint:lang:modifier
. E.g.,lint:js
,lint:js:changed
,lint:css:all
, etc.
- Use
Time improvements
Improvements will vary depending on the PR scope, but in PRs with a few client changes, the eslint
check can be up to 4x faster. Feels good
Before | After |
---|---|
Used two CI builds for comparison:
-
This branch with a minimal number of changed
.ts
files. -
This branch dry-run that checks all
.ts
files.
Test plan
Verify that ESLint and Stylelint CI checks are executed only on files changed in the PR.