Skip to content

Adds infra to support recording Maestro tests#2876

Open
JayShortway wants to merge 2 commits intomaestro-play-store-purchasefrom
maestro-recording-infra
Open

Adds infra to support recording Maestro tests#2876
JayShortway wants to merge 2 commits intomaestro-play-store-purchasefrom
maestro-recording-infra

Conversation

@JayShortway
Copy link
Copy Markdown
Member

Description

Note: based on #2866.

This adds the ability to record individual Maestro tests.

New infra

Here's the new infra:

  • A single-file HTTP server, called ShellServer, which can run arbitrary shell commands on the (CI) host.
  • A maestro/shell/shell.js script to make it easier to run shell commands through this server.
  • A record/scripts/android.js script that calls shell.js and runs the correct ADB commands to control screen recording.
  • record/start.yml and record/stop.yml which make it convenient to start and stop screen recording from Maestro flows.

Can be shared with iOS in the future

The above can be shared with iOS too, if we create record/scripts/ios.js which runs something like

xcrun simctl io booted recordVideo video.mov

(We can pre-compile the ShellServer and run it as jar or something.)

How it's used

And this is how it's used:

  • maestro/test_paywall_v2.yaml starts recording in onFlowStart and stops recording in onFlowComplete.
  • The recording is only saved if the flow failed. Otherwise it is discarded.
  • Since onFlowComplete runs regardless of success, I added conventions/mark-successful.yml to mark the flow successful. This should be run at the end of the regular flow steps.

@JayShortway JayShortway self-assigned this Nov 26, 2025
# Kotlin error logs
.kotlin/errors/
# Kotlin compiler
.kotlin
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shell-over-http project caused some more files being created in this folder. Ignoring this entire folder is recommended anyway:

Do not commit the .kotlin directory to version control. For example, if you are using Git, add .kotlin to your project's .gitignore file.

@JayShortway JayShortway marked this pull request as ready for review November 26, 2025 11:25
@JayShortway JayShortway requested a review from a team as a code owner November 26, 2025 11:25
Copy link
Copy Markdown
Member

@rickvdl rickvdl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! This should really help with debugging failures :)

I'm going back and forth wondering if being able to run any shell code over the HTTP server is a security risk, but I can't really think of an example that would make it any different from running the same code in a circle CI config file for example. In the end it's a local webserver so the code has to be in git for it to be able to execute it on the machine locally, which is ephemeral by design anyways. So I think we're good on that front. But happy to hear it if anyone thinks differently about it :)

function start(filename) {
var name = normalizeFilename(filename);

var pid = output.shell.start('adb shell screenrecord /sdcard/' + name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice to be able to run full commands through the webserver 👏

Copy link
Copy Markdown
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great! my only question is whether we need to run the shell-over-http server before starting to execute the maestro flows in order for this to work?

function start(filename) {
var name = normalizeFilename(filename);

var pid = output.shell.start('adb shell screenrecord /sdcard/' + name);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I'm not sure, is the /sdcard/ folder always guaranteed to exist? Not sure if we should record in a documents folder or something like...


function run(cmd) {
if (!isServerRunning()) {
return { exitCode: -1, stdout: '', stderr: 'shell-over-http server not running' };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably missing something... but do we need to start the server for shell-over-http in the circleci job/fastlane lane before running the tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants