diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e447d2c3c..2bd2dc191 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,78 +1,188 @@ name: Android CI -on: [push, pull_request] +on: + push: + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + jobs: build: - runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Set up Android SDK License + run: yes | /usr/local/lib/android/sdk/tools/bin/sdkmanager --licenses + + - name: Build with Gradle + run: ./gradlew spotlessCheck lint build + + - name: Upload build reports + uses: actions/upload-artifact@v2 + with: + name: build-reports + path: ./app/build/reports + + unit-test: + runs-on: ubuntu-latest + needs: build + timeout-minutes: 30 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Set up Android SDK License + run: yes | /usr/local/lib/android/sdk/tools/bin/sdkmanager --licenses + + - name: Build with Gradle + run: ./gradlew test + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v2 + with: + name: unit-test-result + path: "**/build/test-results/**/*.xml" + + connected-test: + runs-on: macOS-latest + needs: build + timeout-minutes: 60 - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Set up Android SDK License - run: yes | /usr/local/lib/android/sdk/tools/bin/sdkmanager --licenses - - - name: Apply Signing - if: ${{ github.event_name != 'pull_request' }} - env: - ALIAS: ${{ secrets.ALIAS }} - KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} - KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }} - run: ./.github/apply_signing.sh - - - name: Build with Gradle - run: ./gradlew spotlessCheck lint bundle assemble --stacktrace - - - name: Upload build outputs - uses: actions/upload-artifact@v2 - with: - name: build-outputs - path: ./app/build/outputs - - - name: Upload build reports - uses: actions/upload-artifact@v2 - with: - name: build-reports - path: ./app/build/reports - - - name: Check if is prelease - if: startsWith(github.ref, 'refs/tags/') - id: check-tag - run: | - if [[ ${{ github.event.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+\-(dev|beta)[0-9]+$ ]]; then - echo ::set-output name=prelease::true - fi - - - name: Create Prerelease - if: steps.check-tag.outputs.prelease == 'true' - run: | - set -x - assets=() - for asset in $(find -name *-release.apk); do - assets+=("-a" "$asset") - done - tag_name="${GITHUB_REF##*/}" - hub release create "${assets[@]}" -m "$tag_name" "$tag_name" -p - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create Release - if: steps.check-tag.outputs.prelease != 'true' && startsWith(github.ref, 'refs/tags/') - run: | - set -x - assets=() - for asset in $(find -name *-release.apk); do - assets+=("-a" "$asset") - done - tag_name="${GITHUB_REF##*/}" - hub release create "${assets[@]}" -m "$tag_name" "$tag_name" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + strategy: + # Allow tests to continue on other devices if they fail on one device. + fail-fast: false + matrix: + include: + - api-level: 29 + target: default + - api-level: 28 + target: default + - api-level: 26 + target: default + - api-level: 24 + target: default + - api-level: 22 + target: default + + steps: + - uses: actions/checkout@v2 + + - name: set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Set up Android SDK License + run: (while sleep 3; do echo "y"; done) | /Users/runner/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager --licenses + + - name: Build tests + run: ./gradlew assembleAndroidTest + + - name: Run tests + uses: reactivecircus/android-emulator-runner@v2 + timeout-minutes: 40 + with: + api-level: ${{ matrix.api-level }} + profile: 4in WVGA (Nexus S) + target: ${{ matrix.target }} + script: | + adb logcat > logcat.txt & + ./gradlew connectedCheck + + - name: Upload logs + if: always() + uses: actions/upload-artifact@v2 + with: + name: logs-${{ matrix.api-level }}-${{ matrix.target }} + path: logcat.txt + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v2 + with: + name: test-results-${{ matrix.api-level }}-${{ matrix.target }} + path: "**/build/outputs/**/connected/**/*.xml" + + release : + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + needs: [build, unit-test, connected-test] + timeout-minutes: 30 + + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Set up Android SDK License + run: yes | /usr/local/lib/android/sdk/tools/bin/sdkmanager --licenses + + - name: Apply Signing + env: + ALIAS: ${{ secrets.ALIAS }} + KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} + KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }} + run: ./.github/apply_signing.sh + + - name: Build with Gradle + run: ./gradlew assembleRelease bundleRelease + + - name: Check if is prelease + if: startsWith(github.ref, 'refs/tags/') + id: check-tag + run: | + if [[ ${{ github.event.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+\-(dev|beta)[0-9]+$ ]]; then + echo ::set-output name=prelease::true + fi + + - name: Create Prerelease + if: steps.check-tag.outputs.prelease == 'true' + run: | + set -x + assets=() + for asset in $(find -name *-release.apk); do + assets+=("-a" "$asset") + done + for asset in $(find -name *-release.aab); do + assets+=("-a" "$asset") + done + tag_name="${GITHUB_REF##*/}" + hub release create "${assets[@]}" -m "$tag_name" "$tag_name" -p + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Release + if: steps.check-tag.outputs.prelease != 'true' + run: | + set -x + assets=() + for asset in $(find -name *-release.apk); do + assets+=("-a" "$asset") + done + for asset in $(find -name *-release.aab); do + assets+=("-a" "$asset") + done + tag_name="${GITHUB_REF##*/}" + hub release create "${assets[@]}" -m "$tag_name" "$tag_name" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index cbe742a26..2f86a1776 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -3,7 +3,7 @@