This repository has been archived by the owner on May 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 333
140 lines (123 loc) · 4.49 KB
/
androidTestSuite.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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
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