Skip to content

Commit 74ddc9e

Browse files
committed
test: create a clean "native coverage upload" failed signal in CI
native coverage was still failing to upload correctly, and it was a silent false positive this doesn't enforce a specific level of native coverage but enforces that it is correctly collected and uploaded - that the plumbing + system is working
1 parent 326b35e commit 74ddc9e

10 files changed

Lines changed: 98 additions & 18 deletions

File tree

.github/workflows/tests_e2e_android.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,20 @@ jobs:
273273
yarn tests:android:post-e2e-coverage
274274
275275
# https://github.com/codecov/codecov-action/releases
276-
- uses: codecov/codecov-action@e53489f4d376d79066609109e7a95a29eb3740b1 # v7.0.0
276+
- name: Upload Codecov e2e TS (Android)
277+
uses: codecov/codecov-action@e53489f4d376d79066609109e7a95a29eb3740b1 # v7.0.0
277278
continue-on-error: true
278279
with:
280+
files: coverage/lcov.info
281+
flags: e2e-ts-android
282+
verbose: true
283+
284+
- name: Upload Codecov Android native
285+
uses: codecov/codecov-action@e53489f4d376d79066609109e7a95a29eb3740b1 # v7.0.0
286+
continue-on-error: true
287+
with:
288+
files: tests/android/app/build/reports/jacoco/jacocoAndroidTestReport/jacocoAndroidTestReport.xml
289+
flags: android-native
279290
verbose: true
280291

281292
- name: Upload Emulator Log

.github/workflows/tests_e2e_ios.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,22 @@ jobs:
420420
path: .github/workflows/scripts/*.log
421421

422422
# https://github.com/codecov/codecov-action/releases
423-
- uses: codecov/codecov-action@e53489f4d376d79066609109e7a95a29eb3740b1 # v7.0.0
423+
- name: Upload Codecov e2e TS (iOS)
424+
uses: codecov/codecov-action@e53489f4d376d79066609109e7a95a29eb3740b1 # v7.0.0
424425
if: contains(matrix.buildmode, 'debug')
425426
continue-on-error: true
426427
with:
428+
files: coverage/lcov.info
429+
flags: e2e-ts-ios
430+
verbose: true
431+
432+
- name: Upload Codecov iOS native
433+
uses: codecov/codecov-action@e53489f4d376d79066609109e7a95a29eb3740b1 # v7.0.0
434+
if: contains(matrix.buildmode, 'debug')
435+
continue-on-error: true
436+
with:
437+
files: coverage/ios-native/lcov.info
438+
flags: ios-native
427439
verbose: true
428440

429441
- name: Yarn Cache Save

.github/workflows/tests_e2e_other.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ jobs:
281281
- uses: codecov/codecov-action@e53489f4d376d79066609109e7a95a29eb3740b1 # v7.0.0
282282
continue-on-error: true
283283
with:
284+
files: coverage/lcov.info
285+
flags: e2e-ts-macos
284286
verbose: true
285287

286288
- name: Stop Screen Recording and System Logging

.github/workflows/tests_jest.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ jobs:
6565
# https://github.com/codecov/codecov-action/releases
6666
- uses: codecov/codecov-action@e53489f4d376d79066609109e7a95a29eb3740b1 # v7.0.0
6767
with:
68+
files: coverage/lcov.info
69+
flags: jest
6870
verbose: true
6971
# https://github.com/actions/cache/releases
7072
- uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5

codecov.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,27 @@ coverage:
1414
changes: no
1515

1616
comment:
17-
layout: 'header, diff'
17+
layout: 'header, diff, flags'
1818
behavior: default
1919
require_changes: false
2020
after_n_builds: 3
21+
22+
# Native upload gates. Flag names must match codecov-action `flags:` in CI workflows
23+
# (see okf-bundle/testing/coverage-design.md).
24+
flag_management:
25+
individual_flags:
26+
- name: ios-native
27+
carryforward: false
28+
statuses:
29+
- type: project
30+
target: 1%
31+
threshold: 0%
32+
informational: false
33+
34+
- name: android-native
35+
carryforward: false
36+
statuses:
37+
- type: project
38+
target: 1%
39+
threshold: 0%
40+
informational: false

okf-bundle/ci-workflows/android.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
1. `yarn tests:android:test-cover --headless` — Detox + Jet (pass/fail gate)
66
2. `yarn tests:android:post-e2e-coverage` — poll/pull `coverage.ec`, Jacoco report (best-effort, never fails the job)
7-
3. Codecov upload — `continue-on-error: true`
7+
3. **Codecov upload**two flagged uploads (`e2e-ts-android`, `android-native`); `continue-on-error: true` on the action steps. **`codecov/project/android-native`** fails if the native flag upload is missing (see [coverage design](../testing/coverage-design.md#native-upload-gates)).
88

99
Native Android coverage is **not** pulled inside `tests/e2e/firebase.test.js`. The Jet `after` hook in `tests/app.js` calls `RNFBTestingCoverage.flush()` in the **app process** to write `coverage.ec` before Detox SIGINTs instrumentation. Post-e2e pull runs after Detox exits.
1010

@@ -50,3 +50,4 @@ Full inventory: [detox-patches.md](detox-patches.md).
5050
| Empty Jacoco XML (~235 bytes) | No `.ec` pulled — check post-e2e logs |
5151
| `adb reverse --remove` in Detox logs | Expected on 1006; should be warn-only after Detox patch |
5252
| Detox red, tests green in log | Pre-patch: teardown adb error; re-run or check patch applied |
53+
| `codecov/project/android-native` fail | Jacoco XML not uploaded — check post-e2e logs and Codecov Uploads tab for `android-native` flag |

okf-bundle/ci-workflows/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Knowledge for GitHub Actions workflows in this repository: how jobs are structur
1414

1515
## Related
1616

17-
* [Testing / coverage design](../testing/coverage-design.md) — e2e coverage collection that runs inside the iOS workflow
17+
* [Testing / coverage design](../testing/coverage-design.md) — e2e coverage collection, Codecov flags, and upload gates

okf-bundle/ci-workflows/ios.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ A long gap with only `com.apple.datamigrator` activity and no `com.invertase.tes
8585

8686
Device type is defined in `tests/.detoxrc.js` (`devices.simulator.device.type`). The boot script and Detox both use this name. CI does not hard-code a UDID.
8787

88+
### Codecov (debug matrix only)
89+
90+
After Detox, the debug leg runs `yarn tests:ios:test:process-coverage` then two flagged Codecov uploads (`e2e-ts-ios`, `ios-native`). **`codecov/project/ios-native`** blocks if the native flag upload is missing. Release legs skip coverage. Details: [coverage design](../testing/coverage-design.md#codecov-uploads-ci).
91+
8892
### E2E test app orchestration (Detox + Jet)
8993

9094
After pre-boot succeeds, failures often move **inside** the test app process (`com.invertase.testing`, binary `testing`). Simulator boot and app install are fine; Detox `launchApp` stalls while the app stays alive. Several overlapping issues show up in CI logs.
@@ -205,7 +209,8 @@ rg 'testing\[' simulator.log | rg -i 'FIRApp|RNFB|RCTBridge|configure'
205209
| Pattern | Meaning |
206210
|---------|---------|
207211
| `ready action too early` in Detox step only | Early-ready race (patch should fix; check patch applied in `yarn install`) |
208-
| `ECOMPROMISED` / `Unable to update lock within the stale threshold` | Device registry lock heartbeat missed — see [detox-patches.md](detox-patches.md); check `ExclusiveLockfile.js` patch |
212+
| `ECOMPROMISED` / `Unable to update lock within the stale threshold` | Device registry lock heartbeat missed — see [detox-patches.md](detox-patches.md) |
213+
| `codecov/project/ios-native` fail | Native lcov not uploaded — check process-coverage step and Codecov Uploads tab for `ios-native` flag |
209214
| `waitForActive` without `waitForActiveDone` | Scene/active hang (issue 4) **or** Metro/JS load failure (issue 5) — check `[rnfb-lifecycle]` probes |
210215
| `probe+30s` / `probe+60s` with `UIApplication.state=inactive` or scene `unattached` | App never became foreground-active (issue 4); compare with SpringBoard `foreground-interactive` lines |
211216
| `probe+30s` / `probe+60s` with `active` / `foregroundActive` but no `waitForActiveDone` | Metro/JS bundle failure despite active UIKit (issue 5); check `RCTJavaScriptDidFailToLoad` and `packager-status-fetch` |

okf-bundle/testing/coverage-design.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,22 +161,48 @@ The Podfile `post_install` coverage flags are temporary. When native dependencie
161161

162162
# Codecov uploads (CI)
163163

164-
CI uses [codecov-action](https://github.com/codecov/codecov-action) v7 with `verbose: true`. It auto-discovers coverage files under the repo, including:
164+
CI uses [codecov-action](https://github.com/codecov/codecov-action) v7 with explicit `files` and `flags` per upload (no auto-discovery for gated artifacts). Workflow steps use `continue-on-error: true` so a Codecov API hiccup does not fail the test job; **blocking gates** are the Codecov GitHub status checks configured in `codecov.yml`.
165165

166-
| Workflow | Artifacts |
167-
|----------|-----------|
168-
| `tests_jest.yml` | `coverage/lcov.info`, `coverage-final.json`, `clover.xml` |
169-
| `tests_e2e_android.yml` | `coverage/lcov.info` + Jacoco XML |
170-
| `tests_e2e_other.yml` | `coverage/lcov.info` (macOS TS) |
171-
| `tests_e2e_ios.yml` (debug) | `coverage/lcov.info` + `coverage/ios-native/lcov.info` |
166+
## Flag inventory
172167

173-
The iOS workflow runs `yarn tests:ios:test:process-coverage` after Detox (`if: always()`, `continue-on-error: true` for now). The process step exits 1 when profraw is missing.
168+
Flag names are defined in **`codecov.yml`** (`flag_management`) and must match **`flags:`** in the workflow step. Do not rename in one place without the other.
169+
170+
| Flag | Workflow | File uploaded | Blocks PR? |
171+
|------|----------|---------------|------------|
172+
| `jest` | `tests_jest.yml` | `coverage/lcov.info` | No |
173+
| `e2e-ts-ios` | `tests_e2e_ios.yml` (debug only) | `coverage/lcov.info` | No |
174+
| `ios-native` | `tests_e2e_ios.yml` (debug only) | `coverage/ios-native/lcov.info` | **Yes**`codecov/project/ios-native` |
175+
| `e2e-ts-android` | `tests_e2e_android.yml` | `coverage/lcov.info` | No |
176+
| `android-native` | `tests_e2e_android.yml` | `tests/android/app/build/reports/jacoco/jacocoAndroidTestReport/jacocoAndroidTestReport.xml` | **Yes**`codecov/project/android-native` |
177+
| `e2e-ts-macos` | `tests_e2e_other.yml` | `coverage/lcov.info` | No |
178+
179+
iOS **release** matrix legs do not upload coverage. macOS e2e has TS coverage only (no native gate).
180+
181+
## Native upload gates
182+
183+
Blocking flags use `carryforward: false` and `target: 1%` in `codecov.yml`:
184+
185+
- **Upload present** with any reasonable native coverage → flag status **passes** (well above 1%).
186+
- **Upload missing** (file not produced, step skipped, or upload failed) → flag has **0%** → status **fails**.
187+
188+
This gates **upload presence**, not native coverage percentage regressions. Overall `codecov/project` remains `informational: true`.
189+
190+
PR comments include a **flags** table (`comment.layout: …, flags`).
191+
192+
## Per-workflow artifacts
193+
194+
| Workflow | Steps before Codecov |
195+
|----------|---------------------|
196+
| `tests_jest.yml` | `yarn tests:jest-coverage` |
197+
| `tests_e2e_ios.yml` (debug) | Detox → `yarn tests:ios:test:process-coverage` (`continue-on-error: true` on process step for now) |
198+
| `tests_e2e_android.yml` | Detox → `yarn tests:android:post-e2e-coverage` (soft-fail poll/pull in script) |
199+
| `tests_e2e_other.yml` | macOS Jet e2e |
174200

175201
## File naming
176202

177-
The repo standard for JavaScript lcov is **`coverage/lcov.info`**. iOS native lcov is **`coverage/ios-native/lcov.info`** — the basename `lcov.info` is required for codecov-action auto-discovery (files like `ios-native.lcov.info` are not matched). Android native coverage is **Jacoco XML**, not lcov; codecov discovers `jacoco*.xml` once the report is generated.
203+
JavaScript lcov: **`coverage/lcov.info`**. iOS native lcov: **`coverage/ios-native/lcov.info`** (basename `lcov.info` required). Android native: **Jacoco XML** at the path in the table above after `jacocoAndroidTestReport`.
178204

179-
Check the Codecov commit **Uploads** tab for **Processed** vs **Unusable** per upload — that is the authoritative signal, not small project percentage deltas.
205+
Check the Codecov commit **Uploads** tab: each flag should appear as **Processed**. **Unusable** means wrong format or paths — fix before relying on the gate.
180206

181207
# Local iteration
182208

@@ -231,8 +257,9 @@ These must all be true for native coverage to work. If any break, the e2e test s
231257
| iOS link: `swiftCompatibility56` undefined | Profile link flags applied to all Pods | Restrict `OTHER_LDFLAGS` profile flags to app target; RNFB pods compile-only |
232258
| No `[jet-coverage] WS received` lines | Patches not applied | `yarn install` from repo root; check `.yarn/patches/` |
233259
| NYC summary missing / empty `lcov.info` | Jet not run from `tests/` cwd | Detox spawns `yarn jet` inside `tests/`; macOS uses `cd tests && npx jet` |
234-
| Codecov missing iOS native files | Output not named `lcov.info` | Use `coverage/ios-native/lcov.info` (not `coverage/ios-native.lcov.info`) |
260+
| Codecov missing iOS native files | Output not named `lcov.info` or wrong path | Use `coverage/ios-native/lcov.info`; confirm `ios-native` flag upload in iOS debug workflow |
235261
| Codecov upload **Unusable** | Wrong `SF:` paths | Confirm path rewrite in `process-ios-native-coverage.js`; check Uploads tab message |
262+
| `codecov/project/ios-native` or `android-native` **fail** | Native flag upload missing (`carryforward: false` → 0%) | Check Uploads tab for that flag; iOS: process-coverage step + `coverage/ios-native/lcov.info`; Android: post-e2e Jacoco XML path |
236263

237264
# Future cleanups (non-blocking)
238265

okf-bundle/testing/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Testing
22

3-
* [Coverage design](coverage-design.md) - how unit and e2e coverage is collected, transformed, and uploaded
3+
* [Coverage design](coverage-design.md) unit and e2e coverage collection, Codecov flags, and native upload gates

0 commit comments

Comments
 (0)