From fa5fa5f738e707644e1b41ee83b389ad385c2c79 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Thu, 19 Dec 2024 22:01:10 +0100 Subject: [PATCH] Test --- .github/workflows/android.yml | 164 +++++++++++++++++++++++++--------- 1 file changed, 123 insertions(+), 41 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 5b90a2b6a..71832d0c1 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -28,47 +28,129 @@ env: jobs: build: runs-on: ubuntu-latest + steps: + # Get source code + - uses: actions/checkout@v4.2.2 + # Set up Java + - name: set up OpenJDK 17 + run: | + sudo apt-get update + sudo apt-get install -y openjdk-17-jdk-headless + sudo update-alternatives --auto java + # Build the app + - name: Build + run: ./gradlew assembleRelease + # Upload build + - name: Upload build + uses: actions/upload-artifact@v4.4.3 + with: + name: Build + path: app/build/outputs/apk/ + check-translations: + runs-on: ubuntu-latest + steps: + # Get source code + - uses: actions/checkout@v4.2.2 + # Check translations + - name: Fail on bad translations + run: if grep -ri "<xliff" app/src/main/res/values*/strings.xml; then echo "Invalidly escaped translations found"; exit 1; fi + instrumented-tests: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + api-level: [21, 34] + flavor: [Foss, Gplay] + steps: + # Get source code + - uses: actions/checkout@v4.2.2 + # Get built APKs + - name: Download artifacts + uses: actions/download-artifact@v4.1.8 + with: + name: Build + path: app/build/outputs/apk/ + # Instrumented tests + - name: Enable KVM + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + - name: Run instrumented tests + uses: ReactiveCircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + arch: x86_64 + script: ./gradlew connected${{ matrix.flavor }}DebugAndroidTest + lint: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + flavor: [Foss, Gplay] + steps: + # Get source code + - uses: actions/checkout@v4.2.2 + # Get built APKs + - name: Download artifacts + uses: actions/download-artifact@v4.1.8 + with: + name: Build + path: app/build/outputs/apk/ + # Set up Java + - name: set up OpenJDK 17 + run: | + sudo apt-get update + sudo apt-get install -y openjdk-17-jdk-headless + sudo update-alternatives --auto java + # Lint + - name: Check lint + run: ./gradlew lint${{ matrix.flavor }}Release + spotbugs: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + flavor: [Foss, Gplay] + steps: + # Get source code + - uses: actions/checkout@v4.2.2 + # Get built APKs + - name: Download artifacts + uses: actions/download-artifact@v4.1.8 + with: + name: Build + path: app/build/outputs/apk/ + # Set up Java + - name: set up OpenJDK 17 + run: | + sudo apt-get update + sudo apt-get install -y openjdk-17-jdk-headless + sudo update-alternatives --auto java + # Spotbugs + - name: SpotBugs + run: ./gradlew spotbugs${{ matrix.flavor }}Release + unit-tests: + runs-on: ubuntu-latest + needs: build strategy: matrix: - api-level: [ 21, 34 ] + flavor: [Foss, Gplay] steps: - - uses: actions/checkout@v4.2.2 - - name: Fail on bad translations - run: if grep -ri "<xliff" app/src/main/res/values*/strings.xml; then echo "Invalidly escaped translations found"; exit 1; fi - - uses: gradle/actions/wrapper-validation@v4 - - name: set up OpenJDK 17 - run: | - sudo apt-get update - sudo apt-get install -y openjdk-17-jdk-headless - sudo update-alternatives --auto java - - name: Build - run: ./gradlew assembleRelease - - name: Check lint (foss flavour) - run: ./gradlew lintFossRelease - - name: Check lint (gplay flavour) - run: ./gradlew lintGplayRelease - - name: Run unit tests (foss flavour) - run: timeout 5m ./gradlew testFossReleaseUnitTest || { ./gradlew --stop && timeout 5m ./gradlew testFossReleaseUnitTest; } - - name: Run unit tests (gplay flavour) - run: timeout 5m ./gradlew testGplayReleaseUnitTest || { ./gradlew --stop && timeout 5m ./gradlew testGplayReleaseUnitTest; } - - name: Enable KVM - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - - name: Run instrumented tests - uses: ReactiveCircus/android-emulator-runner@v2 - with: - api-level: ${{ matrix.api-level }} - arch: x86_64 - script: ./gradlew connectedCheck - - name: SpotBugs (foss flavour) - run: ./gradlew spotbugsFossRelease - - name: SpotBugs (gplay flavour) - run: ./gradlew spotbugsGplayRelease - - name: Archive test results - if: always() - uses: actions/upload-artifact@v4.4.3 - with: - name: test-results-api${{ matrix.api-level }} - path: app/build/reports + # Get source code + - uses: actions/checkout@v4.2.2 + # Get built APKs + - name: Download artifacts + uses: actions/download-artifact@v4.1.8 + with: + name: Build + path: app/build/outputs/apk/ + # Set up Java + - name: set up OpenJDK 17 + run: | + sudo apt-get update + sudo apt-get install -y openjdk-17-jdk-headless + sudo update-alternatives --auto java + # Unit test + - name: Run unit tests + run: timeout 5m ./gradlew test${{ matrix.flavor }}ReleaseUnitTest || { ./gradlew --stop && timeout 5m ./gradlew test${{ matrix.flavor }}ReleaseUnitTest; }