mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-10-22 01:28:55 +08:00
Compare commits
9 Commits
v2.0-beta.
...
v2.0-beta.
Author | SHA1 | Date | |
---|---|---|---|
|
29894757f3 | ||
|
5328161026 | ||
|
4968d2280b | ||
|
c000a0b58f | ||
|
6ff498182a | ||
|
60b1ffac6b | ||
|
9b7c81f8f6 | ||
|
b650771559 | ||
|
17f624cb5b |
10
.github/workflows/integTest-caching.yml
vendored
10
.github/workflows/integTest-caching.yml
vendored
@@ -22,12 +22,12 @@ jobs:
|
|||||||
- name: Build using Gradle wrapper
|
- name: Build using Gradle wrapper
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
build-root-directory: __tests__/samples/basic
|
build-root-directory: __tests__/samples/groovy-dsl
|
||||||
arguments: test
|
arguments: test
|
||||||
- name: Build with configuration-cache enabled
|
- name: Build with configuration-cache enabled
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
build-root-directory: __tests__/samples/basic
|
build-root-directory: __tests__/samples/groovy-dsl
|
||||||
arguments: test --configuration-cache
|
arguments: test --configuration-cache
|
||||||
|
|
||||||
# Test that the gradle-user-home cache will cache dependencies, by running build with --offline
|
# 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
|
- name: Execute Gradle build with --offline
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
build-root-directory: __tests__/samples/basic
|
build-root-directory: __tests__/samples/groovy-dsl
|
||||||
arguments: test --offline
|
arguments: test --offline
|
||||||
cache-read-only: true
|
cache-read-only: true
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ jobs:
|
|||||||
- name: Execute Gradle build and verify tasks from cache
|
- name: Execute Gradle build and verify tasks from cache
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
build-root-directory: __tests__/samples/basic
|
build-root-directory: __tests__/samples/groovy-dsl
|
||||||
arguments: test -DverifyCachedBuild=true
|
arguments: test -DverifyCachedBuild=true
|
||||||
cache-read-only: true
|
cache-read-only: true
|
||||||
|
|
||||||
@@ -79,6 +79,6 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
VERIFY_CACHED_CONFIGURATION: true
|
VERIFY_CACHED_CONFIGURATION: true
|
||||||
with:
|
with:
|
||||||
build-root-directory: __tests__/samples/basic
|
build-root-directory: __tests__/samples/groovy-dsl
|
||||||
arguments: test --configuration-cache
|
arguments: test --configuration-cache
|
||||||
cache-read-only: true
|
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
|
- name: Test use defined Gradle executable
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
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
|
build-root-directory: __tests__/samples/no-wrapper
|
||||||
arguments: help -DgradleVersionCheck=7.1.1
|
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
|
- name: Build using Gradle wrapper
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
build-root-directory: __tests__/samples/basic
|
build-root-directory: __tests__/samples/groovy-dsl
|
||||||
arguments: test
|
arguments: test
|
||||||
|
|
||||||
# Test that the gradle-user-home cache will cache dependencies, by running build with --offline
|
# 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
|
- name: Execute Gradle build with --offline
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
build-root-directory: __tests__/samples/basic
|
build-root-directory: __tests__/samples/groovy-dsl
|
||||||
arguments: test --offline
|
arguments: test --offline
|
||||||
cache-read-only: true
|
cache-read-only: true
|
||||||
|
|
||||||
@@ -47,6 +47,6 @@ jobs:
|
|||||||
- name: Execute Gradle build and verify tasks from cache
|
- name: Execute Gradle build and verify tasks from cache
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
build-root-directory: __tests__/samples/basic
|
build-root-directory: __tests__/samples/groovy-dsl
|
||||||
arguments: test -DverifyCachedBuild=true
|
arguments: test -DverifyCachedBuild=true
|
||||||
cache-read-only: 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
2
dist/post/index.js
vendored
2
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js.map
vendored
2
dist/post/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
|
def isTopLevelBuild = gradle.getParent() == null
|
||||||
if (isTopLevelBuild) {
|
if (isTopLevelBuild) {
|
||||||
def version = GradleVersion.current().baseVersion
|
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")
|
def atLeastGradle6 = version >= GradleVersion.version("6.0")
|
||||||
|
|
||||||
if (atLeastGradle6) {
|
if (atLeastGradle6) {
|
||||||
settingsEvaluated { settings ->
|
settingsEvaluated { settings ->
|
||||||
if (settings.pluginManager.hasPlugin("com.gradle.enterprise")) {
|
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 ->
|
projectsEvaluated { gradle ->
|
||||||
if (gradle.rootProject.pluginManager.hasPlugin("com.gradle.build-scan")) {
|
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) {
|
def registerCallbacks(buildScanExtension, rootProjectName) {
|
||||||
gradleEnterprise.with {
|
buildScanExtension.with {
|
||||||
buildScan {
|
|
||||||
def scanFile = new File("gradle-build-scan.txt")
|
def scanFile = new File("gradle-build-scan.txt")
|
||||||
buildScanPublished { buildScan ->
|
buildScanPublished { buildScan ->
|
||||||
scanFile.text = buildScan.buildScanUri
|
scanFile.text = buildScan.buildScanUri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
return initScript
|
return initScript
|
||||||
|
@@ -5,7 +5,7 @@ import * as core from '@actions/core'
|
|||||||
import * as glob from '@actions/glob'
|
import * as glob from '@actions/glob'
|
||||||
import * as exec from '@actions/exec'
|
import * as exec from '@actions/exec'
|
||||||
|
|
||||||
import {AbstractCache, hashFileNames} from './cache-utils'
|
import {AbstractCache, hashFileNames, tryDelete} from './cache-utils'
|
||||||
|
|
||||||
// Which paths under Gradle User Home should be cached
|
// Which paths under Gradle User Home should be cached
|
||||||
const CACHE_PATH = ['caches', 'notifications']
|
const CACHE_PATH = ['caches', 'notifications']
|
||||||
@@ -141,7 +141,7 @@ export class GradleUserHomeCache extends AbstractCache {
|
|||||||
if (commonArtifactFiles.length === 0) {
|
if (commonArtifactFiles.length === 0) {
|
||||||
this.debug(`No files found to cache for ${bundle}`)
|
this.debug(`No files found to cache for ${bundle}`)
|
||||||
if (fs.existsSync(cacheMetaFile)) {
|
if (fs.existsSync(cacheMetaFile)) {
|
||||||
fs.unlinkSync(cacheMetaFile)
|
tryDelete(cacheMetaFile)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ export class GradleUserHomeCache extends AbstractCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const file of commonArtifactFiles) {
|
for (const file of commonArtifactFiles) {
|
||||||
fs.unlinkSync(file)
|
tryDelete(file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@ import * as cache from '@actions/cache'
|
|||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import * as crypto from 'crypto'
|
import * as crypto from 'crypto'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
import * as fs from 'fs'
|
||||||
|
|
||||||
export function isCacheDisabled(): boolean {
|
export function isCacheDisabled(): boolean {
|
||||||
return core.getBooleanInput('cache-disabled')
|
return core.getBooleanInput('cache-disabled')
|
||||||
@@ -60,6 +61,29 @@ export function hashFileNames(fileNames: string[]): string {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to delete a file, waiting to allow locks to be released
|
||||||
|
*/
|
||||||
|
export async function tryDelete(file: string): Promise<void> {
|
||||||
|
for (let count = 0; count < 3; count++) {
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(file)
|
||||||
|
return
|
||||||
|
} catch (error) {
|
||||||
|
if (count === 2) {
|
||||||
|
throw error
|
||||||
|
} else {
|
||||||
|
core.warning(String(error))
|
||||||
|
await delay(1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function delay(ms: number): Promise<void> {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, ms))
|
||||||
|
}
|
||||||
|
|
||||||
class CacheKey {
|
class CacheKey {
|
||||||
key: string
|
key: string
|
||||||
restoreKeys: string[]
|
restoreKeys: string[]
|
||||||
|
Reference in New Issue
Block a user