From 02d2c2fdba013caaef3fea1a429570085927fe35 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Fri, 6 Dec 2019 14:53:14 +0100 Subject: [PATCH] Actions tests --- .github/codecov.yml | 17 +++++++++ .github/workflows/build.yml | 72 ++++++++++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 15 ++++++++ cameraview/build.gradle | 10 ++--- 4 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 .github/codecov.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/deploy.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 00000000..2694c73f --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,17 @@ +coverage: + precision: 1 + round: down + range: "30...70" + + status: + project: + default: + target: 40% + patch: + default: + target: 70% + changes: no + +comment: + # diff, changes, footer, reach, flags, suggestions + layout: "header, files" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..57ff2dd4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,72 @@ +# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions +name: Android Build +on: [push, pull_request] +env: + - ANDROID_UNIT_TESTS_PATH: ./cameraview/build/jacoco/ + - ANDROID_EMULATOR_TESTS_PATH: ./cameraview/build/outputs/code_coverage/debugAndroidTest/connected +jobs: + ANDROID_BASE_CHECKS: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + with: fetch-depth: 1 + - uses: actions/setup-java@v1 + with: java-version: 1.8 + - run: ./gradlew demo:assembleDebug cameraview:javadoc + ANDROID_UNIT_TESTS: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + with: fetch-depth: 1 + - uses: actions/setup-java@v1 + with: java-version: 1.8 + - run: ./gradlew cameraview:testDebugUnitTest + - uses: actions/upload-artifact@v1 + with: + name: unit_tests + path: $ANDROID_UNIT_TESTS_PATH + ANDROID_EMULATOR_TESTS: + runs-on: macOS-latest + strategy: + matrix: + EMULATOR_API: [22] + EMULATOR_ARCH: [x86_64] + steps: + - uses: actions/checkout@v1 + with: fetch-depth: 1 + - uses: actions/setup-java@v1 + with: java-version: 1.8 + - 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 + - uses: actions/upload-artifact@v1 + with: + name: emulator_tests + path: $ANDROID_EMULATOR_TESTS_PATH + CODE_COVERAGE: + runs-on: ubuntu-latest + needs: [ANDROID_UNIT_TESTS, ANDROID_EMULATOR_TESTS] + steps: + - uses: actions/checkout@v1 + with: fetch-depth: 1 + - uses: actions/setup-java@v1 + with: java-version: 1.8 + - uses: actions/download-artifact@v1 + with: + name: unit_tests + path: $ANDROID_UNIT_TESTS_PATH + - uses: actions/download-artifact@v1 + with: + name: emulator_tests + path: ANDROID_EMULATOR_TESTS_PATH + - run: ./gradlew cameraview:mergedCoverageReport + - uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_KEY }} + file: ./cameraview/build/reports/mergedCoverageReport + yml: ./.github/codecov.yml + 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..e370e03f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,15 @@ +# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions +name: Android Deploy +on: [release] +jobs: + BINTRAY_UPLOAD: + runs-on: ubuntu-latest + env: + - TRAVIS: true + - BINTRAY_USER: ${{ secrets.BINTRAY_USER }} + - BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }} + - uses: actions/checkout@v1 + with: fetch-depth: 1 + - uses: actions/setup-java@v1 + with: java-version: 1.8 + - run: ./gradlew bintrayUpload diff --git a/cameraview/build.gradle b/cameraview/build.gradle index b0f0551f..e9690270 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 { @@ -234,9 +234,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**.*')