Skip to content

Merge pull request #60 from docknetwork/fix/issues-with-wallet-unlock #11

Merge pull request #60 from docknetwork/fix/issues-with-wallet-unlock

Merge pull request #60 from docknetwork/fix/issues-with-wallet-unlock #11

name: "Bank Demo tests"
on:
push:
workflow_dispatch:
inputs:
build_number:
description: 'Build number e.g v1.7.0 build-904'
required: false
default: 'v1.7.4 build-340'
distribution-name:
description: 'Distribution name matching the S3 bucket pattern app-{name}-distribution (e.g., truvera for app-truvera-distribution, bank-demo for app-bank-demo-distribution)'
required: false
default: 'bank-demo'
workflow_call:
inputs:
build_number:
description: 'Build number e.g v1.7.0 build-904'
required: false
default: 'v1.7.4 build-340'
type: string
distribution-name:
description: 'Distribution name matching the S3 bucket pattern app-{name}-distribution (e.g., truvera for app-truvera-distribution, bank-demo for app-bank-demo-distribution)'
required: false
default: 'bank-demo'
type: string
# Auto cancels previous running CI jobs in this PR on each new commit
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.inputs.distribution-name }}
cancel-in-progress: true
jobs:
bank-demo-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: |
# Set distribution name (default to bank-demo if not provided)
DISTRIBUTION_NAME="${{ github.event.inputs.distribution-name }}"
if [ -z "$DISTRIBUTION_NAME" ]; then
DISTRIBUTION_NAME="bank-demo"
fi
echo "DISTRIBUTION_NAME=$DISTRIBUTION_NAME" >> "$GITHUB_ENV"
echo "Using distribution name: $DISTRIBUTION_NAME"
# 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-${DISTRIBUTION_NAME}-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-${{ env.DISTRIBUTION_NAME }}-distribution/${{ env.DIRECTORY_NAME }}/dock-wallet.apk"
aws s3 cp s3://dock-wallet/app-${{ env.DISTRIBUTION_NAME }}-distribution/${{ env.DIRECTORY_NAME }}/dock-wallet.apk ./app/quotient-wallet.apk
- name: Install Dependencies
run: |
npm install --force
yarn global add appium
appium driver install uiautomator2
npx playwright install --with-deps chromium
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: AVD cache
uses: actions/cache/restore@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-34-default
- 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: 34
target: default
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 -memory 4096
disable-animations: false
script: |
sleep 60
- name: Save AVD cache
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-34-default
- name: Start Appium Server
run: |
appium &>/dev/null &
APPIUM_PID=$!
- name: Run Bank Demo Integration Tests
uses: ReactiveCircus/android-emulator-runner@v2
env:
CERTS_API_KEY: ${{ secrets.CERTS_API_KEY }}
CERTS_API_URL: ${{ secrets.CERTS_API_URL }}
ISSUER_DID: ${{ secrets.ISSUER_DID }}
TEST_CREDENTIALS: ${{ secrets.TEST_CREDENTIALS }}
with:
api-level: 34
target: default
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
script: |
adb install -g ./app/quotient-wallet.apk
adb shell pm grant com.dockapp android.permission.WRITE_EXTERNAL_STORAGE || true
echo "$TEST_CREDENTIALS" > test-credentials.json
adb logcat -G 16M || true
adb logcat -c || true
npm run test:bank-demo; TEST_EXIT=$?; adb logcat -d > logcat.txt; adb shell pm list packages | grep -iE 'dock|quotient' > packages.txt; exit $TEST_EXIT
- name: Force Kill Emulator
if: always()
continue-on-error: true
run: |
pkill -9 qemu-system-x86_64 || true
pkill -9 adb || true
- name: Upload Logcat
if: always()
uses: actions/upload-artifact@v4
with:
name: logcat
path: |
logcat.txt
packages.txt
retention-days: 30
- 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 Playwright HTML Report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-html-report
path: test-reports/playwright-html/
retention-days: 30
- name: Upload Playwright Test Results (JUnit)
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-junit-report
path: test-reports/playwright-junit/
retention-days: 30
- name: Upload Test Results Directory
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results/
retention-days: 30
- name: Publish Playwright Test Results
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: test-reports/playwright-junit/results.xml
check_name: Bank Demo Integration Tests Results
comment_title: Bank Demo Integration Tests Results
- name: Extract Playwright Test Results
if: always()
id: test-results
run: |
# Extract test results from Playwright JSON report
if [ -f "test-reports/playwright-json/results.json" ]; then
TOTAL=$(jq '.suites[].specs | length' test-reports/playwright-json/results.json | awk '{s+=$1} END {print s}')
PASSED=$(jq '[.suites[].specs[].tests[] | select(.status=="expected")] | length' test-reports/playwright-json/results.json)
FAILED=$(jq '[.suites[].specs[].tests[] | select(.status=="unexpected")] | length' test-reports/playwright-json/results.json)
SKIPPED=$(jq '[.suites[].specs[].tests[] | select(.status=="skipped")] | length' test-reports/playwright-json/results.json)
echo "TOTAL_TESTS=$TOTAL" >> $GITHUB_ENV
echo "PASSED_TESTS=$PASSED" >> $GITHUB_ENV
echo "FAILED_TESTS=$FAILED" >> $GITHUB_ENV
echo "SKIPPED_TESTS=$SKIPPED" >> $GITHUB_ENV
TEST_SUMMARY="✅ Passed: $PASSED | ❌ Failed: $FAILED | ⏭️ Skipped: $SKIPPED | 📊 Total: $TOTAL"
echo "TEST_SUMMARY=$TEST_SUMMARY" >> $GITHUB_ENV
else
echo "TEST_SUMMARY=⚠️ Test results not found" >> $GITHUB_ENV
fi
- name: Generate Test Summary
if: always()
run: |
echo "# 🏦 Bank Demo Integration Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 📊 Test Summary" >> $GITHUB_STEP_SUMMARY
echo "${{ env.TEST_SUMMARY }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 📦 Distribution" >> $GITHUB_STEP_SUMMARY
echo "- **Distribution name**: ${{ env.DISTRIBUTION_NAME }}" >> $GITHUB_STEP_SUMMARY
echo "- **Build number**: ${{ env.BUILD_NUMBER }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 📸 Artifacts" >> $GITHUB_STEP_SUMMARY
echo "- **Screenshots**: Available in the screenshots artifact" >> $GITHUB_STEP_SUMMARY
echo "- **Playwright HTML Report**: Download playwright-html-report artifact" >> $GITHUB_STEP_SUMMARY
echo "- **Test Results**: Download test-results artifact for traces and videos" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 🔗 Links" >> $GITHUB_STEP_SUMMARY
echo "- [View Full Test Run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY
- 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: '✅ Bank Demo Integration Tests Passed'
failure_text: '❌ Bank Demo Integration Tests Failed'
cancelled_text: '⚠️ Bank Demo Integration Tests Cancelled'
fields: |
[
{ "title": "Test Type", "value": "🏦 Bank Demo Integration", "short": true },
{ "title": "Build Number", "value": "${{ env.BUILD_NUMBER }}", "short": true },
{ "title": "Branch", "value": "${{ github.ref_name }}", "short": true },
{ "title": "Distribution", "value": "${{ env.DISTRIBUTION_NAME }}", "short": true },
{ "title": "Action URL", "value": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" }
]