diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 02cc093b8..90ae78b07 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -2,13 +2,19 @@ name: E2E on: workflow_dispatch: + pull_request: env: TERM: xterm-256color FORCE_COLOR: 1 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: + if: github.event.pull_request.draft == false runs-on: ubuntu-latest steps: @@ -35,13 +41,19 @@ jobs: E2E: true run: ./gradlew assembleDevDebug + - name: Rename APK + run: | + apk=$(find app/build/outputs/apk/dev/debug -name 'bitkit-android-*-devDebug.apk') + mv "$apk" app/build/outputs/apk/dev/debug/bitkit_e2e.apk + - name: Upload APK uses: actions/upload-artifact@v4 with: - name: bitkit-e2e-apk - path: app/build/outputs/apk/dev/debug/bitkit-android-11-devDebug.apk + name: bitkit-e2e-apk_${{ github.run_number }} + path: app/build/outputs/apk/dev/debug/bitkit_e2e.apk e2e-tests: + if: github.event.pull_request.draft == false runs-on: ubuntu-latest needs: build @@ -52,14 +64,77 @@ jobs: repository: synonymdev/bitkit-e2e-tests path: bitkit-e2e-tests + - 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: Download APK uses: actions/download-artifact@v4 with: - name: bitkit-e2e-apk + name: bitkit-e2e-apk_${{ github.run_number }} path: bitkit-e2e-tests/aut - - name: Rename APK - run: mv bitkit-e2e-tests/aut/bitkit-android-11-devDebug.apk bitkit-e2e-tests/aut/bitkit_e2e.apk - - name: List APK directory contents run: ls -l bitkit-e2e-tests/aut + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Cache npm cache + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies + working-directory: bitkit-e2e-tests + run: npm ci + + - name: Run regtest setup + working-directory: bitkit-e2e-tests + run: | + cd docker + mkdir lnd && chmod 777 lnd + docker compose pull --quiet + docker compose up -d + + - name: Wait for electrum server and LND + working-directory: bitkit-e2e-tests + timeout-minutes: 10 + run: | + while ! nc -z '127.0.0.1' 60001; do sleep 1; done + sudo bash -c "while [ ! -f docker/lnd/data/chain/bitcoin/regtest/admin.macaroon ]; do sleep 1; done" + sudo chmod -R 777 docker/lnd + + - name: Run E2E Tests + uses: reactivecircus/android-emulator-runner@v2 + with: + profile: pixel_6 + api-level: 33 + arch: x86_64 + avd-name: Pixel_6 + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none + script: | + # adb port forwarding for regtest + adb reverse tcp:60001 tcp:60001 + cd bitkit-e2e-tests && npm run e2e:android -- --mochaOpts.grep "Can start onboarding" + env: + RECORD_VIDEO: true + + - name: Upload E2E Artifacts + if: failure() + uses: actions/upload-artifact@v4 + with: + name: e2e-artifacts_${{ github.run_number }} + path: bitkit-e2e-tests/artifacts/ + + - name: Dump docker logs on failure + if: failure() + uses: jwalton/gh-docker-logs@v2