Set up CI for the new integration tests #166
This file contains hidden or 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: CI | |
| on: [push, pull_request] | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 21 | |
| distribution: adopt-hotspot | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Build debug APK | |
| run: ./gradlew assembleDebug | |
| - name: Build release APK | |
| run: ./gradlew assembleRelease | |
| - name: Build release AAB | |
| run: ./gradlew bundleRelease | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: debug-app.apk | |
| path: app/build/outputs/apk/debug/app-debug.apk | |
| if-no-files-found: error | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: unsigned-app.apk | |
| path: app/build/outputs/apk/release/app-release-unsigned.apk | |
| if-no-files-found: error | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: unsigned-app.aab | |
| path: app/build/outputs/bundle/release/app-release.aab | |
| if-no-files-found: error | |
| integration-test: | |
| name: Integration Tests (API ${{ matrix.api-level }}) | |
| needs: build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| api-level: [30, 33] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| cache-dependency-path: integration-tests/package-lock.json | |
| - name: Install test dependencies | |
| run: npm ci | |
| working-directory: integration-tests | |
| - name: Download debug APK | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: debug-app.apk | |
| path: app/build/outputs/apk/debug | |
| - 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: AVD cache | |
| uses: actions/cache@v4 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: avd-${{ matrix.api-level }} | |
| - name: Create AVD and cache snapshot | |
| if: steps.avd-cache.outputs.cache-hit != 'true' | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| target: google_apis | |
| arch: x86_64 | |
| profile: pixel_5 | |
| ram-size: 2048M | |
| heap-size: 512M | |
| disk-size: 4096M | |
| force-avd-creation: false | |
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| script: echo "AVD snapshot created for caching" | |
| - name: Run integration tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| target: google_apis | |
| arch: x86_64 | |
| profile: pixel_5 | |
| ram-size: 2048M | |
| heap-size: 512M | |
| disk-size: 4096M | |
| 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: cd integration-tests && ./setup.sh && npm test | |
| - name: Upload test screenshots on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-screenshots-api-${{ matrix.api-level }} | |
| path: integration-tests/screenshots/ | |
| if-no-files-found: ignore | |
| deploy: | |
| name: Deploy to GitHub Releases & Google Play | |
| needs: build | |
| runs-on: ubuntu-22.04 | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| environment: production | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Get the APK | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: unsigned-app.apk | |
| path: . | |
| - name: Get the AAB | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: unsigned-app.aab | |
| path: . | |
| - name: Detect latest build tool version | |
| shell: bash | |
| run: | | |
| BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) | |
| echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | |
| echo Latest build tool version is: $BUILD_TOOL_VERSION | |
| - name: Sign the APK & AAB | |
| uses: r0adkll/sign-android-release@349ebdef58775b1e0d8099458af0816dc79b6407 | |
| id: sign_app | |
| with: | |
| releaseDirectory: . | |
| signingKeyBase64: ${{ secrets.ANDROID_SIGNING_JKS_BASE64 }} | |
| alias: ${{ vars.SIGNING_KEY_ALIAS }} | |
| keyStorePassword: ${{ secrets.SIGNING_KEY_STORE_PASSWORD }} | |
| keyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }} | |
| env: | |
| BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }} | |
| - name: List release files | |
| run: ls -l | |
| - name: Rename release files | |
| run: | | |
| mv ./app-release-unsigned-signed.apk ./httptoolkit.apk | |
| mv ./app-release.aab ./httptoolkit.aab | |
| - name: Publish the APK & AAB to GitHub Releases | |
| uses: svenstaro/upload-release-action@6b7fa9f267e90b50a19fef07b3596790bb941741 | |
| with: | |
| prerelease: true | |
| file: ./httptoolkit{.apk,.aab} | |
| file_glob: true | |
| tag: ${{ github.ref }} | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish the AAB to Google Play | |
| uses: r0adkll/upload-google-play@935ef9c68bb393a8e6116b1575626a7f5be3a7fb | |
| with: | |
| serviceAccountJsonPlainText: ${{ secrets.PLAY_SERVICE_ACCOUNT_JSON }} | |
| packageName: tech.httptoolkit.android.v1 | |
| releaseFiles: ./httptoolkit.aab | |
| track: production |