diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..d78c5099b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,141 @@ +name: Test and deploy + +on: + push: + branches: [ develop ] + tags: [ '*' ] + pull_request: + branches: [ develop ] + + workflow_dispatch: + +jobs: + build: + name: Pre-build + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: fkirc/skip-duplicate-actions@master + - uses: actions/checkout@v2 + - uses: gradle/wrapper-validation-action@v1 + - uses: actions/setup-java@v1 + with: + java-version: 11 + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }} + - name: Build + run: ./gradlew compileFdroidDebugUnitTestKotlin packageFdroidDebug preFdroidDebugAndroidTestBuild + - name: Prepare build cache + run: tar -cvf prebuild.tar .gradle app/build + - uses: actions/upload-artifact@v2 + with: + name: prebuild.tar + path: prebuild.tar + + unit-tests: + name: Unit tests + runs-on: ubuntu-latest + timeout-minutes: 10 + needs: [ build ] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 11 + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }} + - uses: actions/download-artifact@v2 + with: + name: prebuild.tar + - name: Extract build cache + run: tar -xvf prebuild.tar app/build + - name: Unit tests + run: | + ./gradlew -Pcoverage testFdroidDebugUnitTest --stacktrace + ./gradlew -Pcoverage jacocoTestReport --stacktrace + - uses: codecov/codecov-action@v1 + with: + flags: unit + + instrumentation-tests: + name: Instrumentation tests + runs-on: ubuntu-latest + timeout-minutes: 15 + needs: [ build ] + strategy: + fail-fast: true + matrix: + api-level: [21, 29] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 11 + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }} + - uses: actions/download-artifact@v2 + with: + name: prebuild.tar + - name: Extract build cache + run: tar -xvf prebuild.tar app/build + - name: Instrumentation tests + uses: reactivecircus/android-emulator-runner@v2.13.0 + with: + api-level: ${{ matrix.api-level }} + arch: x86 + script: | + ./gradlew -Pcoverage connectedFdroidDebugAndroidTest --stacktrace + ./gradlew -Pcoverage jacocoTestReport --stacktrace + - uses: codecov/codecov-action@v1 + with: + flags: instrumented,api-${{ matrix.api-level }} + + deploy-google-play: + name: Deploy to google play + runs-on: ubuntu-latest + timeout-minutes: 10 + environment: google-play + needs: [ build, unit-tests, instrumentation-tests ] + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 11 + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }} + - uses: actions/download-artifact@v2 + with: + name: prebuild.tar + - name: Extract build cache + run: tar -xvf prebuild.tar app/build + - name: Decrypt keys + env: + ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }} + SERVICES_ENCRYPT_KEY: ${{ secrets.SERVICES_ENCRYPT_KEY }} + run: | + gpg --yes --batch --passphrase=$SERVICES_ENCRYPT_KEY ./app/src/release/google-services.json.gpg + gpg --yes --batch --passphrase=$ENCRYPT_KEY ./app/key.p12.gpg + gpg --yes --batch --passphrase=$ENCRYPT_KEY ./app/upload-key.jks.gpg + - name: Upload apk to google play + env: + PLAY_KEY_PASSWORD: ${{ secrets.PLAY_KEY_PASSWORD }} + PLAY_SERVICE_ACCOUNT_EMAIL: ${{ secrets.PLAY_SERVICE_ACCOUNT_EMAIL }} + PLAY_STORE_PASSWORD: ${{ secrets.PLAY_STORE_PASSWORD }} + run: ./gradlew publishPlayRelease -PenableFirebase --stacktrace; diff --git a/README.en.md b/README.en.md index 4c5e53da8..accc36082 100644 --- a/README.en.md +++ b/README.en.md @@ -1,7 +1,8 @@ [Polska wersja README](README.md) # Wulkanowy -[![Travis](https://img.shields.io/travis/com/wulkanowy/wulkanowy/master.svg?style=flat-square)](https://travis-ci.com/wulkanowy/wulkanowy) + +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/wulkanowy/wulkanowy/Test%20and%20deploy/develop?style=flat-square)](https://github.com/wulkanowy/wulkanowy/actions) [![Codecov](https://img.shields.io/codecov/c/github/wulkanowy/wulkanowy/master.svg?style=flat-square)](https://codecov.io/gh/wulkanowy/wulkanowy) [![Discord](https://img.shields.io/discord/390889354199040011.svg?style=flat-square)](https://discord.gg/vccAQBr) [![F-Droid](https://img.shields.io/f-droid/v/io.github.wulkanowy.svg?style=flat-square)](https://f-droid.org/packages/io.github.wulkanowy/) @@ -50,7 +51,8 @@ You can also download a [development version](https://wulkanowy.github.io/#downl * [Wulkanowy SDK](https://github.com/wulkanowy/sdk) -* [Dagger 2](https://github.com/google/dagger) +* [Kotlin Coroutines](https://kotlinlang.org/docs/reference/coroutines-overview.html) +* [Hilt](https://dagger.dev/hilt/) * [Room](https://developer.android.com/topic/libraries/architecture/room) * [WorkManager](https://developer.android.com/topic/libraries/architecture/workmanager) diff --git a/README.md b/README.md index 9e29cdb6c..ca3b55904 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ [English version of README](README.en.md) # Wulkanowy -[![Travis](https://img.shields.io/travis/com/wulkanowy/wulkanowy/master.svg?style=flat-square)](https://travis-ci.com/wulkanowy/wulkanowy) + +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/wulkanowy/wulkanowy/Test%20and%20deploy/develop?style=flat-square)](https://github.com/wulkanowy/wulkanowy/actions) [![Codecov](https://img.shields.io/codecov/c/github/wulkanowy/wulkanowy/master.svg?style=flat-square)](https://codecov.io/gh/wulkanowy/wulkanowy) [![Discord](https://img.shields.io/discord/390889354199040011.svg?style=flat-square)](https://discord.gg/vccAQBr) [![F-Droid](https://img.shields.io/f-droid/v/io.github.wulkanowy.svg?style=flat-square)](https://f-droid.org/packages/io.github.wulkanowy/) @@ -50,8 +51,9 @@ Możesz także pobrać [wersję rozwojową](https://wulkanowy.github.io/#downloa ## Zbudowana za pomocą -* [Wulkanowy SDK](https://github.com/wulkanowy/SDK) -* [Dagger 2](https://github.com/google/dagger) +* [Wulkanowy SDK](https://github.com/wulkanowy/sdk) +* [Kotlin Coroutines](https://kotlinlang.org/docs/reference/coroutines-overview.html) +* [Hilt](https://dagger.dev/hilt/) * [Room](https://developer.android.com/topic/libraries/architecture/room) * [WorkManager](https://developer.android.com/topic/libraries/architecture/workmanager) diff --git a/app/jacoco.gradle b/app/jacoco.gradle index a5cf84e63..94469fbc0 100644 --- a/app/jacoco.gradle +++ b/app/jacoco.gradle @@ -7,6 +7,7 @@ jacoco { tasks.withType(Test) { jacoco.includeNoLocationClasses = true + jacoco.excludes = ['jdk.internal.*'] } task jacocoTestReport(type: JacocoReport) { diff --git a/app/src/test/java/io/github/wulkanowy/utils/TimeExtensionTest.kt b/app/src/test/java/io/github/wulkanowy/utils/TimeExtensionTest.kt index d604dfef4..3336c0d9d 100644 --- a/app/src/test/java/io/github/wulkanowy/utils/TimeExtensionTest.kt +++ b/app/src/test/java/io/github/wulkanowy/utils/TimeExtensionTest.kt @@ -50,7 +50,7 @@ class TimeExtensionTest { fun monthNameTest() { Locale.setDefault(Locale.forLanguageTag("PL")) assertEquals("Styczeń", JANUARY.getFormattedName()) - Locale.setDefault(Locale.forLanguageTag("US")) + Locale.setDefault(Locale.forLanguageTag("EN")) assertEquals("January", JANUARY.getFormattedName()) } @@ -58,7 +58,7 @@ class TimeExtensionTest { fun weekDayNameTest() { Locale.setDefault(Locale.forLanguageTag("PL")) assertEquals("poniedziałek", of(2018, 10, 1).weekDayName) - Locale.setDefault(Locale.forLanguageTag("US")) + Locale.setDefault(Locale.forLanguageTag("EN")) assertEquals("Monday", of(2018, 10, 1).weekDayName) }