mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 17:12:51 +00:00
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:
commit
c000a0b58f
24 changed files with 124 additions and 51 deletions
10
.github/workflows/integTest-caching.yml
vendored
10
.github/workflows/integTest-caching.yml
vendored
|
@ -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
|
||||
|
|
67
.github/workflows/integTest-execution.yml
vendored
67
.github/workflows/integTest-execution.yml
vendored
|
@ -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')
|
||||
|
|
@ -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
|
||||
|
|
6
__tests__/samples/basic/.gitattributes
vendored
6
__tests__/samples/basic/.gitattributes
vendored
|
@ -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
|
||||
|
6
__tests__/samples/kotlin-dsl/.gitattributes
vendored
6
__tests__/samples/kotlin-dsl/.gitattributes
vendored
|
@ -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
|
||||
|
5
__tests__/samples/kotlin-dsl/.gitignore
vendored
5
__tests__/samples/kotlin-dsl/.gitignore
vendored
|
@ -1,5 +0,0 @@
|
|||
# Ignore Gradle project-specific cache directory
|
||||
.gradle
|
||||
|
||||
# Ignore Gradle build output directory
|
||||
build
|
10
__tests__/samples/no-wrapper-gradle-4/build.gradle
Normal file
10
__tests__/samples/no-wrapper-gradle-4/build.gradle
Normal 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()
|
||||
}
|
||||
|
8
__tests__/samples/no-wrapper-gradle-4/settings.gradle
Normal file
8
__tests__/samples/no-wrapper-gradle-4/settings.gradle
Normal 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}")
|
||||
}
|
12
__tests__/samples/no-wrapper-gradle-5/build.gradle
Normal file
12
__tests__/samples/no-wrapper-gradle-5/build.gradle
Normal 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
|
||||
}
|
||||
}
|
8
__tests__/samples/no-wrapper-gradle-5/settings.gradle
Normal file
8
__tests__/samples/no-wrapper-gradle-5/settings.gradle
Normal 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}")
|
||||
}
|
6
__tests__/samples/no-wrapper/.gitattributes
vendored
6
__tests__/samples/no-wrapper/.gitattributes
vendored
|
@ -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
|
||||
|
5
__tests__/samples/no-wrapper/.gitignore
vendored
5
__tests__/samples/no-wrapper/.gitignore
vendored
|
@ -1,5 +0,0 @@
|
|||
# Ignore Gradle project-specific cache directory
|
||||
.gradle
|
||||
|
||||
# Ignore Gradle build output directory
|
||||
build
|
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/main/index.js.map
vendored
2
dist/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue