Skip to content

Merge pull request #8 from oppia/develop #17

Merge pull request #8 from oppia/develop

Merge pull request #8 from oppia/develop #17

Workflow file for this run

# Contains jobs corresponding to Gradle tests (particularly Robolectric unit tests).
name: Unit Tests (Robolectric -- Gradle)
# Controls when the action will run. Triggers the workflow on pull request
# events or push events in the develop branch.
on:
workflow_dispatch:
pull_request:
push:
branches:
# Push events on develop branch
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
# This workflow has the following jobs:
# robolectric_tests: Robolectric tests for all modules except the app module
# app_tests: Non-flaky Robolectric tests for the app module
jobs:
robolectric_tests:
name: Non-app Module Robolectric Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-jars-{{ checksum "build.gradle" }}
- name: Set up JDK 1.9
uses: actions/setup-java@v1
with:
java-version: 1.9
- name: Check Java version & path
run: |
which java
java -version
echo "Java home: $JAVA_HOME"
$JAVA_HOME/bin/java -version
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: ./gradlew --full-stacktrace androidDependencies -Dorg.gradle.java.home=$JAVA_HOME
- name: Check Gradle environment
run: ./gradlew -Dorg.gradle.java.home=$JAVA_HOME -v
- name: Build App
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace assembleDebug -Dorg.gradle.java.home=$JAVA_HOME
- name: Utility tests
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace :utility:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME
- name: Upload Utility Test Reports
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status
with:
name: utility reports
path: utility/build/reports
- name: Data tests
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace :data:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME
- name: Upload Data Test Reports
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status
with:
name: data reports
path: data/build/reports
- name: Domain tests
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace :domain:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME
- name: Upload Domain Test Reports
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status
with:
name: domain reports
path: domain/build/reports
- name: Testing tests
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace :testing:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME
- name: Upload Testing Test Reports
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status
with:
name: testing reports
path: testing/build/reports
run_app_module_test:
name: Run app module Robolectric test shard
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
shard: [shard0, shard1, shard2, shard3, shard4, shard5, shard6, shard7]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-jars-{{ checksum "build.gradle" }}
- name: Set up JDK 1.9
uses: actions/setup-java@v1
with:
java-version: 1.9
- name: Check Java version & path
run: |
which java
java -version
echo "Java home: $JAVA_HOME"
$JAVA_HOME/bin/java -version
- name: Check Gradle environment
run: ./gradlew -Dorg.gradle.java.home=$JAVA_HOME -v
- name: Robolectric tests - App Module
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: |
sudo ./gradlew --full-stacktrace :app:testDebugUnitTest --${{ matrix.shard }} -Dorg.gradle.java.home=$JAVA_HOME
- name: Upload App Test Reports
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status
with:
name: app reports ${{ matrix.shard }}
path: app/build/reports
app_tests:
name: App Module Robolectric Tests
needs: run_app_module_test
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
steps:
- name: Check tests passed (for tests that ran)
if: ${{ needs.run_app_module_test.result != 'success' }}
run: exit 1