name: Android CI

on:
  push:
    branches:
      - master
      - staging
      - trying
  pull_request:
    branches:
      - master

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Fail on bad translations
      run: if grep -ri "&lt;xliff" app/src/main/res/values*/strings.xml; then echo "Invalidly escaped translations found"; exit 1; fi
    - uses: gradle/wrapper-validation-action@v1
    - name: set up JDK 11
      uses: actions/setup-java@v2
      with:
        distribution: 'adopt'
        java-version: '11'
    - name: Build
      run: ./gradlew assembleRelease
    - name: Check lint
      run: ./gradlew lintRelease
    - name: Run unit tests
      run: ./gradlew testReleaseUnitTest || ./gradlew testReleaseUnitTest
    - name: SpotBugs
      run: ./gradlew spotbugsRelease
    - name: Archive test results
      if: always()
      uses: actions/upload-artifact@v2
      with:
        name: test-results
        path: app/build/reports
