Start using flavours #4639
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android CI | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- staging | |
- trying | |
pull_request: | |
branches: | |
- main | |
permissions: | |
actions: none | |
checks: none | |
contents: read | |
deployments: none | |
discussions: none | |
id-token: none | |
issues: none | |
packages: none | |
pages: none | |
pull-requests: none | |
repository-projects: none | |
security-events: none | |
statuses: none | |
env: | |
JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Get source code | |
- uses: actions/[email protected] | |
# 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 assembleDebug | |
# Upload build | |
- name: Upload build | |
uses: actions/[email protected] | |
with: | |
name: Build | |
path: app/build/outputs/apk/ | |
# Upload gradle state | |
- name: Upload gradle state | |
uses: actions/[email protected] | |
with: | |
name: Gradle | |
path: .gradle | |
check-translations: | |
runs-on: ubuntu-latest | |
steps: | |
# Get source code | |
- uses: actions/[email protected] | |
# 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/[email protected] | |
# Get built APKs | |
- name: Download build | |
uses: actions/[email protected] | |
with: | |
name: Build | |
path: app/build/outputs/apk/ | |
# Get Gradle state | |
- name: Download gradle state | |
uses: actions/[email protected] | |
with: | |
name: Gradle | |
path: .gradle | |
# 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 | |
# 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/[email protected] | |
# Get built APKs | |
- name: Download build | |
uses: actions/[email protected] | |
with: | |
name: Build | |
path: app/build/outputs/apk/ | |
# Get Gradle state | |
- name: Download gradle state | |
uses: actions/[email protected] | |
with: | |
name: Gradle | |
path: .gradle | |
# 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 }}Debug | |
spotbugs: | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
flavor: [Foss, Gplay] | |
steps: | |
# Get source code | |
- uses: actions/[email protected] | |
# Get built APKs | |
- name: Download build | |
uses: actions/[email protected] | |
with: | |
name: Build | |
path: app/build/outputs/apk/ | |
# Get Gradle state | |
- name: Download gradle state | |
uses: actions/[email protected] | |
with: | |
name: Gradle | |
path: .gradle | |
# 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 }}Debug | |
unit-tests: | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
flavor: [Foss, Gplay] | |
steps: | |
# Get source code | |
- uses: actions/[email protected] | |
# Get built APKs | |
- name: Download build | |
uses: actions/[email protected] | |
with: | |
name: Build | |
path: app/build/outputs/apk/ | |
# Get Gradle state | |
- name: Download gradle state | |
uses: actions/[email protected] | |
with: | |
name: Gradle | |
path: .gradle | |
# 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 }}DebugUnitTest || { ./gradlew --stop && timeout 5m ./gradlew test${{ matrix.flavor }}DebugUnitTest; } |