Skip to content

fix: CI unit tests hanging — use runPureTests + runMockTests #569

fix: CI unit tests hanging — use runPureTests + runMockTests

fix: CI unit tests hanging — use runPureTests + runMockTests #569

Workflow file for this run

# CI Workflow - Build and Test
# Purpose: Continuous integration for pull requests and commits
# - Builds debug APK for validation
# - Runs unit tests and lint checks
# - Performs size analysis
# - Does NOT create releases (see build-apk.yml for dev releases)
name: Build APK
on:
push:
branches: [ main, develop ]
tags-ignore:
- 'v*' # Don't run on version tags - release.yml handles those
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
outputs:
sha_short: ${{ steps.vars.outputs.sha_short }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set build variables
id: vars
run: |
echo "sha_short=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_OUTPUT
echo "build_date=$(date '+%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT
- name: Setup Java 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Make gradlew executable
run: chmod +x gradlew
- name: Build debug APK
run: ./gradlew assembleDebug --stacktrace
- name: Upload debug APKs
uses: actions/upload-artifact@v4
with:
name: cleverkeys-debug-${{ steps.vars.outputs.sha_short }}
path: build/outputs/apk/debug/*.apk
retention-days: 14
- name: Run tests
run: ./gradlew test --stacktrace
continue-on-error: true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ steps.vars.outputs.sha_short }}
path: build/reports/tests/
retention-days: 7
if-no-files-found: ignore
size-analysis:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download debug APKs
uses: actions/download-artifact@v4
with:
name: cleverkeys-debug-${{ needs.build.outputs.sha_short }}
path: ./
- name: Analyze APK sizes
run: |
echo "## Build Analysis - Per-ABI APK Sizes" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| ABI | Size | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----|------|--------|" >> $GITHUB_STEP_SUMMARY
ls -la *.apk || { echo "No APK files found"; ls -la; exit 1; }
FAIL=0
for APK_FILE in *.apk; do
APK_SIZE=$(stat -c%s "$APK_FILE" 2>/dev/null || stat -f%z "$APK_FILE")
APK_SIZE_MB=$((APK_SIZE / 1024 / 1024))
# Determine ABI from filename
if [[ "$APK_FILE" == *"universal"* ]]; then
ABI="universal"
MAX_SIZE=60
elif [[ "$APK_FILE" == *"arm64"* ]]; then
ABI="arm64-v8a"
MAX_SIZE=40
elif [[ "$APK_FILE" == *"armeabi"* ]] || [[ "$APK_FILE" == *"armv7"* ]]; then
ABI="armeabi-v7a"
MAX_SIZE=35
elif [[ "$APK_FILE" == *"x86_64"* ]]; then
ABI="x86_64"
MAX_SIZE=40
else
ABI="unknown"
MAX_SIZE=60
fi
if [ $APK_SIZE_MB -gt $MAX_SIZE ]; then
echo "| $ABI | ${APK_SIZE_MB}MB | ⚠️ Exceeds ${MAX_SIZE}MB |" >> $GITHUB_STEP_SUMMARY
FAIL=1
else
echo "| $ABI | ${APK_SIZE_MB}MB | ✅ OK |" >> $GITHUB_STEP_SUMMARY
fi
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Neural Models**: Included (ONNX Runtime + transformer)" >> $GITHUB_STEP_SUMMARY
echo "- **Package**: tribixbite.cleverkeys" >> $GITHUB_STEP_SUMMARY
if [ $FAIL -eq 1 ]; then
echo "::warning::Some APKs exceed size thresholds"
fi