Always execute Gradle with --no-daemon

The Gradle daemon is not useful for ephemeral builds, and the process
can hold file locks which interfere with cache entry generation.

In the case where multiple Gradle invocations occur in the same job,
we could provide a way for users to override this behaviour, taking care
of stopping any daemon process at the end of the job.
This commit is contained in:
Daz DeBoer 2021-08-27 06:56:16 -06:00
parent 986024f0b7
commit fa0c026e07
No known key found for this signature in database
GPG Key ID: DD6B9F0B06683D5D
2 changed files with 10 additions and 7 deletions

View File

@ -19,12 +19,12 @@ jobs:
uses: ./
with:
build-root-directory: __tests__/samples/basic
arguments: test --no-daemon
arguments: test
- name: Build with configuration-cache enabled
uses: ./
with:
build-root-directory: __tests__/samples/basic
arguments: test --no-daemon --configuration-cache
arguments: test --configuration-cache
gradle-execution:
needs: basic-build
@ -70,7 +70,7 @@ jobs:
uses: ./
with:
build-root-directory: __tests__/samples/basic
arguments: test --no-daemon
arguments: test
configuration-cache:
needs: basic-build
@ -85,7 +85,7 @@ jobs:
uses: ./
with:
build-root-directory: __tests__/samples/basic
arguments: test --configuration-cache --no-daemon
arguments: test --configuration-cache
read-only-cache:
needs: basic-build
@ -100,7 +100,7 @@ jobs:
uses: ./
with:
build-root-directory: __tests__/samples/basic
arguments: test --no-daemon
arguments: test
distributions-cache-enabled: read-only
gradle-user-home-cache-enabled: read-only
project-dot-gradle-cache-enabled: read-only
@ -110,7 +110,7 @@ jobs:
with:
gradle-version: 6.9
build-root-directory: __tests__/samples/basic
arguments: test --no-daemon
arguments: test
distributions-cache-enabled: false
gradle-user-home-cache-enabled: false
project-dot-gradle-cache-enabled: false

View File

@ -15,13 +15,16 @@ export async function run(): Promise<void> {
await caches.restore(buildRootDirectory)
try {
const args: string[] = parseCommandLineArguments()
args.push('--no-daemon')
const result = await execution.execute(
await resolveGradleExecutable(
workspaceDirectory,
buildRootDirectory
),
buildRootDirectory,
parseCommandLineArguments()
args
)
if (result.buildScanUrl) {