├── .github ├── ISSUE_TEMPLATE │ ├── BUG_REPORT.md │ └── FEATURE_REQUEST.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── pr-pipeline-workflow.yml ├── Gemfile ├── README.md ├── docs ├── fastlane.md ├── github-actions.md └── images │ ├── fastlane_summary.png │ ├── issue_template.png │ ├── pipeline.png │ ├── template.png │ └── template_repository.png └── fastlane ├── Appfile ├── Fastfile ├── Pluginfile ├── README.md └── avd_setup.json /.github/ISSUE_TEMPLATE/BUG_REPORT.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 🐛 3 | about: Report a bug or something that is not working as expected 4 | 5 | --- 6 | 7 | ### New Issue Checklist 8 | 9 | - [ ] Fetched latest code from master 10 | - [ ] Able to reproduce error 11 | - [ ] Attached error message 12 | - [ ] Attached logcat and additional logs 13 | 14 | ### Issue Description 15 | 16 | ``` 17 | 18 | ``` 19 | 20 | ### Steps to Reproduce 21 | 22 | ``` 23 | 24 | ``` 25 | 26 | ### Error Message 27 | 28 | ``` 29 | 30 | ``` 31 | 32 | ### Logs 33 | 34 | ``` 35 | 36 | ``` 37 | 38 | ### Environment 39 | 40 | ``` 41 | 42 | ``` -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 🚀 3 | about: A suggestion for a new feature 4 | 5 | --- 6 | 7 | ### Feature Request 8 | 9 | ### Motivation Behind Feature 10 | 11 | ``` 12 | 13 | ``` 14 | 15 | ### Feature Description 16 | 17 | ``` 18 | 19 | ``` 20 | 21 | ### Alternatives or Workarounds 22 | 23 | ``` 24 | 25 | ``` 26 | 27 | ### Additional Context 28 | 29 | ``` 30 | 31 | ``` -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | ### Pull Request Checklist 3 | - [ ] I have added proper commit messages 4 | - [ ] I have updated tests and documentation 5 | - [ ] I have assigned the required reviewers and labels 6 | 7 | ### Story or Ticket Number 8 | 9 | ``` 10 | 11 | ``` 12 | 13 | ### Short Description of Change 14 | 15 | ``` 16 | 17 | ``` 18 | 19 | ### Motivation and Context 20 | 21 | ``` 22 | 23 | ``` 24 | 25 | ### Testing Steps 26 | 27 | ``` 28 | 29 | ``` 30 | 31 | ### Risks Associated 32 | 33 | ``` 34 | 35 | ``` 36 | 37 | ### Additional Information 38 | 39 | ``` 40 | 41 | ``` -------------------------------------------------------------------------------- /.github/workflows/pr-pipeline-workflow.yml: -------------------------------------------------------------------------------- 1 | name: PR Pipeline Workflow 2 | 3 | # Execute PR Pipeline Workflow on pull requests to master 4 | on: 5 | pull_request: 6 | branches: 7 | - master 8 | 9 | 10 | jobs: 11 | ########################################################## 12 | # Compile Job: 13 | # Install dependencies and compile debug and test sources 14 | ########################################################## 15 | compile: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Checkout Repo 19 | uses: actions/checkout@v2 20 | 21 | - name: Set up Ruby 2.6 22 | uses: actions/setup-ruby@v1 23 | with: 24 | ruby-version: 2.6.x 25 | 26 | - name: Install Dependencies 27 | run: gem install bundler && bundle install 28 | 29 | - name: Run Fastlane Compile Lane 30 | run: fastlane compile 31 | 32 | 33 | ########################################################## 34 | # Lint Job: 35 | # Install dependencies and execute lint debug 36 | ########################################################## 37 | lint: 38 | needs: compile 39 | runs-on: ubuntu-latest 40 | steps: 41 | - name: Checkout Repo 42 | uses: actions/checkout@v2 43 | 44 | - name: Set up Ruby 2.6 45 | uses: actions/setup-ruby@v1 46 | with: 47 | ruby-version: 2.6.x 48 | 49 | - name: Install Dependencies 50 | run: gem install bundler && bundle install 51 | 52 | - name: Run Fastlane Lint Lane 53 | run: fastlane lint 54 | 55 | 56 | ########################################################## 57 | # Assemble Job: 58 | # Install dependencies and assemble debug and test APKs 59 | ########################################################## 60 | assemble: 61 | needs: lint 62 | runs-on: ubuntu-latest 63 | steps: 64 | - name: Checkout Repo 65 | uses: actions/checkout@v2 66 | 67 | - name: Set up Ruby 2.6 68 | uses: actions/setup-ruby@v1 69 | with: 70 | ruby-version: 2.6.x 71 | 72 | - name: Install Dependencies 73 | run: gem install bundler && bundle install 74 | 75 | - name: Run Fastlane Assemble Lane 76 | run: fastlane assemble 77 | 78 | 79 | ########################################################## 80 | # Unit Test Job: 81 | # Install dependencies and execute unit tests 82 | ########################################################## 83 | unit_test: 84 | needs: assemble 85 | runs-on: ubuntu-latest 86 | steps: 87 | - name: Checkout Repo 88 | uses: actions/checkout@v2 89 | 90 | - name: Set up Ruby 2.6 91 | uses: actions/setup-ruby@v1 92 | with: 93 | ruby-version: 2.6.x 94 | 95 | - name: Install Dependencies 96 | run: gem install bundler && bundle install 97 | 98 | - name: Run Fastlane Unit Test Lane 99 | run: fastlane unit_test 100 | 101 | 102 | ########################################################## 103 | # Instrumentation Test Job: 104 | # Install dependencies and execute instrumentation tests 105 | # - Using macOS to initiate Android Emulator 106 | ########################################################## 107 | instrumentation_test: 108 | needs: assemble 109 | runs-on: macOS-latest 110 | steps: 111 | - name: Checkout Repo 112 | uses: actions/checkout@v2 113 | 114 | - name: Run Instrumentation Tests on Emulator 115 | uses: reactivecircus/android-emulator-runner@v2 116 | with: 117 | api-level: 28 118 | script: ./gradlew connectedDebugAndroidTest -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "fastlane" 4 | 5 | plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') 6 | eval_gemfile(plugins_path) if File.exist?(plugins_path) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android Template 2 | 3 | A GitHub template to start building Android applications with Fastlane and GitHub Actions. 4 | 5 | ![](docs/images/fastlane_summary.png) 6 | 7 |
8 | 9 | ## Get Started 10 | 11 | To get started with this template, create a repository with this template and then add the Android application folder. Follow the steps below. 12 | 13 | 1. Click on `Use this template` 14 | 15 | ![](docs/images/template.png) 16 | 17 | 2. Enter details on your new repository. The new repository will automatically include the files from this template repository. 18 | 19 | ![](docs/images/template_repository.png) 20 | 21 | 3. Git clone your new repository on your local machine. 22 | 23 | 4. Open Android Studio and create a new project. Select the folder you just cloned in the save location. If you already have an Android project, copy over the files into the cloned folder. 24 | 25 | 5. Git push your changes to the remote repository. 26 | 27 | Congratulations. You have successfully set up your Android development environment with Fastlane and GitHub Actions. 28 | 29 |
30 | 31 | ## Fastlane 32 | 33 | Fastlane is a tool to automate any tedious tasks in building, testing and deploying mobile applications. In this template, the fastlane template is set up to run specific gradle commands locally and on the GitHub Actions continuous integration (CI) pipeline. 34 | 35 | To get started with fastlane, refer to the [Fastlane Summary](docs/fastlane.md). 36 | 37 |
38 | 39 | ## GitHub Actions 40 | 41 | GitHub Actions allows the creation of custom workflows within the GitHub repository. These custom workflows can automate specific tasks within GitHub and build out a continuous integration and continuous deployment (CI/CD) pipeline. With this template, the CI pipeline is set up to validate new changes on pull requests to the master branch. 42 | 43 | To get started with GitHub Actions, refer to the [GitHub Actions Summary](docs/github-actions.md). 44 | 45 |
46 | 47 | ## Templates 48 | 49 | Creating issues and pull requests are common practices when working on a project. The creation of issues and pull requests comes with a pre-set template to ensure all of the required information are captured in the correct manner. The templates for issues and pull request can be found in the .github folder. 50 | 51 | ![](docs/images/issue_template.png) 52 | 53 |
-------------------------------------------------------------------------------- /docs/fastlane.md: -------------------------------------------------------------------------------- 1 | # Fastlane Summary 2 | 3 | ![](images/fastlane_summary.png) 4 | 5 |
6 | 7 | ## Installation 8 | 9 | Make sure you have the latest version of the Xcode command line tools installed: 10 | 11 | ``` 12 | xcode-select --install 13 | ``` 14 | 15 | Install _fastlane_ using 16 | ``` 17 | [sudo] gem install fastlane -NV 18 | ``` 19 | or alternatively using `brew cask install fastlane` 20 | 21 |
22 | 23 | ## Setup 24 | 25 | Requirement: Open the Appfile and replace the package name with the application's package name. 26 | 27 |
28 | 29 | ## Available Actions 30 | ### Android 31 | #### android compile 32 | ``` 33 | fastlane android compile 34 | ``` 35 | Compile debug and test sources 36 | #### android lint 37 | ``` 38 | fastlane android lint 39 | ``` 40 | Execute Android lint 41 | #### android assemble 42 | ``` 43 | fastlane android assemble 44 | ``` 45 | Assemble source and test APKs 46 | #### android unit_test 47 | ``` 48 | fastlane android unit_test 49 | ``` 50 | Execute unit tests 51 | #### android instrumentation_test 52 | ``` 53 | fastlane android instrumentation_test 54 | ``` 55 | Execute instrumentation test on Emulator 56 | 57 |
58 | 59 | ## Fastlane Plugin 60 | 61 | The Fastlane template uses a plugin to create and boot up an Android emulator. Once the emulator is running, the instrumentation tests are executed. Installation of the plugin can be found in the Pluginfile. 62 | 63 | To use the plugin in the fastlane template. Add the lane with the following configuration: 64 | 65 | ``` 66 | automated_test_emulator_run( 67 | AVD_setup_path: "fastlane/avd_setup.json", 68 | AVD_recreate_new: false, 69 | AVD_clean_after: false, 70 | gradle_task: "connectedDebugAndroidTest") 71 | ``` 72 | 73 | The automated_test_emulator_run configuration requires the setup json file. The avd_setup.json defines the properties of the emulator that will be used. To change the emulator type, modify or create a new avd configuration JSON file and refer it into the automated_test_emulator_run configuration in the lane. 74 | 75 | ---- 76 | 77 | More information about fastlane can be found on [fastlane.tools](https://fastlane.tools). 78 | The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools). -------------------------------------------------------------------------------- /docs/github-actions.md: -------------------------------------------------------------------------------- 1 | # GitHub Actions 2 | 3 | ![](images/pipeline.png) 4 | 5 |
6 | 7 | ## Pull Request Workflow 8 | 9 | When a pull request is made to master, the pull request workflow is activated and run the following jobs in order. To customize when to run the workflow, configure the following piece of yml. 10 | 11 | ``` 12 | on: 13 | pull_request: 14 | branches: 15 | - master 16 | ``` 17 | 18 |
19 | 20 | ## Jobs 21 | 22 | | Job | Description | 23 | | ----------- | ------------- | 24 | | compile | Install dependencies and compile debug and test sources | 25 | | lint | Install dependencies and execute lint debug | 26 | | assemble | Install dependencies and assemble debug and test APKs | 27 | | unit_test | Install dependencies and execute unit tests | 28 | | instrumentation_test | Install dependencies and execute instrumentation tests | -------------------------------------------------------------------------------- /docs/images/fastlane_summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asadmansr/template-android/4297edd396f67fda0da6aa1996c0377332cb507f/docs/images/fastlane_summary.png -------------------------------------------------------------------------------- /docs/images/issue_template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asadmansr/template-android/4297edd396f67fda0da6aa1996c0377332cb507f/docs/images/issue_template.png -------------------------------------------------------------------------------- /docs/images/pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asadmansr/template-android/4297edd396f67fda0da6aa1996c0377332cb507f/docs/images/pipeline.png -------------------------------------------------------------------------------- /docs/images/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asadmansr/template-android/4297edd396f67fda0da6aa1996c0377332cb507f/docs/images/template.png -------------------------------------------------------------------------------- /docs/images/template_repository.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asadmansr/template-android/4297edd396f67fda0da6aa1996c0377332cb507f/docs/images/template_repository.png -------------------------------------------------------------------------------- /fastlane/Appfile: -------------------------------------------------------------------------------- 1 | json_key_file("") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one 2 | package_name("") # e.g. com.krausefx.app -------------------------------------------------------------------------------- /fastlane/Fastfile: -------------------------------------------------------------------------------- 1 | # This file contains the fastlane.tools configuration 2 | # You can find the documentation at https://docs.fastlane.tools 3 | # 4 | # For a list of all available actions, check out 5 | # 6 | # https://docs.fastlane.tools/actions 7 | # 8 | # For a list of all available plugins, check out 9 | # 10 | # https://docs.fastlane.tools/plugins/available-plugins 11 | # 12 | 13 | # Uncomment the line if you want fastlane to automatically update itself 14 | # update_fastlane 15 | 16 | default_platform(:android) 17 | 18 | platform :android do 19 | desc "Compile debug and test sources" 20 | lane :compile do 21 | gradle(task: "compileDebugSources") 22 | gradle(task: "compileDebugUnitTestSources") 23 | gradle(task: "compileDebugAndroidTestSources") 24 | end 25 | 26 | desc "Execute Android lint" 27 | lane :lint do 28 | gradle(task: "lintDebug") 29 | end 30 | 31 | desc "Assemble source and test APKs" 32 | lane :assemble do 33 | gradle(task: "assembleDebug") 34 | gradle(task: "assembleDebugAndroidTest") 35 | end 36 | 37 | desc "Execute unit tests" 38 | lane :unit_test do 39 | gradle(task: "testDebugUnitTest") 40 | end 41 | 42 | desc "Execute instrumentation test on Emulator" 43 | lane :instrumentation_test do 44 | automated_test_emulator_run( 45 | AVD_setup_path: "fastlane/avd_setup.json", 46 | AVD_recreate_new: false, 47 | AVD_clean_after: false, 48 | gradle_task: "connectedDebugAndroidTest") 49 | end 50 | end -------------------------------------------------------------------------------- /fastlane/Pluginfile: -------------------------------------------------------------------------------- 1 | # Autogenerated by fastlane 2 | # 3 | # Ensure this file is checked in to source control! 4 | 5 | gem 'fastlane-plugin-automated_test_emulator_run' -------------------------------------------------------------------------------- /fastlane/README.md: -------------------------------------------------------------------------------- 1 | fastlane documentation 2 | ================ 3 | # Installation 4 | 5 | Make sure you have the latest version of the Xcode command line tools installed: 6 | 7 | ``` 8 | xcode-select --install 9 | ``` 10 | 11 | Install _fastlane_ using 12 | ``` 13 | [sudo] gem install fastlane -NV 14 | ``` 15 | or alternatively using `brew cask install fastlane` 16 | 17 | # Available Actions 18 | ## Android 19 | ### android compile 20 | ``` 21 | fastlane android compile 22 | ``` 23 | Compile debug and test sources 24 | ### android lint 25 | ``` 26 | fastlane android lint 27 | ``` 28 | Execute Android lint 29 | ### android assemble 30 | ``` 31 | fastlane android assemble 32 | ``` 33 | Assemble source and test APKs 34 | ### android unit_test 35 | ``` 36 | fastlane android unit_test 37 | ``` 38 | Execute unit tests 39 | ### android instrumentation_test 40 | ``` 41 | fastlane android instrumentation_test 42 | ``` 43 | Execute instrumentation test on Emulator 44 | 45 | ---- 46 | 47 | This README.md is auto-generated and will be re-generated every time [fastlane](https://fastlane.tools) is run. 48 | More information about fastlane can be found on [fastlane.tools](https://fastlane.tools). 49 | The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools). -------------------------------------------------------------------------------- /fastlane/avd_setup.json: -------------------------------------------------------------------------------- 1 | { 2 | "avd_list": [ 3 | { 4 | "avd_name": "Nexus_6P_API_26", 5 | "create_avd_package": "system-images;android-26;google_apis;x86", 6 | "create_avd_device": "Nexus 6P API 26", 7 | "create_avd_tag": "google_apis", 8 | "create_avd_abi": "x86", 9 | "create_avd_additional_options": "", 10 | "create_avd_hardware_config_filepath": "", 11 | "launch_avd_port": "", 12 | "launch_avd_snapshot_filepath": "", 13 | "launch_avd_launch_binary_name": "emulator", 14 | "launch_avd_additional_options": "-skin 1080x1920 -gpu on" 15 | } 16 | ] 17 | } --------------------------------------------------------------------------------