-
Notifications
You must be signed in to change notification settings - Fork 107
fix[notask]: decouple mobile shard validation from desktop integration tests #4031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ac561b1
fix[notask]: decouple mobile shard validation from desktop integratioβ¦
iancris 7ef0572
fix[notask]: reserve "deferred" inside platform maps, drop the inert β¦
iancris 0afebd9
fix[notask]: share the runner extractor, allow per-platform deferral
iancris 1ca01ed
Merge branch 'main' into fix/vla-mobile-group-validation
iancris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
packages/vla-ggml/scripts/__tests__/mobile-test-groups.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| 'use strict' | ||
|
|
||
| const test = require('node:test') | ||
| const assert = require('node:assert/strict') | ||
| const fs = require('node:fs') | ||
| const path = require('node:path') | ||
|
|
||
| const { validateTestGroups, platformNames } = require('../lib/validate-test-groups.js') | ||
| const groups = require('../../test/mobile/test-groups.json') | ||
|
|
||
| const integrationAutoPath = path.resolve(__dirname, '../../test/mobile/integration.auto.cjs') | ||
|
|
||
| function generatedRunners() { | ||
| const content = fs.readFileSync(integrationAutoPath, 'utf8') | ||
| return Array.from(content.matchAll(/^async function (run[A-Za-z0-9_]+)\s*\(/gm), (m) => m[1]) | ||
| } | ||
|
|
||
| test('the committed test-groups.json covers every generated runner', () => { | ||
| assert.deepEqual(validateTestGroups(groups, generatedRunners()), []) | ||
| }) | ||
|
|
||
| test('deferred runners are declared, not silently absent', () => { | ||
| // pi05 mobile coverage is deferred pending a project-owned CDN mirror, and | ||
| // pi05.test.js is gated on-device by `_skipMobilePi05`. Recording it here is | ||
| // what keeps "not scheduled" distinguishable from "forgotten". | ||
| assert.deepEqual(groups.deferred, ['runPi05Test']) | ||
| for (const platform of platformNames(groups)) { | ||
| const scheduled = Object.values(groups[platform]).flat() | ||
| assert.ok( | ||
| !scheduled.includes('runPi05Test'), | ||
| `runPi05Test must not be scheduled on ${platform}` | ||
| ) | ||
| } | ||
| }) | ||
|
|
||
| test('"deferred" is a top-level key, never a platform', () => { | ||
| // The Device Farm composites read only `.<platform>`, so a `deferred` key | ||
| // nested inside ios/android would be scheduled as a real shard. | ||
| assert.ok(!platformNames(groups).includes('deferred')) | ||
| assert.deepEqual(platformNames(groups).sort(), ['android', 'ios']) | ||
| }) | ||
|
|
||
| test('a "deferred" key nested inside a platform is reported', () => { | ||
| // The assertion above only covers the committed file's shape. This covers the | ||
| // hazard itself: nested under a platform, `deferred` is just another array of | ||
| // runner names, so every other rule is satisfied and the file would otherwise | ||
| // validate clean β while upload-to-devicefarm schedules it as a real shard. | ||
| const nested = { | ||
| ios: { smolvla: ['runAddonTest'], deferred: ['runPi05Test'] }, | ||
| android: { smolvla: ['runAddonTest'], deferred: ['runPi05Test'] } | ||
| } | ||
| const problems = validateTestGroups(nested, ['runAddonTest', 'runPi05Test']) | ||
|
|
||
| assert.equal(problems.length, 2, 'exactly one problem per platform') | ||
| for (const platform of ['ios', 'android']) { | ||
| const reported = problems.some( | ||
| (p) => p.startsWith(`[${platform}]`) && p.includes('nested inside the platform map') | ||
| ) | ||
| assert.ok(reported, `${platform} must report the nested "deferred" key`) | ||
| } | ||
| }) | ||
|
|
||
| test('an unassigned runner is reported', () => { | ||
| const problems = validateTestGroups(groups, [...generatedRunners(), 'runBrandNewTest']) | ||
| assert.equal(problems.length, platformNames(groups).length) | ||
| assert.ok(problems.every((p) => p.includes('runBrandNewTest'))) | ||
| }) | ||
|
|
||
| test('a typo in a group is reported', () => { | ||
| const typo = { | ||
| ios: { smolvla: ['runAddonTest', 'runTypoTest'] }, | ||
| deferred: [] | ||
| } | ||
| const problems = validateTestGroups(typo, ['runAddonTest']) | ||
| assert.ok(problems.some((p) => p.includes('runTypoTest') && p.includes('do not exist'))) | ||
| }) | ||
|
|
||
| test('a stale deferred entry is reported', () => { | ||
| const stale = { | ||
| ios: { smolvla: ['runAddonTest'] }, | ||
| deferred: ['runRemovedTest'] | ||
| } | ||
| const problems = validateTestGroups(stale, ['runAddonTest']) | ||
| assert.ok(problems.some((p) => p.includes('runRemovedTest') && p.includes('do not exist'))) | ||
| }) | ||
|
|
||
| test('a runner that is both scheduled and deferred is reported', () => { | ||
| const contradictory = { | ||
| ios: { smolvla: ['runAddonTest'] }, | ||
| deferred: ['runAddonTest'] | ||
| } | ||
| const problems = validateTestGroups(contradictory, ['runAddonTest']) | ||
| assert.ok(problems.some((p) => p.includes('both scheduled and listed'))) | ||
| }) | ||
|
|
||
| test('metadata keys that are not platform maps are ignored', () => { | ||
| // OCR ships a top-level `perf_report_filter` string; the shape must tolerate | ||
| // sibling metadata without treating it as a platform. | ||
| const withMetadata = { | ||
| ios: { smolvla: ['runAddonTest'] }, | ||
| perf_report_filter: 'something|else', | ||
| deferred: [] | ||
| } | ||
| assert.deepEqual(platformNames(withMetadata), ['ios']) | ||
| assert.deepEqual(validateTestGroups(withMetadata, ['runAddonTest']), []) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| 'use strict' | ||
|
|
||
| // Group-coverage rules for test/mobile/test-groups.json. | ||
| // | ||
| // Deliberately dependency-free and side-effect-free (no fs, no process.exit) so | ||
| // the same rules run under `node` from validate-mobile-tests.js and are unit | ||
| // testable from scripts/__tests__/mobile-test-groups.test.js. | ||
| // | ||
| // This check lives OUTSIDE the generator on purpose. It answers a mobile | ||
| // scheduling question β "is every on-device runner assigned to a Device Farm | ||
| // shard?" β which has no bearing on whether integration.auto.cjs was written | ||
| // correctly. Bundling it into the generator once let a Device Farm scheduling | ||
| // edit abort `npm run test:integration`, taking desktop CI down on all seven | ||
| // platforms (PR #4006). | ||
|
|
||
| // Runners deliberately not scheduled on Device Farm are listed under this | ||
| // top-level key. It sits beside the platform maps rather than inside one | ||
| // because the CI composites consume only `.<platform>` and ignore every other | ||
| // top-level key (see .github/actions/run-mobile-integration-tests/ | ||
| // upload-to-devicefarm/action.yml). Nesting it under `ios`/`android` would | ||
| // instead schedule it as a real shard. | ||
| const DEFERRED_KEY = 'deferred' | ||
|
iancris marked this conversation as resolved.
|
||
|
|
||
| // A platform entry is a `{ groupName: [runner, ...] }` map. Anything else at the | ||
| // top level is metadata for another consumer β `deferred` here, OCR's | ||
| // `perf_report_filter` β and is not a platform. | ||
| function isPlatformEntry(value) { | ||
| return typeof value === 'object' && value !== null && !Array.isArray(value) | ||
| } | ||
|
|
||
| function platformNames(groups) { | ||
|
iancris marked this conversation as resolved.
Outdated
|
||
| return Object.keys(groups).filter((key) => isPlatformEntry(groups[key])) | ||
| } | ||
|
|
||
| function coveredRunners(platformEntry) { | ||
| return Object.values(platformEntry).filter(Array.isArray).flat() | ||
| } | ||
|
|
||
| function deferredRunners(groups) { | ||
| const deferred = groups[DEFERRED_KEY] | ||
| return Array.isArray(deferred) ? deferred : [] | ||
| } | ||
|
|
||
| // Returns a list of human-readable problem strings; empty means valid. | ||
| // `runners` is the authoritative runner-name list, derived from the generated | ||
| // integration.auto.cjs by the caller. | ||
| function validateTestGroups(groups, runners) { | ||
| const problems = [] | ||
| const known = new Set(runners) | ||
| const deferred = deferredRunners(groups) | ||
|
|
||
| // A stale `deferred` entry is worse than a noisy one: it would silently | ||
| // excuse a runner that no longer exists, and mask a real gap if the name is | ||
| // ever reused. | ||
| const unknownDeferred = deferred.filter((name) => !known.has(name)) | ||
| if (unknownDeferred.length) { | ||
| problems.push( | ||
| `[${DEFERRED_KEY}] lists runners that do not exist:\n ` + | ||
| unknownDeferred.join('\n ') + | ||
| '\nRemove them or check for typos.' | ||
| ) | ||
| } | ||
|
|
||
| const platforms = platformNames(groups) | ||
| if (platforms.length === 0) { | ||
| problems.push( | ||
| 'test-groups.json declares no platform maps.\n' + | ||
| 'Expected at least one top-level `{ "<platform>": { "<group>": [runners] } }` entry.' | ||
| ) | ||
| return problems | ||
| } | ||
|
|
||
| const deferredSet = new Set(deferred) | ||
|
|
||
| for (const platform of platforms) { | ||
| // `deferred` nested inside a platform is indistinguishable from a shard: to | ||
| // `coveredRunners` below it is just another array of runner names, so the | ||
| // whole file would validate clean β and `upload-to-devicefarm` turns every | ||
| // `{ groupName: [runners] }` entry into a Device Farm spec, so those runners | ||
| // would be scheduled (and billed) under a shard literally named "deferred". | ||
| // Reserving the name here is what makes the top-level rule enforceable | ||
| // rather than merely documented. | ||
| if (Object.prototype.hasOwnProperty.call(groups[platform], DEFERRED_KEY)) { | ||
| problems.push( | ||
| `[${platform}] "${DEFERRED_KEY}" is nested inside the platform map.\n` + | ||
| `It must be a top-level key: nested here it is scheduled as a real Device Farm shard.` | ||
| ) | ||
| } | ||
|
|
||
| const covered = new Set(coveredRunners(groups[platform])) | ||
|
|
||
| const missing = runners.filter((name) => !covered.has(name) && !deferredSet.has(name)) | ||
| if (missing.length) { | ||
| problems.push( | ||
| `[${platform}] runners not assigned to any group:\n ` + | ||
| missing.join('\n ') + | ||
| `\nAdd them to a group in test/mobile/test-groups.json, or to the ` + | ||
| `top-level "${DEFERRED_KEY}" list if they are intentionally not run on device.` | ||
| ) | ||
| } | ||
|
|
||
| const extra = [...covered].filter((name) => !known.has(name)) | ||
| if (extra.length) { | ||
| problems.push( | ||
| `[${platform}] groups reference runners that do not exist:\n ` + | ||
| extra.join('\n ') + | ||
| '\nRemove them or check for typos.' | ||
| ) | ||
| } | ||
|
|
||
| // A runner in both a shard and `deferred` is contradictory: it would run on | ||
| // device while claiming to be deferred. | ||
| const contradictory = [...covered].filter((name) => deferredSet.has(name)) | ||
| if (contradictory.length) { | ||
| problems.push( | ||
| `[${platform}] runners are both scheduled and listed as "${DEFERRED_KEY}":\n ` + | ||
| contradictory.join('\n ') + | ||
| `\nRemove them from one or the other.` | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| return problems | ||
| } | ||
|
|
||
| module.exports = { | ||
| DEFERRED_KEY, | ||
| validateTestGroups, | ||
| platformNames, | ||
| deferredRunners | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.