2022-01-15 17:22:15 +01:00
name : Checks
on :
pull_request :
2024-03-04 22:17:44 +01:00
types : [ opened, synchronize, reopened ]
2022-01-15 17:22:15 +01:00
push :
2024-03-04 22:17:44 +01:00
branches : [ master, develop ]
2022-01-15 17:22:15 +01:00
jobs :
wrapper-validation :
name : "Gradle Wrapper Validation"
runs-on : ubuntu-latest
2022-04-02 11:54:46 +02:00
timeout-minutes : 45
2022-01-15 17:22:15 +01:00
steps :
2024-02-24 15:05:15 +01:00
- uses : actions/checkout@v4
- uses : gradle/wrapper-validation-action@v2
2022-01-15 17:22:15 +01:00
static-analysis :
name : "Static Code Analysis"
runs-on : ubuntu-latest
2022-04-02 11:54:46 +02:00
timeout-minutes : 45
2022-01-15 17:22:15 +01:00
steps :
2024-02-24 15:05:15 +01:00
- uses : actions/checkout@v4
2024-04-07 23:28:14 +02:00
with :
fetch-depth : 0
2024-03-04 22:17:44 +01:00
- name : Set up JDK 17
uses : actions/setup-java@v4
with :
distribution : 'temurin'
java-version : '17'
2022-01-15 17:22:15 +01:00
- name : Cache Gradle
2024-02-24 15:05:15 +01:00
uses : actions/cache@v4
2022-01-15 17:22:15 +01:00
with :
path : |
~/.gradle/caches
~/.gradle/wrapper
key : gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
2024-04-07 23:28:14 +02:00
- name : Configure parallel build
run : echo "org.gradle.parallel=true" >> local.properties
- name : XML code style
run : |
curl -s -L https://github.com/ByteHamster/android-xml-formatter/releases/download/1.1.0/android-xml-formatter.jar > android-xml-formatter.jar
find . -wholename "*/res/layout/*.xml" | xargs java -jar android-xml-formatter.jar
test $(git diff | wc -l) -eq 0 || (echo -e "\n\n===== Found XML code style violations! See output below how to fix them. =====\n\n" && git --no-pager diff --color=always && false)
- name : Checkstyle, Lint, SpotBugs
run : ./gradlew checkstyle :app:lintPlayDebug spotbugsPlayDebug spotbugsDebug
- name : Generate readable error messages for GitHub
if : failure()
run : |
git diff --name-only | xargs -I '{}' echo "::error file={},line=1,endLine=1,title=XML Format::Run android-xml-formatter.jar on this file or view CI output to see how it should be formatted."
python .github/workflows/errorPrinter.py
2022-01-15 17:22:15 +01:00
unit-test :
name : "Unit Test: ${{ matrix.variant }}"
2024-04-07 23:28:14 +02:00
needs : static-analysis
2022-01-15 17:22:15 +01:00
runs-on : ubuntu-latest
2022-04-02 11:54:46 +02:00
timeout-minutes : 45
2022-01-15 17:22:15 +01:00
strategy :
matrix :
include :
- variant : "PlayDebug"
2022-01-22 16:12:49 +01:00
base-variant : "Debug"
2022-01-15 17:22:15 +01:00
execute-tests : true
upload-artifact : true
- variant : "PlayRelease"
2022-01-22 16:12:49 +01:00
base-variant : "Release"
2022-01-15 17:22:15 +01:00
execute-tests : true
upload-artifact : false
- variant : "FreeRelease"
2022-01-22 16:12:49 +01:00
base-variant : "Release"
2022-01-15 17:22:15 +01:00
execute-tests : false
upload-artifact : false
steps :
2024-02-24 15:05:15 +01:00
- uses : actions/checkout@v4
2024-03-04 22:17:44 +01:00
- name : Set up JDK 17
uses : actions/setup-java@v4
with :
distribution : 'temurin'
java-version : '17'
2022-01-15 17:22:15 +01:00
- name : Cache Gradle
2024-02-24 15:05:15 +01:00
uses : actions/cache@v4
2022-01-15 17:22:15 +01:00
with :
path : |
~/.gradle/caches
~/.gradle/wrapper
key : gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
2024-04-07 23:28:14 +02:00
- name : Configure parallel build
run : echo "org.gradle.parallel=true" >> local.properties
2022-01-15 17:22:15 +01:00
- name : Create temporary release keystore
run : keytool -noprompt -genkey -v -keystore "app/keystore" -alias alias -storepass password -keypass password -keyalg RSA -validity 10 -dname "CN=antennapod.org, OU=dummy, O=dummy, L=dummy, S=dummy, C=US"
- name : Build
run : ./gradlew assemble${{ matrix.variant }}
- name : Test
if : matrix.execute-tests == true
2022-01-22 16:12:49 +01:00
run : ./gradlew test${{ matrix.variant }}UnitTest test${{ matrix.base-variant }}UnitTest
2024-02-24 15:05:15 +01:00
- uses : actions/upload-artifact@v4
2022-01-15 17:22:15 +01:00
if : matrix.upload-artifact == true
with :
name : app-play-debug.apk
path : app/build/outputs/apk/play/debug/app-play-debug.apk
emulator-test :
name : "Emulator Test"
2024-04-07 23:28:14 +02:00
needs : static-analysis
2022-01-15 17:22:15 +01:00
runs-on : macOS-latest
2022-04-02 11:54:46 +02:00
timeout-minutes : 45
2022-01-15 17:22:15 +01:00
env :
2022-08-21 17:31:57 +02:00
api-level : 30
2022-01-15 17:22:15 +01:00
steps :
2024-02-24 15:05:15 +01:00
- uses : actions/checkout@v4
2024-03-04 22:17:44 +01:00
- name : Set up JDK 17
2024-02-24 15:05:15 +01:00
uses : actions/setup-java@v4
2022-01-15 17:22:15 +01:00
with :
2022-07-20 22:29:58 +02:00
distribution : 'temurin'
2024-03-04 22:17:44 +01:00
java-version : '17'
2022-01-15 17:22:15 +01:00
- name : Cache Gradle
2024-02-24 15:05:15 +01:00
uses : actions/cache@v4
2022-01-15 17:22:15 +01:00
with :
path : |
~/.gradle/caches
~/.gradle/wrapper
key : gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
2024-04-07 23:28:14 +02:00
- name : Configure parallel build
run : echo "org.gradle.parallel=true" >> local.properties
2022-08-21 17:31:57 +02:00
- name : Build with Gradle
run : ./gradlew assemblePlayDebugAndroidTest
2022-01-15 17:22:15 +01:00
- name : Android Emulator test
uses : reactivecircus/android-emulator-runner@v2
with :
api-level : ${{ env.api-level }}
2022-08-21 17:31:57 +02:00
target : aosp_atd
channel : canary
2022-01-15 17:22:15 +01:00
force-avd-creation : false
emulator-options : -no -snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations : true
script : zsh .github/workflows/runEmulatorTests.sh
2024-02-24 15:05:15 +01:00
- uses : actions/upload-artifact@v4
2022-01-15 17:22:15 +01:00
if : failure()
with :
name : test-report
path : app/build/reports/androidTests/connected/flavors/PLAY/