Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

feat: Consumable In-App Purchases #777

feat: Consumable In-App Purchases

feat: Consumable In-App Purchases #777

name: Android Test Suite
# The workflow will start for every PR against master branch
on:
pull_request:
push:
branches:
- master
# Multiple jobs run in parallel
jobs:
android_test_cases:
name: Android Unit Tests
runs-on: ubuntu-20.04
steps:
# Checkouts the current branch for processing
- name: Checkout
uses: actions/checkout@v2
# Setup the Java environment
- name: Setup JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
# Cache and restore the Gradle dependencies on multiple runs
- name: Gradle cache
uses: gradle/gradle-build-action@v2
# Run android unit tests & organize test reports
- name: Run tests
run: |
chmod +x gradlew
./gradlew jacocoProdDebugUnitTestReport
./gradlew copyUnitTestBuildArtifacts
# Uploads the folder or file in path to GitHub
- name: Upload Test Report
# Run this step even if the previous fails
if: always()
uses: actions/upload-artifact@v2
with:
name: Unit Test Report
path: artifacts
# TODO: Enable once Codecov configured with the repo by setting up `fail_ci_if_error` to true
# Upload the test report to Codecov for coverage report
- name: Codecov Report
uses: codecov/codecov-action@v2
with:
directory: artifacts
files: jacocoProdDebugUnitTestReport.xml
fail_ci_if_error: false
verbose: true
# TODO: Re-enable this job when the Instrument Test functionality is restored - Remove 'if: false'
android_screenshot:
name: Android Instrumented Tests
# The macOS VM provided by GitHub Actions has HAXM installed so we are able to create a new AVD
# instance, launch an emulator with hardware acceleration, and run our Android tests directly
# on the VM.
# Includes Screenshot Tests
# Ref: https://github.com/marketplace/actions/android-emulator-runner
runs-on: macos-11
if: false
steps:
# Checkouts the current branch for processing
- name: Checkout
uses: actions/checkout@v2
# Setup the Java environment
- name: Setup JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
# Install Python 2.7 to support Pillow library for screenshot testing
# Ref: https://github.com/facebook/screenshot-tests-for-android#requirements
- name: Setup Python 2.7
uses: actions/setup-python@v2
with:
python-version: 2.7
# Install requirements for screenshot testing
- name: Install Requirements
run: pip install -r requirements.txt
# Cache and restore the Gradle dependencies on multiple runs
- name: Gradle cache
uses: gradle/gradle-build-action@v2
# Cache and restore the particular Android Virtual Device
- name: AVD cache
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-21
# Create AVD for caching and to be used later
- name: Create AVD and generate a snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
profile: Nexus 4
api-level: 21
arch: x86
target: google_apis
disable-animations: false
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: echo "Generated AVD snapshot for caching."
# Run screenshot test cases and pull the screenshot from device to be used for reporting
- name: Run E2E
uses: reactivecircus/android-emulator-runner@v2
with:
profile: Nexus 4
api-level: 21
arch: x86
target: google_apis
disable-animations: true
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: |
./gradlew verifyProdDebuggableAndroidTestScreenshotTest -PdisablePreDex
./gradlew pullProdDebuggableAndroidTestScreenshots -PdisablePreDex
mv OpenEdXMobile/screenshots artifacts/
# Uploads the folder or file in path to GitHub
- name: Upload Test Report
if: always()
uses: actions/upload-artifact@v2
with:
name: Screenshot Test Report
path: artifacts