fixing issues with AVD cache #569
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: "End-to-end test" | |
| on: | |
| push: | |
| workflow_dispatch: | |
| inputs: | |
| build_number: | |
| description: 'Build number e.g v1.7.0 build-904' | |
| required: false | |
| default: 'v1.7.0 build-904' | |
| # Auto cancels previous running CI jobs in this PR on each new commit | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| start-test: | |
| runs-on: ubuntu-latest | |
| name: "Start Test" | |
| steps: | |
| - 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 | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| # setup nodejs | |
| - name: Install Node.js | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: '22' | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v5.1.0 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Determine build number and directory name | |
| run: | | |
| # Check if build_number was provided via workflow_dispatch | |
| if [ -n "${{ github.event.inputs.build_number }}" ]; then | |
| BUILD_NUMBER="${{ github.event.inputs.build_number }}" | |
| echo "Using provided build number: $BUILD_NUMBER" | |
| else | |
| # Fetch the latest folder from S3 | |
| echo "No build number provided, fetching latest from S3..." | |
| LATEST_FOLDER=$(aws s3 ls s3://dock-wallet/app-truvera-distribution/ | grep PRE | awk '{print $2}' | sed 's/\///' | sort -V | tail -n 1) | |
| BUILD_NUMBER="$LATEST_FOLDER" | |
| echo "Using latest build from S3: $BUILD_NUMBER" | |
| fi | |
| # Format directory name (replace spaces with underscores) | |
| DIRECTORY_NAME=$(echo "$BUILD_NUMBER" | sed 's/ /_/g') | |
| echo "BUILD_NUMBER=$BUILD_NUMBER" >> "$GITHUB_ENV" | |
| echo "DIRECTORY_NAME=$DIRECTORY_NAME" >> "$GITHUB_ENV" | |
| - name: Download file from S3 | |
| run: | | |
| echo "Downloading APK from s3://dock-wallet/app-truvera-distribution/${{ env.DIRECTORY_NAME }}/dock-wallet.apk" | |
| aws s3 cp s3://dock-wallet/app-truvera-distribution/${{ env.DIRECTORY_NAME }}/dock-wallet.apk ./app/truvera-wallet.apk | |
| - name: Install Dependencies | |
| run: | | |
| npm install --force | |
| yarn global add appium | |
| appium driver install uiautomator2 | |
| - 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: Gradle cache | |
| uses: gradle/actions/setup-gradle@v3 | |
| - name: AVD cache | |
| uses: actions/cache@v4 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: avd-30 | |
| # - 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: 30 | |
| # arch: x86_64 | |
| # profile: pixel_7_pro | |
| # 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: Start Appium Server | |
| run: | | |
| appium &>/dev/null & | |
| APPIUM_PID=$! | |
| sleep 5 | |
| - name: Run E2E Tests | |
| # TODO: workaround to get faster reports | |
| # The emulator is not closing properly, so we need to timeout the job until we find a fix for that | |
| # will be testing fixes in the next iterations | |
| timeout-minutes: 8 | |
| uses: ReactiveCircus/android-emulator-runner@v2 | |
| with: | |
| api-level: 30 | |
| arch: x86_64 | |
| profile: pixel_7_pro | |
| force-avd-creation: false | |
| continue-on-error: true | |
| emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -memory 4096 | |
| disable-animations: true | |
| # emulator-options: -no-snapshot-save -no-snapshot-load -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim | |
| script: | | |
| adb install -g ./app/truvera-wallet.apk | |
| adb shell pm grant com.truvera.app android.permission.WRITE_EXTERNAL_STORAGE | |
| npm run test | |
| - name: Force Kill Emulator | |
| if: always() | |
| continue-on-error: true | |
| run: | | |
| pkill -9 qemu-system-x86_64 || true | |
| pkill -9 adb || true | |
| - name: Upload Test Reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-reports | |
| path: test-reports/ | |
| retention-days: 30 | |
| - name: Upload Screenshots | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: screenshots | |
| path: test-reports/screenshots/ | |
| retention-days: 30 | |
| - name: Upload CTRF Report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ctrf-report | |
| path: ctrf/ | |
| retention-days: 30 | |
| - name: Publish CTRF Test Summary | |
| if: always() | |
| run: | | |
| if [ -f "ctrf/ctrf-report.json" ]; then | |
| npx github-actions-ctrf ctrf/ctrf-report.json | |
| else | |
| echo "CTRF report not found at ctrf/ctrf-report.json" | |
| echo "Checking if reporter was installed..." | |
| npm list mocha-ctrf-json-reporter || echo "mocha-ctrf-json-reporter not installed" | |
| fi | |
| - name: Publish Test Results | |
| if: always() | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| with: | |
| files: test-reports/junit/results.xml | |
| check_name: E2E Test Results | |
| comment_title: E2E Test Results | |
| - name: Generate Test Summary | |
| if: always() | |
| run: | | |
| echo "## E2E Test Results Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ -f "test-reports/mochawesome/report.json" ]; then | |
| TOTAL=$(jq '.stats.tests' test-reports/mochawesome/report.json) | |
| PASSES=$(jq '.stats.passes' test-reports/mochawesome/report.json) | |
| FAILURES=$(jq '.stats.failures' test-reports/mochawesome/report.json) | |
| PENDING=$(jq '.stats.pending' test-reports/mochawesome/report.json) | |
| DURATION=$(jq '.stats.duration' test-reports/mochawesome/report.json) | |
| echo "📊 **Test Statistics**" >> $GITHUB_STEP_SUMMARY | |
| echo "- Total Tests: $TOTAL" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Passed: $PASSES" >> $GITHUB_STEP_SUMMARY | |
| echo "- ❌ Failed: $FAILURES" >> $GITHUB_STEP_SUMMARY | |
| echo "- ⏭️ Pending: $PENDING" >> $GITHUB_STEP_SUMMARY | |
| echo "- ⏱️ Duration: ${DURATION}ms" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # List failed tests if any | |
| if [ "$FAILURES" -gt 0 ]; then | |
| echo "### ❌ Failed Tests" >> $GITHUB_STEP_SUMMARY | |
| jq -r '.results[].suites[].tests[] | select(.fail == true) | "- " + .fullTitle' test-reports/mochawesome/report.json >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| else | |
| echo "⚠️ No test report found" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "📸 **Screenshots**" >> $GITHUB_STEP_SUMMARY | |
| echo "Screenshots are available in the artifacts section above." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "📄 **Full HTML Report**" >> $GITHUB_STEP_SUMMARY | |
| echo "Download the test-reports artifact to view the detailed HTML report." >> $GITHUB_STEP_SUMMARY | |
| # - name: Parse Test Report | |
| # if: always() | |
| # run: | | |
| # chmod +x ./scripts/ParseReports.sh ./scripts/BuildNumber.sh | |
| # ./scripts/ParseReports.sh | |
| # ./scripts/BuildNumber.sh | |
| - name: Send slack notification | |
| if: always() | |
| uses: edge/simple-slack-notify@master | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| with: | |
| channel: '#wallet-bot' | |
| status: ${{ job.status }} | |
| success_text: 'Smoke Tests completed successfully' | |
| failure_text: 'Smoke Tests failed' | |
| cancelled_text: 'Smoke Tests cancelled' | |
| fields: | | |
| [ | |
| { "title": "Action URL", "value": "${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}"}, | |
| { "title": "Build Number", "value":"${{ env.BUILD_NUMBER }}"}, | |
| { "title": "Failed Tests", "value":"${env.ALL_FAILED_TESTS}"} | |
| ] |