Merge pull request #87 from gradle/dd/gradle-versions

Fix build-scan link detection with older build-scan plugins

Fixes #86
This commit is contained in:
Daz DeBoer 2021-09-29 15:15:24 -06:00 committed by GitHub
commit c000a0b58f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 124 additions and 51 deletions

View file

@ -22,12 +22,12 @@ jobs:
- name: Build using Gradle wrapper
uses: ./
with:
build-root-directory: __tests__/samples/basic
build-root-directory: __tests__/samples/groovy-dsl
arguments: test
- name: Build with configuration-cache enabled
uses: ./
with:
build-root-directory: __tests__/samples/basic
build-root-directory: __tests__/samples/groovy-dsl
arguments: test --configuration-cache
# Test that the gradle-user-home cache will cache dependencies, by running build with --offline
@ -43,7 +43,7 @@ jobs:
- name: Execute Gradle build with --offline
uses: ./
with:
build-root-directory: __tests__/samples/basic
build-root-directory: __tests__/samples/groovy-dsl
arguments: test --offline
cache-read-only: true
@ -60,7 +60,7 @@ jobs:
- name: Execute Gradle build and verify tasks from cache
uses: ./
with:
build-root-directory: __tests__/samples/basic
build-root-directory: __tests__/samples/groovy-dsl
arguments: test -DverifyCachedBuild=true
cache-read-only: true
@ -79,6 +79,6 @@ jobs:
env:
VERIFY_CACHED_CONFIGURATION: true
with:
build-root-directory: __tests__/samples/basic
build-root-directory: __tests__/samples/groovy-dsl
arguments: test --configuration-cache
cache-read-only: true

View file

@ -37,6 +37,71 @@ jobs:
- name: Test use defined Gradle executable
uses: ./
with:
gradle-executable: __tests__/samples/basic/gradlew${{ matrix.script-suffix }}
gradle-executable: __tests__/samples/groovy-dsl/gradlew${{ matrix.script-suffix }}
build-root-directory: __tests__/samples/no-wrapper
arguments: help -DgradleVersionCheck=7.1.1
gradle-versions:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: windows-latest
script-suffix: '.bat'
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Test Gradle 7
uses: ./
id: gradle7
with:
gradle-version: 7.2
build-root-directory: __tests__/samples/no-wrapper
arguments: help -DgradleVersionCheck=7.2
- name: Check Gradle 7 scan
if: ${{ !steps.gradle7.outputs.build-scan-url }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('No build scan detected')
- name: Test Gradle 6
uses: ./
id: gradle6
with:
gradle-version: 6.9
build-root-directory: __tests__/samples/no-wrapper
arguments: help -DgradleVersionCheck=6.9
- name: Check Gradle 6 scan
if: ${{ !steps.gradle6.outputs.build-scan-url }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('No build scan detected')
- name: Test Gradle 5
uses: ./
id: gradle5
with:
gradle-version: 5.6.4
build-root-directory: __tests__/samples/no-wrapper-gradle-5
arguments: help -DgradleVersionCheck=5.6.4
- name: Check Gradle 5 scan
if: ${{ !steps.gradle5.outputs.build-scan-url }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('No build scan detected')
- name: Test Gradle 4
uses: ./
id: gradle4
with:
gradle-version: 4.10.3
build-root-directory: __tests__/samples/no-wrapper-gradle-4
arguments: help -DgradleVersionCheck=4.10.3
- name: Check Gradle 4 scan
if: ${{ !steps.gradle4.outputs.build-scan-url }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('No build scan detected')

View file

@ -20,7 +20,7 @@ jobs:
- name: Build using Gradle wrapper
uses: ./
with:
build-root-directory: __tests__/samples/basic
build-root-directory: __tests__/samples/groovy-dsl
arguments: test
# Test that the gradle-user-home cache will cache dependencies, by running build with --offline
@ -33,7 +33,7 @@ jobs:
- name: Execute Gradle build with --offline
uses: ./
with:
build-root-directory: __tests__/samples/basic
build-root-directory: __tests__/samples/groovy-dsl
arguments: test --offline
cache-read-only: true
@ -47,6 +47,6 @@ jobs:
- name: Execute Gradle build and verify tasks from cache
uses: ./
with:
build-root-directory: __tests__/samples/basic
build-root-directory: __tests__/samples/groovy-dsl
arguments: test -DverifyCachedBuild=true
cache-read-only: true

View file

@ -1,6 +0,0 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

View file

@ -1,6 +0,0 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

View file

@ -1,5 +0,0 @@
# Ignore Gradle project-specific cache directory
.gradle
# Ignore Gradle build output directory
build

View file

@ -0,0 +1,10 @@
plugins {
id "com.gradle.build-scan" version "1.16"
}
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
publishAlways()
}

View file

@ -0,0 +1,8 @@
rootProject.name = 'no-wrapper'
println "Using Gradle version: ${gradle.gradleVersion}"
def gradleVersionCheck = System.properties.gradleVersionCheck
if (gradleVersionCheck && gradle.gradleVersion != gradleVersionCheck) {
throw new RuntimeException("Got the wrong version: expected ${gradleVersionCheck} but was ${gradle.gradleVersion}")
}

View file

@ -0,0 +1,12 @@
plugins {
id("com.gradle.build-scan") version("3.7")
}
gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
publishAlways()
uploadInBackground = false
}
}

View file

@ -0,0 +1,8 @@
rootProject.name = 'no-wrapper'
println "Using Gradle version: ${gradle.gradleVersion}"
def gradleVersionCheck = System.properties.gradleVersionCheck
if (gradleVersionCheck && gradle.gradleVersion != gradleVersionCheck) {
throw new RuntimeException("Got the wrong version: expected ${gradleVersionCheck} but was ${gradle.gradleVersion}")
}

View file

@ -1,6 +0,0 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

View file

@ -1,5 +0,0 @@
# Ignore Gradle project-specific cache directory
.gradle
# Ignore Gradle build output directory
build

2
dist/main/index.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -18,34 +18,32 @@ import org.gradle.util.GradleVersion
def isTopLevelBuild = gradle.getParent() == null
if (isTopLevelBuild) {
def version = GradleVersion.current().baseVersion
def atLeastGradle5 = version >= GradleVersion.version("5.0")
def atLeastGradle4 = version >= GradleVersion.version("4.0")
def atLeastGradle6 = version >= GradleVersion.version("6.0")
if (atLeastGradle6) {
settingsEvaluated { settings ->
if (settings.pluginManager.hasPlugin("com.gradle.enterprise")) {
registerCallbacks(settings.extensions["gradleEnterprise"], settings.rootProject.name)
registerCallbacks(settings.extensions["gradleEnterprise"].buildScan, settings.rootProject.name)
}
}
} else if (atLeastGradle5) {
} else if (atLeastGradle4) {
projectsEvaluated { gradle ->
if (gradle.rootProject.pluginManager.hasPlugin("com.gradle.build-scan")) {
registerCallbacks(gradle.rootProject.extensions["gradleEnterprise"], gradle.rootProject.name)
registerCallbacks(gradle.rootProject.extensions["buildScan"], gradle.rootProject.name)
}
}
}
}
def registerCallbacks(gradleEnterprise, rootProjectName) {
gradleEnterprise.with {
buildScan {
def registerCallbacks(buildScanExtension, rootProjectName) {
buildScanExtension.with {
def scanFile = new File("gradle-build-scan.txt")
buildScanPublished { buildScan ->
scanFile.text = buildScan.buildScanUri
}
}
}
}
`
)
return initScript