diff options
author | ByteHamster <info@bytehamster.com> | 2022-01-15 17:22:15 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-01-15 21:05:23 +0100 |
commit | 876042038f52c8e0e74950e3cb4f03f660375752 (patch) | |
tree | 96191cfaee25cca0ffc79f3319ea4142d1f7d790 | |
parent | ba17dd53f855ad55b2152325598a9e4adf9e9e28 (diff) | |
download | AntennaPod-876042038f52c8e0e74950e3cb4f03f660375752.zip |
Run tests on GitHub Actions instead of CircleCI
-rw-r--r-- | .circleci/config.yml | 110 | ||||
-rw-r--r-- | .github/workflows/android-emulator.yml | 31 | ||||
-rw-r--r-- | .github/workflows/checks.yml | 156 | ||||
-rw-r--r-- | .github/workflows/runEmulatorTests.sh (renamed from .github/workflows/runTests.sh) | 0 |
4 files changed, 156 insertions, 141 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 157ec29b8..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,110 +0,0 @@ -version: 2.1 - -jobs: - build: - parameters: - build-steps: - description: "Steps that will be executed for this build" - type: steps - default: [] - docker: - - image: circleci/android:api-30 - working_directory: ~/AntennaPod - environment: - GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx1536m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError"' - _JAVA_OPTIONS: "-Xms256m -Xmx1280m" - steps: - - checkout - - restore_cache: - keys: - - v1-android-{{ checksum "build.gradle" }} - - v1-android- - - run: - name: Create temporary release keystore - command: 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" - - steps: << parameters.build-steps >> - - save_cache: - paths: - - ~/.android - - ~/.gradle - - ~/android - key: v1-android-{{ checksum "build.gradle" }} - -workflows: - unit-tests: - jobs: - - build: - name: Build debug - build-steps: - - run: - name: Build debug - command: ./gradlew assembleDebug -PdisablePreDex - - store_artifacts: - name: Uploading apk artifact - path: app/build/outputs/apk/play/debug/app-play-debug.apk - destination: app-play-debug.apk - - run: - name: Execute debug unit tests - command: ./gradlew testPlayDebugUnitTest -PdisablePreDex - - build: - name: Build release - build-steps: - - run: - name: Build release - command: ./gradlew assembleRelease -PdisablePreDex - - run: - name: Execute release unit tests - command: ./gradlew testPlayReleaseUnitTest -PdisablePreDex - - build: - name: Build integration tests - build-steps: - - run: - name: Build integration tests - command: ./gradlew assemblePlayDebugAndroidTest -PdisablePreDex - - build: - name: Build free - build-steps: - - run: - name: Build free (for F-Droid) - command: ./gradlew assembleFreeRelease -PdisablePreDex - - static-analysis: - jobs: - - build: - name: Checkstyle - build-steps: - - run: - name: Checkstyle - command: ./gradlew checkstyle - - run: - name: Diff-Checkstyle - command: | - git fetch origin develop - branchBaseCommit=`git merge-base origin/develop HEAD` - echo "Comparing to $branchBaseCommit" - 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 $branchBaseCommit - - build: - name: Lint - build-steps: - - run: - name: Lint - command: ./gradlew lintPlayRelease lintRelease - - build: - name: SpotBugs - build-steps: - - run: - name: SpotBugs - command: ./gradlew spotbugsPlayDebug spotbugsDebug 2>&1 | grep -i "spotbugs" - - build: - name: XML - build-steps: - - run: - name: XML of changed files - command: | - git fetch origin develop - branchBaseCommit=`git merge-base origin/develop HEAD` - echo "Comparing to $branchBaseCommit" - 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 $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) diff --git a/.github/workflows/android-emulator.yml b/.github/workflows/android-emulator.yml deleted file mode 100644 index c8e66e14f..000000000 --- a/.github/workflows/android-emulator.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Android Emulator test - -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - build: - runs-on: macOS-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - distribution: 'adopt' - java-version: '11' - - name: Wrapper validation - uses: gradle/wrapper-validation-action@v1 - - name: Build with Gradle - run: ./gradlew assemblePlayDebugAndroidTest - - name: Android Emulator test - uses: ReactiveCircus/android-emulator-runner@v2 - with: - api-level: 27 - disable-animations: true - script: zsh .github/workflows/runTests.sh - - uses: actions/upload-artifact@v2 - if: failure() - with: - name: test-report - path: app/build/reports/androidTests/connected/flavors/PLAY/ diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 000000000..d55817141 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,156 @@ +name: Checks + +on: + pull_request: + types: [opened, synchronize, reopened] + push: + branches: [master, develop] + +jobs: + code-style: + name: "Code Style" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Cache Gradle + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} + - name: Checkstyle + run: ./gradlew checkstyle + - 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 + steps: + - uses: actions/checkout@v2 + - uses: gradle/wrapper-validation-action@v1 + + static-analysis: + name: "Static Code Analysis" + needs: code-style + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Cache Gradle + uses: actions/cache@v2 + 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 + strategy: + matrix: + include: + - variant: "PlayDebug" + execute-tests: true + upload-artifact: true + - variant: "PlayRelease" + execute-tests: true + upload-artifact: false + - variant: "FreeRelease" + execute-tests: false + upload-artifact: false + steps: + - uses: actions/checkout@v2 + - name: Cache Gradle + uses: actions/cache@v2 + 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 + run: ./gradlew test${{ matrix.variant }}UnitTest + - uses: actions/upload-artifact@v2 + 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 + env: + api-level: 27 + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' + - name: Build with Gradle + run: ./gradlew assemblePlayDebugAndroidTest + - name: Cache Gradle + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} + - name: Cache AVD + uses: actions/cache@v2 + 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 + - uses: actions/upload-artifact@v2 + if: failure() + with: + name: test-report + path: app/build/reports/androidTests/connected/flavors/PLAY/ diff --git a/.github/workflows/runTests.sh b/.github/workflows/runEmulatorTests.sh index ee7a42e0a..ee7a42e0a 100644 --- a/.github/workflows/runTests.sh +++ b/.github/workflows/runEmulatorTests.sh |