Skip to content

Commit

Permalink
Update deps and make task output dirs unique per task (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers authored May 21, 2021
1 parent 490c77f commit 8161b1e
Show file tree
Hide file tree
Showing 43 changed files with 215 additions and 3,199 deletions.
38 changes: 21 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ on:

jobs:
build:
name: ${{ matrix.job }} / JDK ${{ matrix.ci_java_version }} / AGP ${{ matrix.ci_agp_version }} / TraceRefs ${{ matrix.ci_tracerefs }}
name: ${{ matrix.job }} / JDK ${{ matrix.java }} / AGP ${{ matrix.agp }} / TraceRefs ${{ matrix.tracerefs }}
# Use macOS for emulator hardware acceleration
runs-on: macOS-latest
timeout-minutes: 30
strategy:
fail-fast: false # We want to see all results
matrix:
ci_java_version: [1.8]
ci_agp_version: [4.0.0, 4.1.1, 4.2.0-beta02]
ci_tracerefs: [true, false]
job: [instrumentation, plugin]
java: ['8', '11']
agp: ['4.2.1', '7.0.0-beta01']
tracerefs: [true, false]
job: ['instrumentation', 'plugin']
exclude:
# AGP 7.x requires JDK 11+
- agp: 7.0.0-beta01
java: 8
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -37,26 +41,26 @@ jobs:
- uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ matrix.ci_agp_version }}-${{ matrix.job }}-${{ hashFiles('checksum.txt') }}
key: ${{ runner.os }}-gradle-${{ matrix.java }}-${{ hashFiles('checksum.txt') }}
restore-keys: |
${{ runner.os }}-gradle-${{ matrix.ci_agp_version }}-${{ matrix.job }}-
${{ runner.os }}-gradle-${{ matrix.java }}-
- name: Install JDK ${{ matrix.ci_java_version }}
uses: actions/setup-java@v1.4.3
- name: Install JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.ci_java_version }}
distribution: 'adopt'
java-version: ${{ matrix.java }}

- name: Test plugin
if: matrix.job == 'plugin'
run: ./gradlew -p keeper-gradle-plugin clean check --stacktrace -PkeeperTest.agpVersion=${{ matrix.ci_agp_version }}
run: ./gradlew -p keeper-gradle-plugin clean check --stacktrace -PkeeperTest.agpVersion=${{ matrix.agp }}

- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
if: matrix.job == 'instrumentation'
with:
# Run connectedCheck with both Proguard and R8.
# We don't want to wait for the emulator to start/stop twice, so we combine this script into the same step.
script: .github/workflows/run_instrumentation_tests.sh ${{ matrix.ci_agp_version }} ${{ matrix.ci_tracerefs }}
script: .github/workflows/run_instrumentation_tests.sh ${{ matrix.agp }} ${{ matrix.tracerefs }}
api-level: 29

- name: (Fail-only) Bundle the build report
Expand All @@ -72,12 +76,12 @@ jobs:

- name: Reclaim memory
run: ./gradlew --stop && jps|grep -E 'KotlinCompileDaemon|GradleDaemon'| awk '{print $1}'| xargs kill -9 || true
if: success() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && matrix.ci_java_version == '1.8' && matrix.ci_agp_version == '4.0.0' && matrix.job == 'plugin'
if: success() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && matrix.java == '8' && matrix.agp == '4.2.1' && matrix.tracerefs && matrix.job == 'plugin'

- name: Upload snapshot (main only)
env:
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SonatypeUsername }}
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SonatypePassword }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SonatypeUsername }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SonatypePassword }}
run: |
./publish.sh --snapshot
if: success() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && matrix.ci_java_version == '1.8' && matrix.ci_agp_version == '4.0.0' && matrix.job == 'plugin'
if: success() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && matrix.java == '8' && matrix.agp == '4.2.1' && matrix.tracerefs && matrix.job == 'plugin'
19 changes: 5 additions & 14 deletions .github/workflows/run_instrumentation_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@
AGP_VERSION=$1
ENABLE_TRACEREFS=$2

function printthreads {
echo "Thread dump"
jps|grep -E 'KotlinCompileDaemon|GradleDaemon'| awk '{print $1}'| xargs jstack
exit 1
}

trap printthreads SIGINT

echo "Install coreutils" # For gtimeout
brew install coreutils

# We only run the sample with R8 as proguard infinite loops if we have java 8 libraries on the classpath 🙃
./gradlew :sample:minifyExternalStagingWithR8 --stacktrace -PkeeperTest.agpVersion="${AGP_VERSION}" -PkeeperTest.enableTraceReferences="${ENABLE_TRACEREFS}"
echo "Building APK and verifying L8"
./gradlew :sample:minifyExternalStagingWithR8 --stacktrace -PkeeperTest.agpVersion="${AGP_VERSION}" -PkeeperTest.enableTraceReferences="${ENABLE_TRACEREFS}" -Pkeeper.verifyL8=true
# Reclaim memory because Actions OOMs sometimes with having both an emulator and heavy gradle builds going on
./gradlew --stop && jps|grep -E 'KotlinCompileDaemon|GradleDaemon'| awk '{print $1}'| xargs kill -9 || true
./gradlew --stop || jps|grep -E 'KotlinCompileDaemon|GradleDaemon'| awk '{print $1}'| xargs kill -9 || true
# Now proceed, with much of the build being cached up to this point
gtimeout --signal=SIGINT 10m ./gradlew connectedExternalStagingAndroidTest --stacktrace -PkeeperTest.agpVersion="${AGP_VERSION}" -PkeeperTest.enableTraceReferences="${ENABLE_TRACEREFS}"
echo "Running instrumentation tests"
./gradlew connectedExternalStagingAndroidTest --stacktrace -PkeeperTest.agpVersion="${AGP_VERSION}" -PkeeperTest.enableTraceReferences="${ENABLE_TRACEREFS}"
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ buildscript {
repositories {
google()
mavenCentral()
jcenter()
}

String defaultAgpVersion = "4.0.0"
String defaultAgpVersion = "4.2.1"
String agpVersion = findProperty("keeperTest.agpVersion")?.toString() ?: defaultAgpVersion
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0"
classpath "com.android.tools.build:gradle:$agpVersion"
classpath "com.slack.keeper:keeper"
}
Expand All @@ -37,7 +36,6 @@ allprojects {
repositories {
google()
mavenCentral()
jcenter()
}

pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
48 changes: 17 additions & 31 deletions keeper-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,33 @@ import java.net.URL
plugins {
`kotlin-dsl`
`java-gradle-plugin`
kotlin("jvm") version "1.4.30"
kotlin("kapt") version "1.4.30"
id("org.jetbrains.dokka") version "1.4.20"
id("com.vanniktech.maven.publish") version "0.13.0"
kotlin("jvm") version "1.5.0"
kotlin("kapt") version "1.5.0"
id("org.jetbrains.dokka") version "1.4.32"
id("com.vanniktech.maven.publish") version "0.15.1"
}

buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
jcenter()
gradlePluginPortal()
}
}

repositories {
mavenCentral()
google()
gradlePluginPortal()
jcenter().mavenContent {
// Required for Dokka
includeModule("org.jetbrains.kotlinx", "kotlinx-html-jvm")
includeGroup("org.jetbrains.dokka")
includeModule("org.jetbrains", "markdown")
}
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
@Suppress("SuspiciousCollectionReassignment")
freeCompilerArgs += listOf("-progressive")
// Because Gradle's Kotlin handling is stupid
apiVersion = "1.4"
languageVersion = "1.4"
// @Suppress("SuspiciousCollectionReassignment")
// freeCompilerArgs += listOf("-progressive")
}
}

Expand Down Expand Up @@ -78,10 +74,6 @@ gradlePlugin {
}
}

kotlinDslPluginOptions {
experimentalWarning.set(false)
}

kotlin {
explicitApi()
}
Expand All @@ -97,36 +89,30 @@ tasks.named<DokkaTask>("dokkaHtml") {
packageListUrl.set(URL("https://developer.android.com/reference/tools/gradle-api/4.1/package-list"))
url.set(URL("https://developer.android.com/reference/tools/gradle-api/4.1/classes"))
}

// Suppress Zipflinger copy
// TODO re-enable this with a proper regex
// perPackageOption {
// matchingRegex.set("com.slack.keeper.internal.zipflinger")
// suppress.set(true)
// }
}
}

val defaultAgpVersion = "4.0.0"
val defaultAgpVersion = "4.2.1"
val agpVersion = findProperty("keeperTest.agpVersion")?.toString() ?: defaultAgpVersion

// See https://github.com/slackhq/keeper/pull/11#issuecomment-579544375 for context
val releaseMode = hasProperty("keeper.releaseMode")
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.4.30")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.5.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0")
implementation("com.android:zipflinger:4.2.1")

if (releaseMode) {
compileOnly("com.android.tools.build:gradle:$defaultAgpVersion")
} else {
implementation("com.android.tools.build:gradle:$agpVersion")
}

compileOnly("com.google.auto.service:auto-service-annotations:1.0-rc7")
kapt("com.google.auto.service:auto-service:1.0-rc7")
compileOnly("com.google.auto.service:auto-service-annotations:1.0")
kapt("com.google.auto.service:auto-service:1.0")

testImplementation("com.squareup:javapoet:1.13.0")
testImplementation("com.squareup:kotlinpoet:1.7.2")
testImplementation("com.squareup:kotlinpoet:1.8.0")
testImplementation("com.google.truth:truth:1.1.2")
testImplementation("junit:junit:4.13.2")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 1 addition & 2 deletions keeper-gradle-plugin/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
pluginManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
jcenter()
gradlePluginPortal()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ public abstract class InferAndroidTestKeepRules : JavaExec() {
val inputJvmArgs = jvmArgsProperty.get()
if (inputJvmArgs.isNotEmpty()) {
logger.lifecycle(
"Starting infer exec with jvmArgs ${inputJvmArgs.joinToString(", ", prefix = "[",
postfix = "]")}. If debugging, attach the debugger now."
"Starting infer exec with jvmArgs ${
inputJvmArgs.joinToString(", ", prefix = "[",
postfix = "]")
}. If debugging, attach the debugger now."
)
jvmArgs = inputJvmArgs
}
Expand All @@ -109,28 +111,28 @@ public abstract class InferAndroidTestKeepRules : JavaExec() {
}

private fun genPrintUsesArgs(): List<String> =
listOf(
"--keeprules",
androidJar.get().asFile.absolutePath,
appTargetJar.get().asFile.absolutePath,
androidTestSourceJar.get().asFile.absolutePath
).also {
// print-uses is using its output to print rules
standardOutput = outputProguardRules.asFile.get().outputStream().buffered()
}
listOf(
"--keeprules",
androidJar.get().asFile.absolutePath,
appTargetJar.get().asFile.absolutePath,
androidTestSourceJar.get().asFile.absolutePath
).also {
// print-uses is using its output to print rules
standardOutput = outputProguardRules.asFile.get().outputStream().buffered()
}

private fun genTraceReferencesArgs(): List<String?> =
listOf(
"--keep-rules" to "",
"--lib" to androidJar.get().asFile.absolutePath,
"--lib" to androidTestJar.get().asFile.takeIf { it.exists() }?.absolutePath,
"--target" to appTargetJar.get().asFile.absolutePath,
"--source" to androidTestSourceJar.get().asFile.absolutePath,
"--output" to outputProguardRules.get().asFile.absolutePath
).map { if (it.second != null) listOf(it.first, it.second) else listOf() }
.reduce { acc, any -> acc + any }
// Add user provided args coming from TraceReferences.arguments after generated ones.
.plus(traceReferencesArgs.getOrElse(listOf()))
listOf(
"--keep-rules" to "",
"--lib" to androidJar.get().asFile.absolutePath,
"--lib" to androidTestJar.get().asFile.takeIf { it.exists() }?.absolutePath,
"--target" to appTargetJar.get().asFile.absolutePath,
"--source" to androidTestSourceJar.get().asFile.absolutePath,
"--output" to outputProguardRules.get().asFile.absolutePath
).map { if (it.second != null) listOf(it.first, it.second) else listOf() }
.reduce { acc, any -> acc + any }
// Add user provided args coming from TraceReferences.arguments after generated ones.
.plus(traceReferencesArgs.getOrElse(listOf()))

public companion object {
@Suppress("UNCHECKED_CAST", "UnstableApiUsage")
Expand Down Expand Up @@ -173,8 +175,9 @@ public abstract class InferAndroidTestKeepRules : JavaExec() {
this.traceReferencesArgs.set(traceReferencesArgs)
outputProguardRules.set(
project.layout.buildDirectory.file(
"${KeeperPlugin.INTERMEDIATES_DIR}/inferred${variantName.capitalize(
Locale.US)}KeepRules.pro"))
"${KeeperPlugin.INTERMEDIATES_DIR}/${
variantName.capitalize(Locale.US)
}/inferredKeepRules.pro"))
classpath(r8Configuration)
mainClass.set(this.traceReferencesEnabled.map { enabled ->
when (enabled) {
Expand Down
Loading

0 comments on commit 8161b1e

Please sign in to comment.