diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..47a531e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,116 @@ +name: CI + +on: + pull_request: + branches: [master] + push: + branches: [master] + workflow_dispatch: + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +env: + GRADLE_OPTS: -Dorg.gradle.jvmargs=-Xmx6g + +jobs: + android: + name: Android + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 21 + + - uses: gradle/actions/setup-gradle@v4 + + # secrets.properties is gitignored, but the Secrets Gradle plugin fails without it. + # Real ad unit ids fall back to test ids in core:ui, so placeholders are enough. + - name: Create stub secrets.properties + run: | + cat > secrets.properties <<'EOF' + MAPS_API_KEY=ci-placeholder + ADS_ID_KEY=ca-app-pub-3940256099942544~3347511713 + METAN_ECOGAS_API=https://example.com/ + GITHUB_BASE_URL=https://example.com/ + EOF + + # google-services.json is gitignored; the Google Services plugin only needs a file + # with matching package names to build, so CI uses a stub without real keys. + - name: Create stub google-services.json + run: | + cat > app/google-services.json <<'EOF' + { + "project_info": { + "project_number": "000000000000", + "project_id": "metanmobile-ci", + "storage_bucket": "metanmobile-ci.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:000000000000:android:0000000000000000", + "android_client_info": { "package_name": "com.ngapp.metanmobile" } + }, + "api_key": [{ "current_key": "AIzaSyCI000000000000000000000000000000" }] + }, + { + "client_info": { + "mobilesdk_app_id": "1:000000000000:android:0000000000000001", + "android_client_info": { "package_name": "com.ngapp.metanmobile.debug" } + }, + "api_key": [{ "current_key": "AIzaSyCI000000000000000000000000000000" }] + } + ], + "configuration_version": "1" + } + EOF + + - name: Build + run: ./gradlew :app:assembleDebug + + - name: Unit tests + run: ./gradlew testDebugUnitTest testAndroidHostTest + + - name: Lint + run: ./gradlew lintDebug + + - name: Upload reports + if: failure() + uses: actions/upload-artifact@v4 + with: + name: android-reports + path: '**/build/reports/' + + ios: + name: iOS + runs-on: macos-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 21 + + - uses: gradle/actions/setup-gradle@v4 + + # secrets.properties is gitignored, but the Secrets Gradle plugin fails without it. + # Real ad unit ids fall back to test ids in core:ui, so placeholders are enough. + - name: Create stub secrets.properties + run: | + cat > secrets.properties <<'EOF' + MAPS_API_KEY=ci-placeholder + ADS_ID_KEY=ca-app-pub-3940256099942544~3347511713 + METAN_ECOGAS_API=https://example.com/ + GITHUB_BASE_URL=https://example.com/ + EOF + + - name: Compile shared code for iOS + run: ./gradlew :composeApp:compileKotlinIosSimulatorArm64 diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e20db57..0d88769 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -100,6 +100,9 @@ dependencies { // Firebase Performance still uses lite generated protobuf messages at runtime. This was // previously brought in transitively by the Android-only DataStore proto module. implementation(libs.protobuf.kotlin.lite) + // OssLicensesMenuActivity/OssLicensesActivity are declared in this module's manifest, so the + // library has to be on app's own compile classpath (core:ui only has it as implementation). + implementation(libs.google.oss.licenses) implementation(projects.core.analytics) implementation(projects.core.common)