mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-04-08 14:24:13 +02:00
Remove stop-daemon configuration flag and stop gradle daemon only if GRADLE_HOME is going to be cached
Signed-off-by: Ivan Milisavljevic <cartman.dev@gmail.com>
This commit is contained in:
parent
f96d30352c
commit
09bf8857de
4 changed files with 10 additions and 49 deletions
42
README.md
42
README.md
|
@ -135,44 +135,6 @@ The initial Action step will perform the Gradle setup.
|
||||||
arguments: check
|
arguments: check
|
||||||
```
|
```
|
||||||
|
|
||||||
### Stopping gradle daemon
|
|
||||||
|
|
||||||
All Gradle daemons will be stopped by default in the post action step.
|
|
||||||
It is possible to keep daemons alive between jobs by setting `stop-daemons` to `false`.
|
|
||||||
|
|
||||||
Note that this is not recommended and should be used only on non-ephemeral runners.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
distribution: temurin
|
|
||||||
java-version: 11
|
|
||||||
|
|
||||||
- name: Setup and execute Gradle 'test' task
|
|
||||||
uses: gradle/gradle-build-action@v2
|
|
||||||
with:
|
|
||||||
stop-daemons: false
|
|
||||||
arguments: test
|
|
||||||
|
|
||||||
build:
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
distribution: temurin
|
|
||||||
java-version: 11
|
|
||||||
|
|
||||||
- name: Setup and execute Gradle 'build' task
|
|
||||||
uses: gradle/gradle-build-action@v2
|
|
||||||
with:
|
|
||||||
stop-daemons: false
|
|
||||||
arguments: build
|
|
||||||
```
|
|
||||||
|
|
||||||
### Gradle command-line arguments
|
### Gradle command-line arguments
|
||||||
|
|
||||||
The `arguments` input can be used to pass arbitrary arguments to the `gradle` command line.
|
The `arguments` input can be used to pass arbitrary arguments to the `gradle` command line.
|
||||||
|
@ -244,6 +206,10 @@ Caching is enabled by default. You can disable caching for the action as follows
|
||||||
cache-disabled: true
|
cache-disabled: true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Stopping gradle daemon
|
||||||
|
By default, the action will stop all Gradle daemons in the post-action step before the state of Gradle User Home is cached.
|
||||||
|
|
||||||
|
If caching is unavailable or the cache is in read-only mode, the daemon will not be stopped and will continue running after the job is completed.
|
||||||
### Cache keys
|
### Cache keys
|
||||||
|
|
||||||
Distributions downloaded to satisfy a `gradle-version` parameter are stored outside of Gradle User Home and cached separately. The cache key is unique to the downloaded distribution and will not change over time.
|
Distributions downloaded to satisfy a `gradle-version` parameter are stored outside of Gradle User Home and cached separately. The cache key is unique to the downloaded distribution and will not change over time.
|
||||||
|
|
|
@ -53,11 +53,6 @@ inputs:
|
||||||
description: Path to the Gradle executable
|
description: Path to the Gradle executable
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
stop-daemons:
|
|
||||||
description: When 'true', Gradle daemon will be stopped after the build.
|
|
||||||
required: false
|
|
||||||
default: true
|
|
||||||
|
|
||||||
generate-job-summary:
|
generate-job-summary:
|
||||||
description: When 'false', no Job Summary will be generated for the Job.
|
description: When 'false', no Job Summary will be generated for the Job.
|
||||||
required: false
|
required: false
|
||||||
|
|
|
@ -61,7 +61,7 @@ export async function save(gradleUserHome: string, cacheListener: CacheListener)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldSaveCaches(): boolean {
|
export function shouldSaveCaches(): boolean {
|
||||||
if (isCacheDisabled()) {
|
if (isCacheDisabled()) {
|
||||||
core.info('Cache is disabled: will not save state for later builds.')
|
core.info('Cache is disabled: will not save state for later builds.')
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -8,12 +8,13 @@ import * as caches from './caches'
|
||||||
|
|
||||||
import {CacheListener} from './cache-reporting'
|
import {CacheListener} from './cache-reporting'
|
||||||
import {BuildResult, loadBuildResults, logJobSummary, writeJobSummary} from './job-summary'
|
import {BuildResult, loadBuildResults, logJobSummary, writeJobSummary} from './job-summary'
|
||||||
|
import {shouldSaveCaches} from "./caches";
|
||||||
|
import {isCacheReadOnly} from "./cache-utils";
|
||||||
|
|
||||||
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED'
|
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED'
|
||||||
const GRADLE_USER_HOME = 'GRADLE_USER_HOME'
|
const GRADLE_USER_HOME = 'GRADLE_USER_HOME'
|
||||||
const CACHE_LISTENER = 'CACHE_LISTENER'
|
const CACHE_LISTENER = 'CACHE_LISTENER'
|
||||||
const JOB_SUMMARY_ENABLED_PARAMETER = 'generate-job-summary'
|
const JOB_SUMMARY_ENABLED_PARAMETER = 'generate-job-summary'
|
||||||
const STOP_DAEMON_PARAMETER = 'stop-daemons'
|
|
||||||
|
|
||||||
function shouldGenerateJobSummary(): boolean {
|
function shouldGenerateJobSummary(): boolean {
|
||||||
// Check if Job Summary is supported on this platform
|
// Check if Job Summary is supported on this platform
|
||||||
|
@ -54,10 +55,9 @@ export async function complete(): Promise<void> {
|
||||||
|
|
||||||
const buildResults = loadBuildResults()
|
const buildResults = loadBuildResults()
|
||||||
|
|
||||||
// Stop gradle daemons
|
// Stop gradle daemons only if the state of GRADLE_HOME is going to be cached
|
||||||
const shouldStopDaemons = core.getBooleanInput(STOP_DAEMON_PARAMETER)
|
if (shouldSaveCaches() && !isCacheReadOnly()) {
|
||||||
if (shouldStopDaemons) {
|
core.info('Cache is going to be saved - Stopping all Gradle daemons')
|
||||||
core.info('Stopping all Gradle daemons')
|
|
||||||
await stopAllDaemons(getUniqueGradleHomes(buildResults))
|
await stopAllDaemons(getUniqueGradleHomes(buildResults))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue