Feature/documentation and tests #26
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: | |
| branches: [ develop, master, main ] | |
| pull_request: | |
| branches: [ develop, master, main ] | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| api-level: [30, 33, 35] # Android 11, 13, 15 | |
| include: | |
| - api-level: 30 | |
| android-version: "Android 11" | |
| - api-level: 33 | |
| android-version: "Android 13" | |
| - api-level: 35 | |
| android-version: "Android 15" | |
| name: Build and Test (API ${{ matrix.api-level }} - ${{ matrix.android-version }}) | |
| env: | |
| GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError"' | |
| GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }} | |
| TARGET_API_LEVEL: ${{ matrix.api-level }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| with: | |
| cache-read-only: false | |
| - name: Make gradlew executable | |
| run: chmod +x BluePlaquesLondon/gradlew | |
| - name: Create google-services.json | |
| run: | | |
| echo '${{ secrets.GOOGLE_SERVICES_JSON }}' > BluePlaquesLondon/app/google-services.json | |
| - name: Check for exposed API keys | |
| run: | | |
| if grep -r "AIzaSy" BluePlaquesLondon/app/src/ --include="*.java" --include="*.xml" --include="*.gradle" --include="*.properties" 2>/dev/null; then | |
| echo "❌ Error: API key found in source code" | |
| exit 1 | |
| fi | |
| echo "✅ No exposed API keys found" | |
| - name: Run Android Lint | |
| run: cd BluePlaquesLondon && ./gradlew lintDebug | |
| - name: Run Detekt code analysis | |
| run: | | |
| cd BluePlaquesLondon | |
| ./gradlew detekt --continue || echo "⚠️ Detekt analysis completed with issues" | |
| - name: Check for TODO/FIXME | |
| run: | | |
| if find BluePlaquesLondon/app/src/main -name "*.java" -exec grep -l "TODO\|FIXME" {} \; | head -5; then | |
| echo "⚠️ Warning: TODO/FIXME found in source code" | |
| fi | |
| - name: Dependency vulnerability scan | |
| run: | | |
| cd BluePlaquesLondon | |
| ./gradlew dependencyCheckAnalyze --info || echo "⚠️ Dependency check completed with warnings" | |
| - name: Build debug APK | |
| run: cd BluePlaquesLondon && ./gradlew assembleDebug | |
| - name: Run unit tests (API ${{ matrix.api-level }}) | |
| run: | | |
| cd BluePlaquesLondon | |
| echo "Running tests for API level ${{ matrix.api-level }} (${{ matrix.android-version }})" | |
| ./gradlew testDebugUnitTest --no-daemon | |
| - name: Generate coverage report | |
| if: always() | |
| run: cd BluePlaquesLondon && ./gradlew jacocoTestReport --no-daemon --continue | |
| - name: Upload coverage to Codecov | |
| if: always() | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./BluePlaquesLondon/app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml | |
| fail_ci_if_error: false | |
| verbose: true | |
| - name: Upload test reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-reports-api-${{ matrix.api-level }} | |
| path: | | |
| BluePlaquesLondon/app/build/reports/ | |
| BluePlaquesLondon/app/build/outputs/androidTest-results/ | |
| - name: Upload APK | |
| if: success() && matrix.api-level == 35 # Only upload APK for latest API level | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-debug-api-${{ matrix.api-level }} | |
| path: BluePlaquesLondon/app/build/outputs/apk/debug/app-debug.apk |