Create main GitHub Actions workflow

pull/541/head
Alinson S. Xavier 6 years ago
parent cbee09c38f
commit b7be459537

@ -0,0 +1,25 @@
name: Build & Test
on: [push]
jobs:
build:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1
- name: Install Java Development Kit 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build APK & Run small tests
run: android/build.sh build
- name: Run medium tests
uses: ReactiveCircus/android-emulator-runner@v2.2.0
with:
api-level: 29
script: android/build.sh medium-tests
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: Build
path: android/uhabits-android/build/outputs/

@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
cd "$(dirname "$0")"
ADB="${ANDROID_HOME}/platform-tools/adb" ADB="${ANDROID_HOME}/platform-tools/adb"
EMULATOR="${ANDROID_HOME}/tools/emulator" EMULATOR="${ANDROID_HOME}/tools/emulator"
GRADLE="./gradlew --stacktrace" GRADLE="./gradlew --stacktrace"
@ -155,10 +157,17 @@ run_instrumented_tests() {
-w ${PACKAGE_NAME}.test/android.support.test.runner.AndroidJUnitRunner \ -w ${PACKAGE_NAME}.test/android.support.test.runner.AndroidJUnitRunner \
| tee ${OUTPUTS_DIR}/instrument.txt | tee ${OUTPUTS_DIR}/instrument.txt
mkdir -p ${OUTPUTS_DIR}/code-coverage/connected/ if grep FAILURES $OUTPUTS_DIR/instrument.txt; then
$ADB pull /data/user/0/${PACKAGE_NAME}/files/coverage.ec \ log_error "Some instrumented tests failed"
${OUTPUTS_DIR}/code-coverage/connected/ \ fetch_images
|| log_error "COVERAGE REPORT NOT AVAILABLE" fetch_logcat
exit 1
fi
#mkdir -p ${OUTPUTS_DIR}/code-coverage/connected/
#$ADB pull /data/user/0/${PACKAGE_NAME}/files/coverage.ec \
# ${OUTPUTS_DIR}/code-coverage/connected/ \
# || log_error "COVERAGE REPORT NOT AVAILABLE"
} }
parse_instrumentation_results() { parse_instrumentation_results() {
@ -173,16 +182,8 @@ generate_coverage_badge() {
python3 tools/coverage-badge/badge.py -i $CORE_REPORT -o ${OUTPUTS_DIR}/coverage-badge python3 tools/coverage-badge/badge.py -i $CORE_REPORT -o ${OUTPUTS_DIR}/coverage-badge
} }
fetch_artifacts() {
log_info "Fetching generated artifacts"
mkdir -p ${OUTPUTS_DIR}/failed
$ADB pull /mnt/sdcard/test-screenshots/ ${OUTPUTS_DIR}/failed
$ADB pull /storage/sdcard/test-screenshots/ ${OUTPUTS_DIR}/failed
$ADB pull /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/ ${OUTPUTS_DIR}/failed
}
fetch_logcat() { fetch_logcat() {
log_info "Fetching logcat to ${OUTPUTS_DIR}/logcat.txt" log_info "Fetching logcat"
$ADB logcat -d > ${OUTPUTS_DIR}/logcat.txt $ADB logcat -d > ${OUTPUTS_DIR}/logcat.txt
} }
@ -201,14 +202,9 @@ uninstall_test_apk() {
} }
fetch_images() { fetch_images() {
rm -rf tmp/test-screenshots > /dev/null log_info "Fetching images"
mkdir -p tmp/ rm -rf $OUTPUTS_DIR/test-screenshots
$ADB pull /mnt/sdcard/test-screenshots/ tmp/ $ADB pull /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/ $OUTPUTS_DIR
$ADB pull /storage/sdcard/test-screenshots/ tmp/
$ADB pull /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/ tmp/
$ADB shell rm -r /mnt/sdcard/test-screenshots/
$ADB shell rm -r /storage/sdcard/test-screenshots/
$ADB shell rm -r /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/ $ADB shell rm -r /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/
} }
@ -226,7 +222,6 @@ run_tests() {
install_test_apk install_test_apk
run_instrumented_tests $SIZE run_instrumented_tests $SIZE
parse_instrumentation_results parse_instrumentation_results
fetch_artifacts
fetch_logcat fetch_logcat
uninstall_test_apk uninstall_test_apk
} }

Loading…
Cancel
Save