Skip to content

Commit

Permalink
Configure Gradle local build cache, add build scans, and use gradle-c…
Browse files Browse the repository at this point in the history
…ache-action for GitHub CI

This commit configures local build cache, and it delegates
Gradle execution to burrunan/gradle-cache-action.

It unlocks fine-grained remote build cache with GitHub Actions backend
(=faster builds), and it adds error markers
(e.g. compilation errors right in the commit diffs)

See https://github.com/burrunan/gradle-cache-action#gradle-cache-action
  • Loading branch information
vlsi committed Aug 19, 2020
1 parent 602ef81 commit 40cbe52
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 14
- name: 'Test'
shell: bash
run: |
./gradlew --no-parallel build -x distTar -x distTarSource
- uses: burrunan/gradle-cache-action@v1
name: Test
with:
job-id: jdk14
multi-cache-enabled: false
arguments: --scan --no-parallel build -x distTar -x distTarSource

mac:
name: 'macOS (JDK 14)'
Expand All @@ -38,6 +40,9 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 14
- name: 'Test'
run: |
./gradlew --no-parallel build -x distTar -x distTarSource -Dskip.test_TestDNSCacheManager.testWithCustomResolverAnd1Server=true
- uses: burrunan/gradle-cache-action@v1
name: Test
with:
job-id: jdk14
multi-cache-enabled: false
arguments: --scan --no-parallel build -x distTar -x distTarSource -Dskip.test_TestDNSCacheManager.testWithCustomResolverAnd1Server=true
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ allprojects {
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
}

outputs.cacheIf("test outcomes sometimes depends on third-party systems, so we should not cache it for now") {
false
}

// Pass the property to tests
fun passProperty(name: String, default: String? = null) {
val value = System.getProperty(name) ?: default
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#

org.gradle.parallel=true
# Build cache can be disabled with --no-build-cache option
org.gradle.caching=true
#org.gradle.caching.debug=true

# See https://github.com/gradle/gradle/pull/11358 , https://issues.apache.org/jira/browse/INFRA-14923
# repository.apache.org does not yet support .sha256 and .sha512 checksums
systemProp.org.gradle.internal.publish.checksums.insecure=true
Expand Down
20 changes: 19 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ pluginManagement {
}
}

plugins {
`gradle-enterprise`
}

// This is the name of a current project
// Note: it cannot be inferred from the directory name as developer might clone JMeter to jmeter_tmp folder
rootProject.name = "jmeter"
Expand Down Expand Up @@ -92,6 +96,18 @@ if (property("localReleasePlugins").toBool(nullAs = false, blankAs = true, defau
includeBuild("../vlsi-release-plugins")
}

val isCiServer = System.getenv().containsKey("CI")

if (isCiServer) {
gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
tag("CI")
}
}
}

// Checksum plugin sources can be validated at https://github.com/vlsi/vlsi-release-plugins
buildscript {
dependencies {
Expand All @@ -107,6 +123,8 @@ buildscript {

// Note: we need to verify the checksum for checksum-dependency-plugin itself
val expectedSha512 = mapOf(
"F7040C571C2A2727F2EED4EA772F5A7C5D9CB393828B7A2331F7167E467429486F5F3E9423883FE9A6D652FFB0484EAE722CDFB46D97180209BCBEEBF9C25DE3"
to "gradle-enterprise-gradle-plugin-3.4.jar",
"43BC9061DFDECA0C421EDF4A76E380413920E788EF01751C81BDC004BD28761FBD4A3F23EA9146ECEDF10C0F85B7BE9A857E9D489A95476525565152E0314B5B"
to "bcpg-jdk15on-1.62.jar",
"2BA6A5DEC9C8DAC2EB427A65815EB3A9ADAF4D42D476B136F37CD57E6D013BF4E9140394ABEEA81E42FBDB8FC59228C7B85C549ED294123BF898A7D048B3BD95"
Expand Down Expand Up @@ -137,7 +155,7 @@ val violations =
.joinToString("\n ") { (file, sha512) -> "SHA-512(${file.name}) = $sha512 ($file)" }

if (violations.isNotBlank()) {
throw GradleException("Buildscript classpath has permitted files that were not explicitly permitted:\n $violations")
throw GradleException("Buildscript classpath has files that were not explicitly permitted:\n $violations")
}

apply(plugin = "com.github.vlsi.checksum-dependency")
Expand Down

0 comments on commit 40cbe52

Please sign in to comment.