JS-2017 Fix JS coverage handoff for Sonar analysis - #7481
Conversation
(cherry picked from commit b19fe6a)
Ruling Report✅ No changes to ruling expected issues in this PR |
Code Review ✅ Approved 1 resolved / 1 findingsReplaces fragile implicit cache side effects with explicit workflow artifacts for JS coverage reports, resolving the issue of incomplete reports and adding a fast-fail check for missing files. ✅ 1 resolved✅ Edge Case: Partial coverage cache can produce incomplete artifact silently
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|
zglicz
left a comment
There was a problem hiding this comment.
I'd suggest doing one or the other:
- remove the cache completely and potentially create a task to improve the CI, to reintroduce it
- fix the caching behavior and remove the artifacts.
I'll just comment, as I'll leave this up to engineers still owning this repo.
zglicz
left a comment
There was a problem hiding this comment.
Looks good to me, I take it back
Code Review ✅ Approved 1 resolved / 1 findingsReplaces fragile implicit cache side effects with explicit workflow artifacts for JS coverage reports, resolving the issue of incomplete reports and adding a fast-fail check for missing files. ✅ 1 resolved✅ Edge Case: Partial coverage cache can produce incomplete artifact silently
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
lookup-only: true on populate_npm_cache's cache step means the action never actually saves node_modules under the branch key (mode=lookup: "no restore, no save"), same latent bug already fixed for the JS coverage cache in #7481. It only appeared to work when a branch's lockfile hash matched master's, via the fallback-exact-key path. Drop lookup-only so the step does a normal restore-or-install, letting the action's post-step genuinely save under the branch's own key. Downstream jobs (build, test_js, test_js_win, prepare_rspec_rule_data) already do a plain restore against that same key and get a real hit once it's actually populated - no need to pin gh-action_cache back.





Summary
This PR fixes the JS coverage handoff in CI.
test_jscan still reuse an existingcoverage/jscache to skip rerunning bridge coverage, but the coverage files consumed byAnalyze in SonarQube NEXTare now passed explicitly as a workflow artifact instead of relying on implicit cache behavior across jobs.Root cause
The latent workflow bug was introduced by
16cc127bc27f7968e3bb9e6b3ae5e5000a87db2c(JS-943 try bigger machines + windows dependencies (#5909), 2025-11-11).That change split the flow in two jobs:
test_jscheckedcoverage/jswithSonarSource/gh-action_cache@v1andlookup-only: trueAnalyze in SonarQube NEXTlater tried to restorecoverage/jsfrom the cache using the samejs-files-hashThis was fragile because
lookup-only: truemeans thetest_jsjob is not supposed to restore or save anything. The workflow only kept working because the action implementation still ended up saving branch caches as a side effect.Why it started failing now
This did not start because of a new SonarJS workflow change. It started because
SonarSource/gh-action_cache@v1is a floating ref and its behavior changed on 2026-06-30 in8d5f45db5f8e71b8b09d15d3a8f751576cd33afd(BUILD-11220 Skip duplicate S3 cache save when content matches the default-branch fallback).Before that update, earlier successful runs on PR #7445 still saved a branch cache from
test_jsafter a cold miss, andAnalyze in SonarQube NEXTrestored that branch cache later in the same workflow.After the update, the action started enforcing lookup-only mode explicitly:
mode=lookuplookup-only input set — no restore, no saveEarlier successful runs used action SHA
339d9d71cc5210bfa866a831dd8eba8e32c40491and showed:test_js:Cache saved with key: fix/js-1995-s2486-single-statement-try/js-coverage-...Analyze in SonarQube NEXT:Cache restored from key: fix/js-1995-s2486-single-statement-try/js-coverage-...The failing run used action SHA
4e40632e780e11a8bbe9b721985ab22b42847cc4and logged the explicit lookup-only behavior instead.Once
@v1advanced, the latent bug became visible. PR #7445 exposed it because changing files underrules/changedjs-files-hash, which forced a cold miss on a new cache key.test_jsno longer saved coverage for that key,Analyze in SonarQube NEXTcould not restore anything from the branch ormaster, and the job failed whencoverage/js/test-report.xmlwas missing.Fix
test_js, but use a normal restore instead of a lookup-only probecoverage/js/lcov.infoandcoverage/js/test-report.xmlfromtest_jsThis removes the hidden dependency on cache side effects while preserving the fast path when the JS coverage cache already exists.