Skip to content

Commit 9bcbf43

Browse files
authored
ci: cache eslint and tsc results between ci runs (#33304)
## **Description** `yarn lint` and `yarn lint:tsc` both run cold on every CI invocation: `.eslintcache` and `tsconfig.tsbuildinfo` are gitignored, and the `scripts` job in `ci.yml` does a fresh `actions/checkout` with no step restoring them, so ESLint's `--cache` flag and TypeScript's `incremental: true` option never actually get to skip anything in CI — every run re-lints and re-type-checks the entire repo from scratch. This adds two rolling caches to the `scripts` job, scoped to their respective matrix entries: - `lint` → restores/saves `.eslintcache` - `lint:tsc` → restores/saves `tsconfig.tsbuildinfo` Both use a `key` that includes `github.run_id` (always a miss) with a `restore-keys` prefix fallback — this is the pattern documented in [`actions/cache`'s own "Update a cache" guidance](https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache), needed because cache entries are immutable and can't be overwritten in place. The net effect: each run restores the most recent eligible cache (same branch, base branch, or `main`, per GitHub's cache access rules), lets the tool re-validate file hashes itself, and saves a fresh cache at the end — so most runs only need to re-lint/re-check files that actually changed instead of the whole repo. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: ## **Manual testing steps** N/A — CI-only configuration change with no in-app behavior to verify. Validated by observing the `Restore ESLint cache` / `Restore TypeScript incremental build cache` steps and the resulting `lint` / `lint:tsc` job durations across consecutive CI runs on this PR and after merging to `main`. ## **Screenshots/Recordings** ### **Before** N/A ### **After** N/A ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) - [x] I've tested on Android - [x] I've tested with a power user scenario - [x] I've instrumented key operations with Sentry traces for production performance metrics ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. Made with [Cursor](https://cursor.com)
1 parent 285a54b commit 9bcbf43

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,22 @@ jobs:
307307
command: yarn install --immutable
308308
- name: Clean state and following up dependencies installation
309309
run: yarn setup:github-ci --node
310+
- name: Restore ESLint cache
311+
if: ${{ matrix.scripts == 'lint' }}
312+
uses: actions/cache@v4
313+
with:
314+
path: .eslintcache
315+
key: eslintcache-${{ runner.os }}-${{ github.run_id }}
316+
restore-keys: |
317+
eslintcache-${{ runner.os }}-
318+
- name: Restore TypeScript incremental build cache
319+
if: ${{ matrix.scripts == 'lint:tsc' }}
320+
uses: actions/cache@v4
321+
with:
322+
path: tsconfig.tsbuildinfo
323+
key: tsbuildinfo-${{ runner.os }}-${{ github.run_id }}
324+
restore-keys: |
325+
tsbuildinfo-${{ runner.os }}-
310326
- run: yarn ${{ matrix['scripts'] }}
311327
- name: Require clean working directory
312328
shell: bash
@@ -1338,7 +1354,13 @@ jobs:
13381354
permissions:
13391355
contents: read
13401356
id-token: write
1341-
needs: [get_requirements, build-android-apks, smart-e2e-selection, prepare-e2e-timings]
1357+
needs:
1358+
[
1359+
get_requirements,
1360+
build-android-apks,
1361+
smart-e2e-selection,
1362+
prepare-e2e-timings,
1363+
]
13421364
uses: ./.github/workflows/run-e2e-smoke-tests-android.yml
13431365
with:
13441366
changed_files: ${{ needs.get_requirements.outputs.changed_files }}
@@ -1392,7 +1414,13 @@ jobs:
13921414
permissions:
13931415
contents: read
13941416
id-token: write
1395-
needs: [get_requirements, ios-tests-ready, smart-e2e-selection, prepare-e2e-timings]
1417+
needs:
1418+
[
1419+
get_requirements,
1420+
ios-tests-ready,
1421+
smart-e2e-selection,
1422+
prepare-e2e-timings,
1423+
]
13961424
uses: ./.github/workflows/run-e2e-smoke-tests-ios.yml
13971425
with:
13981426
changed_files: ${{ needs.get_requirements.outputs.changed_files }}

0 commit comments

Comments
 (0)