spion / adbfs-rootless

Mount Android phones on Linux with adb. No root required.
Other
890 stars 73 forks source link

feat: add docker testing #62

Closed spion closed 1 week ago

spion commented 1 year ago

This PR adds a scaffold for automated tests based on docker and an android emulator. The neat thing about this approach is that we can also use multiple versions of android, and while that may not be fully exhaustive in terms of the devices out there, its way better than having nothing.

Without tests, changes to this project are quite high risk. With tests, I think we can get things going :smile:

Currently covers only a single Android version, but its easy to add a second dockerfile.

To try it out

docker build -t adbfs-rootless-v1 -f docker/Dockerfile .
docker run --privileged --rm adbfs-rootless-v1

The reason --privileged is needed is because the android emulators need virtualization support (/dev/kvm needs to be available). I'm still hoping we'll be able to run these in GitHub actions but I've not tried yet.

This is WIP. Would be great to have some ideas about good representative tests to run and ways to verify that everything is ok.

spion commented 1 year ago

For running priviledged actions, refer to https://github.com/actions/container-action/issues/2#issuecomment-854057781

spion commented 1 year ago

Looks like this is not happening with github actions for now: https://github.com/actions/runner-images/issues/183

spion commented 7 months ago

TODO: check if this helps https://www.ubicloud.com/use-cases/github-actions

ViliusSutkus89 commented 3 weeks ago

Hello @spion , how's it going?

I have a question, since you're trying to combine emulator and docker, why exactly do you need docker? Dockerfile is basically a script with extra tools. You can install whatever tools you need on GHA Ubuntu machine and then run your test.sh inside reactivecircus/android-emulator-runner

Is it because of libfuse? Is Docker needed in order to use libfuse on GHA?

spion commented 3 weeks ago

Its so I can also run the tests locally (with multiple android versions, as well as multiple versions of ubuntu/fuse/etc) without having to rely on GHA. But I'm probably going to be reworking that bit to use separate containers for the emulator and the filesystem "host"

ViliusSutkus89 commented 3 weeks ago

The way I see it, you need docker to be able to test locally on different ubuntu/fuse versions. Just because you need that, it doesn't mean that the script should ONLY be callable through docker. You could use docker locally, and plain naked script in GHA. Both still calling the same adb calls. With GHA you get an easy way to set up a test matrix with all relevant android versions and maybe even fuse versions, if different fuse versions are easily reachable through apt-get or whatever.

Keep in mind that GHA Android emulators are x86/x86_64. I haven't tried anything with the new macos armv8 images, maybe they would allow armv8 emulator images in addition to ubuntu's x86/x86_64.

Let me know if you want help here on the emulator or GHA

spion commented 3 weeks ago

Yeah, the script is already called directly in GHA now from an action that sets up the emulator. The code is a year old and went through quite a few iterations - my main goal yesterday was to get it working in case there is a new influx of contributions but there is some cleanup left to do for sure :sweat_smile: