Fix script #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android Build and Test | |
on: | |
push: | |
branches: | |
- 'feature/github_actions' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
TARGET_VERSION: 30 | |
ANDROID_BUILD_TOOLS_VERSION: 30.0.2 | |
ANDROID_HOME: ${{ github.workspace }}/android-sdk | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v2 | |
- name: Download and Install Android SDK | |
run: | | |
mkdir -p $ANDROID_HOME | |
wget "https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip" -O commandlinetools.zip | |
unzip -q commandlinetools.zip -d $ANDROID_HOME/ | |
echo 'export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin' >> $GITHUB_ENV | |
source $GITHUB_ENV | |
- name: Accept Android Licenses | |
run: yes | sdkmanager --licenses | |
- name: List Available Emulators | |
run: | | |
sdkmanager --list | |
emulator -list-avds # Check available AVDs | |
- name: Install SDK components | |
run: | | |
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "platforms;android-31" "system-images;android-31;google_apis;x86_64" | |
- name: Create AVD | |
run: echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n testRunner -d 19 -k "system-images;android-31;google_apis;x86_64" | |
- name: Cache Gradle Dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
- name: Set Cloudinary URL | |
run: | | |
bash tools/get_test_cloud.sh > cloudinary_url.txt | |
echo "CLOUDINARY_URL=$(cat cloudinary_url.txt)" >> $GITHUB_ENV | |
- name: Check Emulator Command Availability | |
run: | | |
which emulator # Check if emulator command is available | |
echo $PATH # Check the PATH variable contents for emulator directory | |
- name: Start Emulator | |
run: | | |
emulator -list-avds | |
emulator -avd your_emulator_name -no-window -no-audio & | |
android-wait-for-emulator | |
adb devices | |
- name: Wait for Emulator | |
run: | | |
emulator -list-avds # Lists available emulators for reference | |
emulator -avd your_emulator_name -no-window -no-audio & | |
android-wait-for-emulator | |
adb devices # Check if the emulator is recognized as a connected device | |
- name: Build and Test | |
run: ./gradlew clean connectedCheck |