-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test Gradle plugin on relevant PRs (#2509)
* Update Gradle used in tooling subprojects * Update Kotlin in Compose Gradle plugin * Decrease verbosity of Gradle plugin tests * Disable mac sign test * Add workflow to test Gradle plugin * Fix custom jdk tests on Linux * Make Compose Gradle plugin build compatible with Configuration cache * Print tests summary * Remove unused code * Refactor tests configuration * Turn off parallel execution * Try adding windows runner * Turn off fail fast * Fix Windows test issues #2368 * Adjust default proguard rules The following rule is needed to fix tests on Windows: ``` -dontwarn org.graalvm.compiler.core.aarch64.AArch64NodeMatchRules_MatchStatementSet* ``` Other rules are just to make builds less noisy. Kotlin's `*.internal` packages often contain bytecode, which triggers ProGuard's notes. However, these notes are not actionable for most users, so we can ignore notes by default. #2393
- Loading branch information
1 parent
7e574a0
commit 382ad5b
Showing
23 changed files
with
448 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Test Gradle plugin | ||
on: | ||
pull_request: | ||
paths: | ||
- 'gradle-plugins/**' | ||
- '.github/workflows/gradle-plugin.yml' | ||
jobs: | ||
test-gradle-plugin: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-20.04, macos-12, windows-2022] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'corretto' | ||
java-version: '16' | ||
- name: Test Gradle plugin | ||
shell: bash | ||
run: | | ||
cd gradle-plugins | ||
./gradlew assemble | ||
./gradlew :compose:check --continue | ||
- name: Print summary | ||
shell: bash | ||
if: always() | ||
run: | | ||
cd gradle-plugins/compose/build/test-summary | ||
for SUMMARY_FILE in `find . -name "*.md"`; do | ||
FILE_NAME=`basename $SUMMARY_FILE` | ||
echo "## $FILE_NAME" >> $GITHUB_STEP_SUMMARY | ||
cat $SUMMARY_FILE >> $GITHUB_STEP_SUMMARY | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
gradle-plugins/buildSrc/src/main/kotlin/CheckJarPackagesTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. | ||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.file.RegularFile | ||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.provider.SetProperty | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.InputFile | ||
import org.gradle.api.tasks.TaskAction | ||
import java.util.* | ||
import java.util.zip.ZipFile | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Checks that every class in a [jarFile] matches one of [allowedPackagePrefixes] | ||
*/ | ||
abstract class CheckJarPackagesTask @Inject constructor( | ||
objects: ObjectFactory | ||
) : DefaultTask() { | ||
@get:InputFile | ||
val jarFile: Property<RegularFile> = objects.fileProperty() | ||
|
||
@get:Input | ||
val allowedPackagePrefixes: SetProperty<String> = objects.setProperty(String::class.java) | ||
|
||
@TaskAction | ||
fun run() { | ||
ZipFile(jarFile.get().asFile).use { zip -> | ||
checkJarContainsExpectedPackages(zip) | ||
} | ||
} | ||
|
||
private fun checkJarContainsExpectedPackages(jar: ZipFile) { | ||
val unexpectedClasses = arrayListOf<String>() | ||
val allowedPrefixes = allowedPackagePrefixes.get().map { it.replace(".", "/") } | ||
|
||
for (entry in jar.entries()) { | ||
if (entry.isDirectory || !entry.name.endsWith(".class")) continue | ||
|
||
if (allowedPrefixes.none { prefix -> entry.name.startsWith(prefix) }) { | ||
unexpectedClasses.add(entry.name) | ||
} | ||
} | ||
|
||
if (unexpectedClasses.any()) { | ||
error(buildString { | ||
appendLine("All classes in ${jar.name} must match allowed prefixes:") | ||
allowedPrefixes.forEach { | ||
appendLine(" * $it") | ||
} | ||
appendLine("Non-valid classes:") | ||
val unexpectedGroups = unexpectedClasses | ||
.groupByTo(TreeMap()) { it.substringBeforeLast("/") } | ||
for ((_, classes) in unexpectedGroups) { | ||
appendLine(" * ${classes.first()}") | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
|
32 changes: 32 additions & 0 deletions
32
gradle-plugins/buildSrc/src/main/kotlin/SerializeClasspathTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. | ||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.file.ConfigurableFileCollection | ||
import org.gradle.api.file.RegularFileProperty | ||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.api.tasks.InputFiles | ||
import org.gradle.api.tasks.OutputFile | ||
import org.gradle.api.tasks.TaskAction | ||
import java.io.File | ||
import javax.inject.Inject | ||
|
||
abstract class SerializeClasspathTask @Inject constructor( | ||
objects: ObjectFactory | ||
) : DefaultTask() { | ||
@get:InputFiles | ||
val classpathFileCollection: ConfigurableFileCollection = objects.fileCollection() | ||
|
||
@get:OutputFile | ||
val outputFile: RegularFileProperty = objects.fileProperty() | ||
|
||
@TaskAction | ||
fun run() { | ||
val classpath = classpathFileCollection.files.joinToString(File.pathSeparator) { it.absolutePath } | ||
val outputFile = outputFile.get().asFile | ||
outputFile.parentFile.mkdirs() | ||
outputFile.writeText(classpath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.