2022-01-15 17:22:15 +01:00
|
|
|
name: Checks
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
types: [opened, synchronize, reopened]
|
|
|
|
push:
|
|
|
|
branches: [master, develop]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
code-style:
|
|
|
|
name: "Code Style"
|
|
|
|
runs-on: ubuntu-latest
|
2022-04-02 11:54:46 +02:00
|
|
|
timeout-minutes: 45
|
2022-01-15 17:22:15 +01:00
|
|
|
steps:
|
2022-04-14 21:36:42 +02:00
|
|
|
- uses: actions/checkout@v3
|
2022-01-15 17:22:15 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
- name: Checkstyle
|
2022-01-06 12:19:55 +01:00
|
|
|
run: |
|
|
|
|
curl -s -L https://github.com/checkstyle/checkstyle/releases/download/checkstyle-9.2.1/checkstyle-9.2.1-all.jar > checkstyle.jar
|
|
|
|
find . -name "*\.java" | xargs java -Dconfig_loc=config/checkstyle -jar checkstyle.jar -c config/checkstyle/checkstyle.xml
|
2022-01-15 17:22:15 +01:00
|
|
|
- name: Find PR Base Commit
|
|
|
|
id: vars
|
|
|
|
run: |
|
|
|
|
git fetch origin develop
|
|
|
|
echo "::set-output name=branchBaseCommit::$(git merge-base origin/develop HEAD)"
|
|
|
|
- name: Diff-Checkstyle
|
|
|
|
run: |
|
|
|
|
curl -s -L https://github.com/yangziwen/diff-checkstyle/releases/download/0.0.4/diff-checkstyle.jar > diff-checkstyle.jar
|
|
|
|
java -Dconfig_loc=config/checkstyle -jar diff-checkstyle.jar -c config/checkstyle/checkstyle-new-code.xml --git-dir . --base-rev ${{ steps.vars.outputs.branchBaseCommit }}
|
|
|
|
- name: XML of changed files
|
|
|
|
run: |
|
|
|
|
curl -s -L https://github.com/ByteHamster/android-xml-formatter/releases/download/1.1.0/android-xml-formatter.jar > android-xml-formatter.jar
|
|
|
|
git diff --name-only ${{ steps.vars.outputs.branchBaseCommit }} --diff-filter=AM | { grep "res/layout/" || true; } | 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)
|
|
|
|
|
|
|
|
wrapper-validation:
|
|
|
|
name: "Gradle Wrapper Validation"
|
|
|
|
needs: code-style
|
|
|
|
runs-on: ubuntu-latest
|
2022-04-02 11:54:46 +02:00
|
|
|
timeout-minutes: 45
|
2022-01-15 17:22:15 +01:00
|
|
|
steps:
|
2022-04-14 21:36:42 +02:00
|
|
|
- uses: actions/checkout@v3
|
2022-01-15 17:22:15 +01:00
|
|
|
- uses: gradle/wrapper-validation-action@v1
|
|
|
|
|
|
|
|
static-analysis:
|
|
|
|
name: "Static Code Analysis"
|
|
|
|
needs: code-style
|
|
|
|
runs-on: ubuntu-latest
|
2022-04-02 11:54:46 +02:00
|
|
|
timeout-minutes: 45
|
2022-01-15 17:22:15 +01:00
|
|
|
steps:
|
2022-04-14 21:36:42 +02:00
|
|
|
- uses: actions/checkout@v3
|
2022-01-15 17:22:15 +01:00
|
|
|
- name: Cache Gradle
|
2022-04-14 21:36:42 +02:00
|
|
|
uses: actions/cache@v3
|
2022-01-15 17:22:15 +01:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.gradle/caches
|
|
|
|
~/.gradle/wrapper
|
|
|
|
key: gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
|
|
|
- name: Lint
|
|
|
|
run: ./gradlew lintPlayRelease lintRelease
|
|
|
|
- name: SpotBugs
|
|
|
|
run: ./gradlew spotbugsPlayDebug spotbugsDebug 2>&1 | grep -i "spotbugs"
|
|
|
|
|
|
|
|
unit-test:
|
|
|
|
name: "Unit Test: ${{ matrix.variant }}"
|
|
|
|
needs: code-style
|
|
|
|
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:
|
2022-04-14 21:36:42 +02:00
|
|
|
- uses: actions/checkout@v3
|
2022-01-15 17:22:15 +01:00
|
|
|
- name: Cache Gradle
|
2022-04-14 21:36:42 +02:00
|
|
|
uses: actions/cache@v3
|
2022-01-15 17:22:15 +01:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.gradle/caches
|
|
|
|
~/.gradle/wrapper
|
|
|
|
key: gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
|
|
|
- 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
|
2022-04-14 21:36:42 +02:00
|
|
|
- uses: actions/upload-artifact@v3
|
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"
|
|
|
|
needs: code-style
|
|
|
|
runs-on: macOS-latest
|
2022-04-02 11:54:46 +02:00
|
|
|
timeout-minutes: 45
|
2022-01-15 17:22:15 +01:00
|
|
|
env:
|
|
|
|
api-level: 27
|
|
|
|
steps:
|
2022-04-14 21:36:42 +02:00
|
|
|
- uses: actions/checkout@v3
|
2022-01-15 17:22:15 +01:00
|
|
|
- name: Set up JDK 11
|
2022-04-14 21:36:42 +02:00
|
|
|
uses: actions/setup-java@v3
|
2022-01-15 17:22:15 +01:00
|
|
|
with:
|
|
|
|
distribution: 'adopt'
|
|
|
|
java-version: '11'
|
|
|
|
- name: Build with Gradle
|
|
|
|
run: ./gradlew assemblePlayDebugAndroidTest
|
|
|
|
- name: Cache Gradle
|
2022-04-14 21:36:42 +02:00
|
|
|
uses: actions/cache@v3
|
2022-01-15 17:22:15 +01:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.gradle/caches
|
|
|
|
~/.gradle/wrapper
|
|
|
|
key: gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
|
|
|
- name: Cache AVD
|
2022-04-14 21:36:42 +02:00
|
|
|
uses: actions/cache@v3
|
2022-01-15 17:22:15 +01:00
|
|
|
id: avd-cache
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.android/avd/*
|
|
|
|
~/.android/adb*
|
|
|
|
key: avd-${{ env.api-level }}
|
|
|
|
- name: Create AVD and generate snapshot for caching
|
|
|
|
if: steps.avd-cache.outputs.cache-hit != 'true'
|
|
|
|
uses: reactivecircus/android-emulator-runner@v2
|
|
|
|
with:
|
|
|
|
api-level: ${{ env.api-level }}
|
|
|
|
force-avd-creation: false
|
|
|
|
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
|
|
|
disable-animations: false
|
|
|
|
script: echo "Generated AVD snapshot for caching."
|
|
|
|
- name: Android Emulator test
|
|
|
|
uses: reactivecircus/android-emulator-runner@v2
|
|
|
|
with:
|
|
|
|
api-level: ${{ env.api-level }}
|
|
|
|
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
|
2022-04-14 21:36:42 +02:00
|
|
|
- uses: actions/upload-artifact@v3
|
2022-01-15 17:22:15 +01:00
|
|
|
if: failure()
|
|
|
|
with:
|
|
|
|
name: test-report
|
|
|
|
path: app/build/reports/androidTests/connected/flavors/PLAY/
|