Skip to content

Add devices (DEVICE header lines) to the cases response - #5

Merged
yurivibes merged 1 commit into
masterfrom
feat/case-devices
Nov 30, 2026
Merged

yurivibes merged 1 commit into
masterfrom
feat/case-devices

Conversation

@yurivibes

Copy link
Copy Markdown
Owner

What changed

GET /repos/<owner>/<repo>/cases?ref=<branch> now returns an optional devices field, as the simulators/emulators spec asks:

"devices": {"login": ["ios, physical", "android, virtual = MT_Pixel"], "plain": []}
  • Each value is the raw text after DEVICE: on every DEVICE line in the header of mt-tests/<case>/INSTRUCTION.txt, in file order, trimmed. A case with no DEVICE line maps to []. The plugin does not interpret the values.
  • The header parser (sources.device_lines) copies the runner's _parse_instruction_header_keys: the key is case-insensitive, blank and # lines are allowed, and the header ends at the first line that isn't MODE / CLEAR_DATA / REINSTALL_APP / DEVICE: value.
  • How the files are read: the tree the plugin already fetches gives the blob sha of each INSTRUCTION.txt. The plugin fetches those blobs in parallel (8 workers, GET .../git/blobs/<sha>), fetches identical files only once, and caches the parsed result by blob sha in memory. A later listing only fetches files that changed. If the GitHub tree is truncated, the contents-API answers the fallback already gets include the file, so it makes no extra request.
  • If any INSTRUCTION.txt can't be read, the plugin leaves devices out of the response. The contract treats a missing devices as "unknown". The cases list still comes back.
  • POST /builds also calls list_cases (to check recipes). It now passes devices=False, so starting a build doesn't fetch these files.
  • README: documents the field in the endpoint table and a new "Cases and their DEVICE lines" section.

Verified

  • python3 -m unittest discover -s tests -v (the CI command): Ran 109 tests ... OK
  • New tests: unit tests for the parser (order, trimming, raw case, comments and blank lines, stop at the first body line, CRLF, empty value, no DEVICE line) and for the blob dedupe and cache. API tests check devices on the cases route, check that a second listing makes no extra blob requests, check that devices is left out when blob reads fail, check {} for a branch with no cases, check that the truncated-tree fallback makes no blob requests, and check that POST /builds reads no blobs. Both code hosts are covered: the Gitea path and the GitHub path.

Not verified

  • Not run against a real code host. The tests use the in-process fakes. The blob endpoint shapes follow the GitHub/Gitea API docs.
  • Not deployed. The running plugin service was not touched.
  • The viewer side that reads devices is a separate PR in MonkeyTester.

Each case maps to the raw values of the DEVICE lines in its INSTRUCTION.txt
header, read as blobs from the branch tree in parallel and cached by blob sha.
Left out when a file can't be read. POST /builds skips the read.
@yurivibes
yurivibes merged commit 4e1e591 into master Nov 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant