{"id":28125130,"url":"https://github.com/xing/mango","last_synced_at":"2025-05-14T09:20:33.007Z","repository":{"id":47168069,"uuid":"144828536","full_name":"xing/mango","owner":"xing","description":"A fastlane plugin that lets you execute tasks in a managed docker container","archived":false,"fork":false,"pushed_at":"2022-01-20T20:10:23.000Z","size":1617,"stargazers_count":51,"open_issues_count":0,"forks_count":7,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-21T14:20:06.937Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xing.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2018-08-15T08:43:22.000Z","updated_at":"2023-05-29T21:14:18.000Z","dependencies_parsed_at":"2022-09-16T08:22:06.841Z","dependency_job_id":null,"html_url":"https://github.com/xing/mango","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xing%2Fmango","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xing%2Fmango/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xing%2Fmango/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xing%2Fmango/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xing","download_url":"https://codeload.github.com/xing/mango/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254110399,"owners_count":22016393,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-14T09:20:18.611Z","updated_at":"2025-05-14T09:20:32.985Z","avatar_url":"https://github.com/xing.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Mango - Fastlane plugin\n\n[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-mango) [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/xing/mango/blob/master/LICENSE)\n[![Gem](https://img.shields.io/gem/v/fastlane-plugin-mango.svg?style=flat)](http://rubygems.org/gems/fastlane-plugin-mango)\n\nA fastlane plugin that runs Android tasks on a specified [Docker](https://www.docker.com/) image. Can be used for orchestrating android tasks on a CI system.\n\n\u003cimg src=\"assets/mango_logo.png\" alt=\"Mango Logo\" width=\"256px\" height=\"256px\"/\u003e\n\nRunning Android tests, especially [Espresso](https://developer.android.com/training/testing/espresso/) on a continuous integration environment like [Jenkins](https://jenkins.io/) can be a hassle. You need to boot, manage and destroy an [Android Virtual Device (AVD)](https://developer.android.com/studio/run/managing-avds) during the test run. This is why we, the mobile releases team at [XING](https://www.xing.com), built this plugin. It spins up a specified [Docker](https://www.docker.com/) image and runs a given task on it.\n\nAnother requirement we had was to run on a clean environment, which is why Mango also helps us to run our unit test and more. For an example check out the [example `Fastfile`](sample-android/fastlane/Fastfile)\n\n## Prerequisites\n\nIn order to use this plugin you will need to to have [Docker](https://www.docker.com/) installed on the machine you are using.\nDocumentation on how to set it up properly on a Linux (ubuntu) machine can be found [here](docs/docker-linux.md).\n\nIf you need an Android Virtual Device (AVD) to run your tests (for example Espresso, Calabash or Appium), it's necessary to check that your CPU supports kvm virtualisation. We already experienced that it doesn't fully work on macOS and are using Linux for that.\n\n## Getting Started\n\nThis project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-mango`, add it to your project by running:\n\n```bash\nfastlane add_plugin mango\n```\n\n## Usage\n\nAfter installing this plugin you have access to one additional action (`mango`) in your `Fastfile`.\n\nSo a lane in your `Fastfile` could look similar to this for Espresso tests:\n```ruby\ndesc \"Run espresso tests on docker images\"\n  lane :Espresso_Tests do\n     run_dockerized_task(\n       container_name: \"espresso_container\",\n       port_factor: options[:port_factor],\n       docker_image: \"joesss/mango-docker:latest\",\n       container_timeout: 120,\n       android_task: \"./gradlew connectedAndroidTest\",\n       post_actions: \"adb logcat -d \u003e logcat.txt\",\n       pull_latest_image: true          \n     )\n   end\n```\n\nor to this for unit tests or other gradle tasks(some of the variables are optional):\n```ruby\ndesc \"Run unit tests on docker images\"\n  lane :example do\n    run_dockerized_task(\n      container_name: \"emulator_#{options[:port_factor]}\",\n      port_factor: options[:port_factor],\n      docker_image: 'joesss/mango-base:latest',\n      android_task: './gradlew testDebug',\n      post_actions: 'adb logcat -d \u003e logcat.txt',\n      bundle_install: true,\n      core_amount: '8',\n      workspace_dir: '/root/tests/espresso-tests',\n      docker_registry_login: \"docker login -u='USER' -p='PASS' some.docker.com\",\n      pull_latest_image: true,\n      pre_action: 'echo $GIT_BRANCH \u003e /root/.branch',\n      vnc_enabled: false,\n      environment_variables: options[:environment_variables] ? options[:environment_variables].split(' ') : ''\n    )\n  end\n```\n\nNow you can call this new lane by calling `bundle exec fastlane Espresso_Tests`.\n\nThe Plugin will start up the given `docker_image`, execute the given `android_task` and afterwards execute the `post_actions`.\n\n## Configuration options\nThe `mango` action has plenty of options to configure it.\n\n| Option | Description | Default value | Optional | Type |\n| - |:-|-:| :-:| -:|\n| `container_name`| Name of the docker container. Will be generated randomly if not defined. | - | ✅ | `String` |\n| `no_vnc_port` | Port to redirect noVNC. To observe your docker container from your browser while it's running. | 6080 | ❌ | `Integer` |\n| `device_name` | Name of the Android device. | Nexus 5X | ❌ | `String` |\n| `emulator_name`| Name of the Android emulator. | emulator-5554 | ❌ | `String` |\n| `docker_image` | Name of the Docker image, that should be started and used to run your tasks. | butomo1989/docker-android-x86-5.1.1 | ❌ | `String` |\n| `container_timeout` | Timeout (in seconds) to get a healthy docker container. Depending on your `docker_image` it may take some time until it's started up and ready to use. | 450 (this equals 7.5 minutes) | ❌ | `Integer` |\n| `android_task` | A generic Android task you want to execute. | - | ❌ | `String` |\n| `core_amount` | Cpu core amount while starting docker container with limited resource. | - | ✅ | `Integer` |\n| `sdk_path` | The path to your Android sdk directory. | `ANDROID_HOME` environment variable | ✅ | `String` |\n| `port_factor` | Base for calculating a unique port for noVNC. We recommend to use the `EXECUTOR_NUMBER` from your Jenkins environment. | - | ✅ | `String` |\n| `workspace_dir` | Path to the workspace to execute commands. If you want to execute your `android_task` from a different directory you have to specify `workspace_dir`. | `/root/tests/` | ✅ | `String` |\n| `maximal_run_time` | Defines the maximal time of your test run in minutes. This can be helpful if you want to kill hanging processes automatically after a certain time. | 60 | ✅ | `Integer` |\n| `bundle_install` | Defines if the Android task must execute `bundle install` before running a build. This is useful if you want to execute non-gradle tasks. Like [Calabash](https://github.com/calabash/calabash-android), where you need to update/install your [Ruby](https://www.ruby-lang.org) dependencies. | `true` | ✅ | `Boolean` |\n| `is_running_on_emulator` | Define if container boots up an emulator instance inside of it. This will trigger configuration of noVNC, assign necessary ports etc. | `true` | ✅ | `Boolean` |\n| `post_actions` | Actions that will be executed after the main command has been executed. | - | ✅ | `String` |\n| `pre_action` | Actions that will be executed before the docker image gets pulled | - | ✅ | `String` |\n| `docker_registry_login` | Command to authenticate yourself in a custom Docker registry | - | ✅ | `String` |\n| `pull_latest_image` | Defines if you want to pull the `:latest` tag of the given `docker_image` | `false` | ✅ | `Boolean` |\n\n## Contributing\n\n🎁 Bug reports and pull requests for new features are most welcome!\n\n👷🏼 We are looking forward to your pull request, we'd love to help!\n\nYou can help by doing any of the following:\n\n- Reviewing pull requests\n- Bringing ideas for new features\n- Answering questions on issues\n- Improving documentation\n\nThis project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant code](http://contributor-covenant.org/) of conduct.\n\n## Issues and Feedback\n\nFor any other issues and feedback about this plugin, please submit it to this repository.\n\n## Troubleshooting\n\nIf you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.\n\n## License\n\nThe fastlane plugin is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n## Example\n\nCheck out the [example `Fastfile`](sample-android/fastlane/Fastfile) to see how to use this plugin.\nTry it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.\n\n## Run tests for this plugin\n\nTo run both the tests and code style validation, run\n\n```\nrake\n```\n\nTo automatically fix many of the styling issues, use\n```\nrubocop -a\n```\n\n## Using _fastlane_ Plugins\n\nFor more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).\n\n## About _fastlane_\n\n_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxing%2Fmango","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxing%2Fmango","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxing%2Fmango/lists"}