Skip to content

Commit ddcd098

Browse files
romtsnrunningcode
andauthored
ci(agp-matrix): Generate compatibility matrix dynamically (#873)
* ci(agp-matrix): Generate compatibility matrix dynamically * fix script filename * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * Works? * Change name * Switch to ksp for room * Override version check for tests * also fetch kotlin-gradle compatibility and use the min supported gradle version * Matrix only last line of the script output * Changelog * Run test matrix nightly * Minor comments * Update .github/workflows/test-matrix-agp-gradle.yaml Co-authored-by: Nelson Osacky <[email protected]> * Update scripts/generate-compat-matrix.main.kts --------- Co-authored-by: Nelson Osacky <[email protected]>
1 parent dee9553 commit ddcd098

File tree

8 files changed

+347
-35
lines changed

8 files changed

+347
-35
lines changed

.github/workflows/test-matrix-agp-gradle.yaml

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Test Matrix
22

33
on:
4+
schedule:
5+
- cron: '0 4 * * *'
46
push:
57
branches:
68
- main
@@ -11,42 +13,42 @@ concurrency:
1113
cancel-in-progress: true
1214

1315
jobs:
16+
generate-matrix:
17+
name: Generate Compat Matrix
18+
runs-on: ubuntu-latest
19+
outputs:
20+
matrix: ${{ steps.generate.outputs.matrix }}
21+
steps:
22+
- name: Checkout Repo
23+
uses: actions/checkout@v4
24+
- name: Generate Compat Matrix
25+
id: generate
26+
run: |
27+
# Run the script and capture full output for debugging
28+
full_output=$(kotlin scripts/generate-compat-matrix.main.kts)
29+
30+
# Show the full output for debugging
31+
echo "Full script output:"
32+
echo "$full_output"
33+
34+
# Extract only the last line (the JSON matrix)
35+
matrix=$(echo "$full_output" | tail -n 1)
36+
37+
echo "matrix<<EOF" >> "$GITHUB_OUTPUT"
38+
echo "$matrix" >> "$GITHUB_OUTPUT"
39+
echo "EOF" >> "$GITHUB_OUTPUT"
40+
41+
echo "Parsed matrix:"
42+
echo "$matrix" | jq
43+
1444
publish-dry-run:
45+
needs: generate-matrix
1546
runs-on: ubuntu-latest
1647
strategy:
1748
fail-fast: false
18-
matrix:
19-
agp: [ "7.4.0" ]
20-
gradle: [ "7.6.4" ]
21-
java: [ "11" ]
22-
groovy: [ "1.2" ]
23-
include:
24-
- agp: "7.4.0"
25-
gradle: "7.6.4"
26-
java: "11"
27-
groovy: "1.2"
28-
- agp: "8.0.0"
29-
gradle: "8.0.2"
30-
java: "17"
31-
groovy: "1.2"
32-
- agp: "8.6.1"
33-
gradle: "8.7"
34-
java: "17"
35-
groovy: "1.2"
36-
- agp: "8.8.1"
37-
gradle: "8.14.1"
38-
java: "17"
39-
groovy: "1.7.1"
40-
- agp: "8.9.0"
41-
gradle: "8.14.1"
42-
java: "17"
43-
groovy: "1.7.1"
44-
- agp: "8.10.0"
45-
gradle: "8.14.1"
46-
java: "17"
47-
groovy: "1.7.1"
49+
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
4850

49-
name: Test Matrix - AGP ${{ matrix.agp }} - Gradle ${{ matrix.gradle }}
51+
name: Test Matrix - AGP ${{ matrix.agp }} - Gradle ${{ matrix.gradle }} - Java ${{ matrix.java }} - Groovy ${{ matrix.groovy }}
5052
env:
5153
VERSION_AGP: ${{ matrix.agp }}
5254
VERSION_GROOVY: ${{ matrix.groovy }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
### Internal
1414

1515
- Add Google Truth for easier to debug assertions in tests ([#920](https://github.com/getsentry/sentry-android-gradle-plugin/pull/920))
16+
- Generate AGP/Gradle compatibility matrix dynamically ([#873](https://github.com/getsentry/sentry-android-gradle-plugin/pull/873))
1617

1718
### Dependencies
1819

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
alias(libs.plugins.kotlin) apply false
33
alias(libs.plugins.kotlinAndroid) apply false
44
alias(libs.plugins.kapt) apply false
5+
alias(libs.plugins.ksp) apply false
56
alias(libs.plugins.androidApplication) version BuildPluginsVersion.AGP apply false
67
alias(libs.plugins.androidLibrary) version BuildPluginsVersion.AGP apply false
78
alias(libs.plugins.spotless)

examples/android-instrumentation-sample/build.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
alias(libs.plugins.androidApplication) version BuildPluginsVersion.AGP
33
alias(libs.plugins.kotlinAndroid)
4-
alias(libs.plugins.kapt)
4+
alias(libs.plugins.ksp)
55
id("io.sentry.android.gradle")
66
}
77

@@ -86,13 +86,12 @@ dependencies {
8686

8787
implementation(libs.sample.room.runtime)
8888
implementation(libs.sample.room.ktx)
89-
implementation(libs.sample.room.rxjava)
9089

9190
implementation(libs.sample.timber.timber)
9291
implementation(project(":examples:android-room-lib"))
9392
implementation(libs.sample.fragment.fragmentKtx)
9493

95-
kapt(libs.sample.room.compiler)
94+
ksp(libs.sample.room.compiler)
9695
}
9796

9897
sentry {

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ android.useAndroidX=true
66

77
# Kotlin code style for this project: "official" or "obsolete":
88
kotlin.code.style=official
9+
# For AGP matrix tests, we can't infer the correct Gradle version for pre-releases
10+
android.overrideVersionCheck=true

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
1717
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
1818
kotlinSpring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
1919
kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
20+
ksp = { id = "com.google.devtools.ksp", version = "1.8.20-1.0.11" }
2021
dokka = { id = "org.jetbrains.dokka", version = "1.8.10" }
2122
spotless = { id = "com.diffplug.spotless", version = "7.0.4" }
2223
groovyGradlePlugin = { id = "dev.gradleplugins.groovy-gradle-plugin", version = "1.7.1" }
@@ -77,7 +78,6 @@ sample-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-c
7778
sample-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "sampleRoom" }
7879
sample-room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "sampleRoom" }
7980
sample-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "sampleRoom" }
80-
sample-room-rxjava = { group = "androidx.room", name = "room-rxjava2", version.ref = "sampleRoom" }
8181

8282
sample-retrofit-retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "sampleRetrofit" }
8383
sample-retrofit-retrofitGson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "sampleRetrofit" }

plugin-build/src/test/resources/testFixtures/appTestProject/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ org.gradle.daemon=false
33
org.gradle.parallel=true
44

55
android.useAndroidX=true
6+
# For AGP matrix tests, we can't infer the correct Gradle version for pre-releases
7+
android.overrideVersionCheck=true

0 commit comments

Comments
 (0)