diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index a27112110..2852ee30c 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -17,7 +17,8 @@ on: pull_request permissions: contents: write - + pull-requests: write + jobs: test: uses: ./.github/workflows/test.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0c606a1c3..a6509ec53 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -29,10 +29,10 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout Repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v3.3.1 + uses: gradle/actions/wrapper-validation@v4 - name: Set up JDK 17 uses: actions/setup-java@v4.2.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ced6d9852..2ff521537 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} - name: Set up JDK 17 @@ -31,7 +31,7 @@ jobs: with: java-version: '17' distribution: 'temurin' - - uses: gradle/wrapper-validation-action@v3.3.1 + - uses: gradle/actions/wrapper-validation@v4 - name: Create .gpg key run: | echo $GPG_KEY_ARMOR | base64 --decode > ./release.asc @@ -56,7 +56,7 @@ jobs: node-version: '14' - name: Semantic Release - uses: cycjimmy/semantic-release-action@v3.4.1 + uses: cycjimmy/semantic-release-action@v4.1.1 with: extra_plugins: | "@semantic-release/commit-analyzer@8.0.1" diff --git a/.github/workflows/report.yml b/.github/workflows/report.yml new file mode 100644 index 000000000..61a65b959 --- /dev/null +++ b/.github/workflows/report.yml @@ -0,0 +1,61 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A workflow that runs tests on every new pull request +name: Run unit tests + +on: + repository_dispatch: + types: [test] + push: + branches-ignore: ['gh-pages'] + pull_request: + branches-ignore: ['gh-pages'] + workflow_dispatch: + workflow_call: + +jobs: + test: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Gradle Wrapper Validation + uses: gradle/actions/wrapper-validation@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4.2.1 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build modules + run: ./gradlew build jacocoTestDebugUnitTestReport --stacktrace + + - name: Jacoco Report to PR + id: jacoco + uses: madrapps/jacoco-report@v1.7.1 + with: + paths: | + ${{ github.workspace }}/library/build/jacoco/jacoco.xml + token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} + min-coverage-overall: 26 + min-coverage-changed-files: 60 + title: Code Coverage + debug-mode: false + update-comment: true \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb604fdcb..a30213709 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,10 +33,10 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v3.3.1 + uses: gradle/actions/wrapper-validation@v4 - name: Set up JDK 17 uses: actions/setup-java@v4.2.1 @@ -45,17 +45,4 @@ jobs: distribution: 'temurin' - name: Build modules - run: ./gradlew build jacocoTestDebugUnitTestReport --stacktrace - - - name: Jacoco Report to PR - id: jacoco - uses: madrapps/jacoco-report@v1.6.1 - with: - paths: | - ${{ github.workspace }}/library/build/jacoco/jacoco.xml - token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} - min-coverage-overall: 26 - min-coverage-changed-files: 60 - title: Code Coverage - debug-mode: false - update-comment: true \ No newline at end of file + run: ./gradlew build jacocoTestDebugUnitTestReport --stacktrace \ No newline at end of file diff --git a/build.gradle b/build.gradle index 9dcf33b75..3bc54dc11 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ */ buildscript { - ext.kotlin_version = '2.0.0' + ext.kotlin_version = '2.0.21' repositories { google() mavenCentral() @@ -24,11 +24,11 @@ buildscript { } } dependencies { - classpath 'com.android.tools.build:gradle:8.7.0' - classpath 'com.mxalbert.gradle:jacoco-android:0.2.1' - classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.9.20" + classpath libs.gradle + classpath libs.jacoco.android + classpath libs.secrets.gradle.plugin + classpath libs.kotlin.gradle.plugin + classpath libs.dokka.gradle.plugin } } diff --git a/demo/build.gradle b/demo/build.gradle index 2f32c71eb..bbc7d2ff5 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -23,10 +23,10 @@ plugins { android { defaultConfig { - compileSdk 34 + compileSdk 35 applicationId "com.google.maps.android.utils.demo" minSdkVersion 21 - targetSdkVersion 34 + targetSdkVersion 35 versionCode 1 versionName "1.0" } @@ -53,16 +53,15 @@ dependencies { // [START_EXCLUDE silent] implementation project(':library') - implementation 'androidx.appcompat:appcompat:1.7.0' - implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' + implementation(libs.appcompat) + implementation(libs.lifecycle.extensions) + implementation(libs.lifecycle.viewmodel.ktx) + implementation(libs.kotlin.stdlib.jdk8) + implementation(libs.kotlinx.coroutines.android) + implementation(libs.kotlinx.coroutines.core) - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.6" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1' - testImplementation("junit:junit:4.13.2") - testImplementation("com.google.truth:truth:1.4.2") + testImplementation(libs.junit) + testImplementation(libs.truth) // [END_EXCLUDE] } // [END maps_android_utils_install_snippet] diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..802e5112a --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,43 @@ +[versions] +appcompat = "1.7.0" +dokka-gradle-plugin = "1.9.20" +gradle = "8.7.2" +jacoco-android = "0.2.1" +lifecycle-extensions = "2.2.0" +lifecycle-viewmodel-ktx = "2.8.7" +kotlin = "2.0.21" +kotlinx-coroutines = "1.9.0" +junit = "4.13.2" +secrets-gradle-plugin = "2.0.1" +truth = "1.4.2" +play-services-maps = "19.0.0" +core-ktx = "1.15.0" +robolectric = "4.12.2" +kxml2 = "2.3.0" +mockk = "1.13.11" +lint = "31.7.2" + +[libraries] +appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } +dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka-gradle-plugin" } +gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" } +jacoco-android = { module = "com.mxalbert.gradle:jacoco-android", version.ref = "jacoco-android" } +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +lifecycle-extensions = { module = "androidx.lifecycle:lifecycle-extensions", version.ref = "lifecycle-extensions" } +lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle-viewmodel-ktx" } +kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } +kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" } +kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } +junit = { module = "junit:junit", version.ref = "junit" } +secrets-gradle-plugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets-gradle-plugin" } +truth = { module = "com.google.truth:truth", version.ref = "truth" } +play-services-maps = { module = "com.google.android.gms:play-services-maps", version.ref = "play-services-maps" } +core-ktx = { module = "androidx.core:core-ktx", version.ref = "core-ktx" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } +kxml2 = { module = "net.sf.kxml:kxml2", version.ref = "kxml2" } +mockk = { module = "io.mockk:mockk", version.ref = "mockk" } +lint-api = { module = "com.android.tools.lint:lint-api", version.ref = "lint" } +lint-checks = { module = "com.android.tools.lint:lint-checks", version.ref = "lint" } +lint = { module = "com.android.tools.lint:lint", version.ref = "lint" } +lint-tests = { module = "com.android.tools.lint:lint-tests", version.ref = "lint" } +testutils = { module = "com.android.tools:testutils", version.ref = "lint" } diff --git a/library/build.gradle b/library/build.gradle index 641cf7db1..56170c77b 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -25,9 +25,9 @@ dokkaHtml { android { defaultConfig { - compileSdk 34 + compileSdk 35 minSdkVersion 21 - targetSdkVersion 34 + targetSdkVersion 35 versionCode 1 versionName "1.0" consumerProguardFiles 'consumer-rules.pro' @@ -64,16 +64,16 @@ android { dependencies { // We are adding api() for the Maps SDK for Android, so it propagates to the app-level modules. - api 'com.google.android.gms:play-services-maps:19.0.0' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1' - implementation 'androidx.appcompat:appcompat:1.7.0' - implementation 'androidx.core:core-ktx:1.13.1' + api(libs.play.services.maps) + implementation(libs.kotlinx.coroutines.android) + implementation(libs.appcompat) + implementation(libs.core.ktx) lintPublish project(':lint-checks') - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.robolectric:robolectric:4.12.2' - testImplementation 'net.sf.kxml:kxml2:2.3.0' - testImplementation "io.mockk:mockk:1.13.11" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation(libs.junit) + testImplementation(libs.robolectric) + testImplementation(libs.kxml2) + testImplementation(libs.mockk) + implementation(libs.kotlin.stdlib.jdk8) } tasks.register('instrumentTest') { dependsOn connectedCheck } diff --git a/lint-checks/build.gradle b/lint-checks/build.gradle index a8b3b3975..b07d68867 100644 --- a/lint-checks/build.gradle +++ b/lint-checks/build.gradle @@ -1,3 +1,19 @@ +/** + * Copyright 2024 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + apply plugin: 'java-library' apply plugin: 'kotlin' apply plugin: 'com.android.lint' @@ -11,14 +27,13 @@ lintOptions { } dependencies { - compileOnly "com.android.tools.lint:lint-api:31.4.1" - compileOnly "com.android.tools.lint:lint-checks:31.4.1" - // compileOnly "com.android.tools.lint:manifest-merger:31.1.0" - compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testImplementation "junit:junit:4.13.2" - testImplementation "com.android.tools.lint:lint:31.4.1" - testImplementation "com.android.tools.lint:lint-tests:31.4.1" - testImplementation "com.android.tools:testutils:31.4.1" + compileOnly(libs.lint.api) + compileOnly(libs.lint.checks) + compileOnly(libs.kotlin.stdlib.jdk8) + testImplementation(libs.junit) + testImplementation(libs.lint) + testImplementation(libs.lint.tests) + testImplementation(libs.testutils) } jar {