|
| 1 | +name: Catroid Update Smoke Test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths-ignore: |
| 6 | + - "**/*.md" |
| 7 | + - "docs/**" |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - develop |
| 11 | + paths-ignore: |
| 12 | + - "**/*.md" |
| 13 | + - "docs/**" |
| 14 | + workflow_dispatch: |
| 15 | + inputs: |
| 16 | + BASE_REF: |
| 17 | + description: "Play Store baseline branch or commit to install before updating" |
| 18 | + required: false |
| 19 | + type: string |
| 20 | + default: "main" |
| 21 | + |
| 22 | +env: |
| 23 | + BASELINE_JAVA_VERSION: 17 |
| 24 | + PR_JAVA_VERSION: 21 |
| 25 | + PACKAGE_NAME: org.catrobat.catroid |
| 26 | + BASELINE_REF: ${{ github.event.inputs.BASE_REF || 'main' }} |
| 27 | + |
| 28 | +concurrency: |
| 29 | + group: update-smoke-${{ github.ref }} |
| 30 | + cancel-in-progress: true |
| 31 | + |
| 32 | +jobs: |
| 33 | + update-smoke: |
| 34 | + name: Update Smoke Test |
| 35 | + runs-on: ubuntu-latest |
| 36 | + timeout-minutes: 35 |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout PR |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + path: pr |
| 43 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 44 | + |
| 45 | + - name: Checkout baseline |
| 46 | + uses: actions/checkout@v4 |
| 47 | + with: |
| 48 | + path: baseline |
| 49 | + ref: ${{ env.BASELINE_REF }} |
| 50 | + |
| 51 | + - name: Resolve baseline commit |
| 52 | + id: baseline-ref |
| 53 | + working-directory: baseline |
| 54 | + run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
| 55 | + |
| 56 | + - name: Setup baseline JDK ${{ env.BASELINE_JAVA_VERSION }} |
| 57 | + uses: actions/setup-java@v4 |
| 58 | + with: |
| 59 | + distribution: "temurin" |
| 60 | + java-version: ${{ env.BASELINE_JAVA_VERSION }} |
| 61 | + cache: gradle |
| 62 | + |
| 63 | + - name: Setup Gradle |
| 64 | + uses: gradle/actions/setup-gradle@v4 |
| 65 | + |
| 66 | + - name: Restore baseline APK cache |
| 67 | + id: baseline-cache |
| 68 | + uses: actions/cache@v4 |
| 69 | + with: |
| 70 | + path: baseline-apk |
| 71 | + key: update-smoke-baseline-${{ steps.baseline-ref.outputs.sha }}-${{ hashFiles('baseline/**/*.gradle*', 'baseline/gradle/**') }} |
| 72 | + restore-keys: | |
| 73 | + update-smoke-baseline-${{ steps.baseline-ref.outputs.sha }}- |
| 74 | +
|
| 75 | + - name: Build baseline APK |
| 76 | + if: steps.baseline-cache.outputs.cache-hit != 'true' |
| 77 | + working-directory: baseline |
| 78 | + run: | |
| 79 | + ./gradlew :catroid:copyAndroidNatives :catroid:assembleCatroidRelease --stacktrace |
| 80 | +
|
| 81 | + mkdir -p ../baseline-apk |
| 82 | + baseline_apk="$(find catroid/build/outputs/apk/catroid/release -name '*.apk' -print -quit)" |
| 83 | + test -n "$baseline_apk" |
| 84 | + cp "$baseline_apk" ../baseline-apk/catroid-update-baseline.apk |
| 85 | + cp catroid/build/outputs/apk/catroid/release/output-metadata.json ../baseline-apk/output-metadata.json |
| 86 | +
|
| 87 | + - name: Resolve PR version code |
| 88 | + id: pr-version |
| 89 | + run: | |
| 90 | + baseline_version_code="$(python3 -c 'import json; print(json.load(open("baseline-apk/output-metadata.json", encoding="utf-8"))["elements"][0]["versionCode"])')" |
| 91 | + echo "version-code=$((baseline_version_code + 1))" >> "$GITHUB_OUTPUT" |
| 92 | +
|
| 93 | + - name: Setup PR JDK ${{ env.PR_JAVA_VERSION }} |
| 94 | + uses: actions/setup-java@v4 |
| 95 | + with: |
| 96 | + distribution: "temurin" |
| 97 | + java-version: ${{ env.PR_JAVA_VERSION }} |
| 98 | + |
| 99 | + - name: Build PR APK |
| 100 | + working-directory: pr |
| 101 | + run: | |
| 102 | + ./gradlew :catroid:copyAndroidNatives :catroid:assembleCatroidUpdateTest \ |
| 103 | + -PversionCodeOverride=${{ steps.pr-version.outputs.version-code }} \ |
| 104 | + --stacktrace |
| 105 | +
|
| 106 | + pr_apk="$(find catroid/build/outputs/apk/catroid/updateTest -name '*.apk' -print -quit)" |
| 107 | + test -n "$pr_apk" |
| 108 | + echo "$pr_apk" > ../pr-apk-path.txt |
| 109 | +
|
| 110 | + - name: Enable KVM |
| 111 | + run: | |
| 112 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 113 | + sudo udevadm control --reload-rules |
| 114 | + sudo udevadm trigger --name-match=kvm |
| 115 | +
|
| 116 | + - name: Run update smoke test |
| 117 | + uses: reactivecircus/android-emulator-runner@v2 |
| 118 | + with: |
| 119 | + api-level: 35 |
| 120 | + arch: x86_64 |
| 121 | + force-avd-creation: true |
| 122 | + emulator-boot-timeout: 900 |
| 123 | + emulator-options: > |
| 124 | + -no-window |
| 125 | + -no-boot-anim |
| 126 | + script: | |
| 127 | + bash pr/automationScripts/update-smoke/run-update-smoke.sh "$(pwd)/baseline-apk/catroid-update-baseline.apk" "$(pwd)/pr/$(cat pr-apk-path.txt)" "${{ env.PACKAGE_NAME }}" |
| 128 | +
|
| 129 | + - name: Upload update smoke artifacts |
| 130 | + uses: actions/upload-artifact@v4 |
| 131 | + if: always() |
| 132 | + with: |
| 133 | + name: update-smoke-artifacts |
| 134 | + path: pr/build/update-smoke/** |
0 commit comments