From 79d00d5eba098b405b214a4b802bf57afcd899b6 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Fri, 6 Dec 2019 17:31:35 +0100 Subject: [PATCH] Drop Travis and move to GitHub actions (#694) --- .github/workflows/build.yml | 92 ++++++++++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 18 +++++++ .travis.yml | 90 ----------------------------------- README.md | 2 +- cameraview/build.gradle | 19 +++++--- 5 files changed, 124 insertions(+), 97 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/deploy.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..4a58a66d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,92 @@ +# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions +name: Build +on: + push: + branches: + - master + pull_request: +env: + TRAVIS: true +jobs: + ANDROID_BASE_CHECKS: + name: Base Checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Perform base checks + run: ./gradlew demo:assembleDebug cameraview:javadoc + ANDROID_UNIT_TESTS: + name: Unit Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Execute unit tests + run: ./gradlew cameraview:testDebugUnitTest + - name: Upload unit tests artifact + uses: actions/upload-artifact@v1 + with: + name: unit_tests + path: ./cameraview/build/jacoco/ + ANDROID_EMULATOR_TESTS: + name: Emulator Tests + runs-on: macOS-latest + strategy: + matrix: + EMULATOR_API: [22] + EMULATOR_ARCH: [x86_64] + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Execute emulator tests + uses: reactivecircus/android-emulator-runner@v1 + with: + api-level: ${{ matrix.EMULATOR_API }} + arch: ${{ matrix.EMULATOR_ARCH }} + disable-animations: true + headless: true + script: ./gradlew cameraview:connectedCheck + - name: Upload emulator tests artifact + uses: actions/upload-artifact@v1 + with: + name: emulator_tests + path: ./cameraview/build/outputs/code_coverage/debugAndroidTest/connected + CODE_COVERAGE: + name: Code Coverage Report + runs-on: ubuntu-latest + needs: [ANDROID_UNIT_TESTS, ANDROID_EMULATOR_TESTS] + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Download unit tests artifact + uses: actions/download-artifact@v1 + with: + name: unit_tests + path: ./cameraview/build/jacoco/ + - name: Download emulator tests artifact + uses: actions/download-artifact@v1 + with: + name: emulator_tests + path: ./cameraview/build/outputs/code_coverage/debugAndroidTest/connected + - name: Create merged coverage report + run: ./gradlew cameraview:mergeCoverageReports + - name: Upload merged coverage report (GitHub) + uses: actions/upload-artifact@v1 + with: + name: report + path: ./cameraview/build/reports/mergedCoverageReport + - name: Upload merged coverage report (Codecov) + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_KEY }} + file: ./cameraview/build/reports/mergedCoverageReport/* + fail_ci_if_error: true \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..a0cfa3b4 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,18 @@ +# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions +name: Deploy +on: [release] +jobs: + BINTRAY_UPLOAD: + name: Bintray Upload + runs-on: ubuntu-latest + env: + TRAVIS: true + BINTRAY_USER: ${{ secrets.BINTRAY_USER }} + BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }} + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Perform bintray upload + run: ./gradlew bintrayUpload diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5878a459..00000000 --- a/.travis.yml +++ /dev/null @@ -1,90 +0,0 @@ -# https://github.com/andstatus/andstatus/blob/master/.travis.yml - -language: android - -branches: - only: - - master - - /^v\d+\.\d+\.\d+$/ - - /^v\d+\.\d+\.\d+-beta\d+$/ - - /^v\d+\.\d+\.\d+-rc\d+$/ - -sudo: false - -jdk: - - oraclejdk8 - -env: - global: - - EMULATOR_API=22 # 24 has some issues, probably some overlayed window - - EMULATOR_ABI=x86_64 # seems to work with emulator v29. - - EMULATOR_TAG=default # can be google_apis - - PATH=$ANDROID_HOME:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$PATH - -android: - components: - - tools - - platform-tools - - build-tools-28.0.3 - - android-28 - - doc-28 - -install: - # Setup - - echo $ANDROID_HOME # We assume this is correctly set when setting path - - sdkmanager --list || true # Look at the packages - - echo yes | sdkmanager "tools" # Ensure tools is updated - - echo yes | sdkmanager "emulator" # Ensure emulator is present - - # Install emulator - # The channel=4 line looks into canary which brings in v29. - # The previous version v28 was broken: - # https://travis-ci.community/t/android-emulators-not-starting-for-the-last-few-days-late-march-2019/2871/11?u=mikehardy - - export EMULATOR="system-images;android-$EMULATOR_API;$EMULATOR_TAG;$EMULATOR_ABI" - - echo yes | sdkmanager "platforms;android-$EMULATOR_API" # Install sdk for the emulator - - echo yes | sdkmanager --channel=4 "$EMULATOR" # Install system image - - sdkmanager --list || true # Check everything is updated - - # Create adn start emulator - - echo no | avdmanager create avd -n test -k "$EMULATOR" -f # Create emulator virtual device - - which emulator # ensure we are using the right emulator ($ANDROID_HOME/emulator/emulator) - - emulator -avd test -no-window -no-accel -no-snapshot -camera-back emulated -camera-front emulated -memory 2048 -writable-system & # Launch - - adb wait-for-device # Wait for adb process - - adb remount # Mount as writable - -before_script: - # Wait for emulator - - android-wait-for-emulator # Wait for emulator ready to interact - - adb shell settings put global window_animation_scale 0 & # Disable animations - - adb shell settings put global transition_animation_scale 0 & # Disable animations - - adb shell settings put global animator_duration_scale 0 & # Disable animations - - # Unlock and configure logs. - # Would be great to use -v color to adb logcat but looks not supported on travis. - - sleep 20 # Sleep 20 seconds just in case - - adb shell input keyevent 82 & # Dispatch unlock event - - adb logcat --help # See if this version supports color - - adb logcat -c # Clear logcat - - adb logcat Test:V TestRunner:V CameraView:V CameraController:V Camera1:V WorkerHandler:V THREAD_STATE:S *:E & - # - export LOGCAT_PID=$! # Save PID of the logcat process. Should kill later with kill $LOGCAT_PID - - - -script: - - ./gradlew clean demo:assembleDebug cameraview:testDebugUnitTest cameraview:connectedCheck cameraview:mergedCoverageReport cameraview:javadoc - -after_success: - - bash <(curl -s https://codecov.io/bash) -s "*/build/reports/mergedCoverageReport/" - -cache: - directories: - - $HOME/.gradle - - $HOME/.m2/repository - -deploy: - provider: script - script: ./gradlew bintrayUpload - skip_cleanup: true - on: - branch: master - tags: true \ No newline at end of file diff --git a/README.md b/README.md index 9e63de74..fb313dd7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/natario1/CameraView.svg?branch=master)](https://travis-ci.org/natario1/CameraView) +[![Build Status](https://github.com/natario1/CameraView/workflows/Build/badge.svg)](https://github.com/natario1/CameraView/actions) [![Code Coverage](https://codecov.io/gh/natario1/CameraView/branch/master/graph/badge.svg)](https://codecov.io/gh/natario1/CameraView) [![Release](https://img.shields.io/github/release/natario1/CameraView.svg)](https://github.com/natario1/CameraView/releases) [![Issues](https://img.shields.io/github/issues-raw/natario1/CameraView.svg)](https://github.com/natario1/CameraView/issues) diff --git a/cameraview/build.gradle b/cameraview/build.gradle index b0f0551f..00367edb 100644 --- a/cameraview/build.gradle +++ b/cameraview/build.gradle @@ -8,7 +8,7 @@ group = 'com.otaliastudios' //region android dependencies -def travis = System.getenv("TRAVIS") +def isCI = System.getenv("TRAVIS") android { compileSdkVersion rootProject.ext.compileSdkVersion @@ -19,7 +19,7 @@ android { versionCode 1 versionName project.version testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - if (travis) { + if (isCI) { testInstrumentationRunnerArgument "notAnnotation", "com.otaliastudios.cameraview.DoNotRunOnTravis" } } @@ -109,7 +109,7 @@ install { def bintrayUser def bintrayKey -if (travis) { +if (isCI) { bintrayUser = System.getenv("BINTRAY_USER") bintrayKey = System.getenv("BINTRAY_KEY") } else { @@ -200,9 +200,16 @@ jacoco { reportsDir = file(reportsDirectory) } -task mergedCoverageReport(type: JacocoReport) { +task createCoverageReports() { dependsOn "testDebugUnitTest" dependsOn "connectedCheck" +} + +task mergeCoverageReports(type: JacocoReport) { + // Let this be called without running the tests. + // dependsOn "createCoverageReports" + // However, ensure we have the compiled .class files. + dependsOn "compileDebugSources" // Merge unit tests and android tests data executionData = fileTree(dir: "$buildDir", includes: [ @@ -234,9 +241,9 @@ task mergedCoverageReport(type: JacocoReport) { '**/Dagger*Component$Builder.class', '**/*Module_*Factory.class', ] - if (travis) { + if (isCI) { // All these classes are tested by the integration tests that we are not able to - // run on the travis emulator. + // run on the CI emulator. classFilter.add('**/com/otaliastudios/cameraview/engine/CameraEngine**.*') classFilter.add('**/com/otaliastudios/cameraview/engine/Camera1Engine**.*') classFilter.add('**/com/otaliastudios/cameraview/engine/Camera2Engine**.*')