diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..3c41226 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,106 @@ +name: Build and Test + +on: + push: + branches: [ main, master, develop ] + pull_request: + branches: [ main, master, develop ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'temurin' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Create mock google-services.json for CI + run: | + cat > app/google-services.json << 'EOF' + { + "project_info": { + "project_number": "123456789", + "firebase_url": "https://mock-project.firebaseio.com", + "project_id": "mock-project", + "storage_bucket": "mock-project.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:123456789:android:abcdef123456", + "android_client_info": { + "package_name": "me.cutmail.disasterapp" + } + }, + "oauth_client": [ + { + "client_id": "123456789-abcdefghijklmnop.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyDummyKeyForCIBuildOnly123456789" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "123456789-abcdefghijklmnop.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" + } + EOF + + - 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: Build with Gradle + run: ./gradlew build --stacktrace + + - name: Run unit tests + run: ./gradlew test --stacktrace + + - name: Run lint checks + run: ./gradlew lint --stacktrace + + - name: Upload build reports + if: failure() + uses: actions/upload-artifact@v4 + with: + name: build-reports + path: | + app/build/reports/ + app/build/test-results/ + retention-days: 7 + + - name: Upload APK + if: success() + uses: actions/upload-artifact@v4 + with: + name: app-debug + path: app/build/outputs/apk/debug/*.apk + retention-days: 7 diff --git a/app/build.gradle b/app/build.gradle index 8386a24..2e6919d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,6 +42,7 @@ dependencies { implementation 'com.jakewharton.timber:timber:4.7.1' implementation 'com.github.hotchemi:android-rate:1.0.1' implementation 'com.firebaseui:firebase-ui-firestore:7.1.1' + implementation 'com.google.firebase:firebase-firestore:22.0.1' implementation 'com.google.firebase:firebase-crashlytics:17.3.0' implementation 'com.google.firebase:firebase-analytics:18.0.0' implementation 'com.google.firebase:firebase-database:19.6.0'