Unverified Commit 33e91b63 authored by Daz DeBoer's avatar Daz DeBoer Committed by GitHub
Browse files

Cache Gradle distributions downloaded for a particular version (#58)

- Cache is separate from (but similar to) the wrapper distribution cache
- New 'distributions-cache-enabled' flag controls caching of all downloaded distributions
  (including wrapper distributions)
- Deprecated the 'wrapper-cache-enabled' flag for removal in v2
parent e4ec586f
Loading
Loading
Loading
Loading
+6 −4
Changes for README.md: 6 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -122,22 +122,24 @@ jobs:

This action provides 3 levels of caching to help speed up your GitHub Actions:

- `wrapper` caches the local [wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html) installation, saving time downloading and unpacking Gradle distributions ;
- `distributions` caches any downloaded Gradle zips, including any downloaded [wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html) versions, saving time downloading Gradle distributions ;
- `dependencies` caches the [dependencies](https://docs.gradle.org/current/userguide/dependency_resolution.html#sub:cache_copy), saving time downloading dependencies ;
- `configuration` caches the [build configuration](https://docs.gradle.org/nightly/userguide/configuration_cache.html), saving time configuring the build.

Only the first one, caching the wrapper installation, is enabled by default.
Only the first one, caching downloaded distributions, is enabled by default.
Future versions of this action will enable all caching by default.

You can control which level is enabled as follows:

```yaml
wrapper-cache-enabled: true
distributions-cache-enabled: true
dependencies-cache-enabled: true
configuration-cache-enabled: true
```

The wrapper installation cache is simple and can't be configured further.
NOTE: The `wrapper-cache-enabled` flag has been deprecated, replaced by `distributions-cache-enabled` which enables caching for all downloaded distributions, including Gradle wrapper downloads.

The distributions cache is simple and can't be configured further.

The dependencies and configuration cache will compute a cache key in a best effort manner.
Keep reading to learn how to better control how they work.
+4
Changes for action.yml: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -20,9 +20,13 @@ inputs:
  arguments:
    description: Gradle command line arguments, see gradle --help
    required: false
  distributions-cache-enabled:
    description: Whether caching downloaded Gradle distributions is enabled or not, default to 'true'
    required: false
  wrapper-cache-enabled:
    description: Whether caching wrapper installation is enabled or not, default to 'true'
    required: false
    deprecationMessage: Replaced by 'distributions-cache-enabled' which enables caching for all downloaded Gradle distributions
  dependencies-cache-enabled:
    description: Whether caching dependencies is enabled or not, default to 'false'
    required: false
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+10 −1
Changes for src/cache-wrapper.ts: 10 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -107,7 +107,16 @@ export function extractGradleWrapperSlugFromDistUri(
}

function isWrapperCacheDisabled(): boolean {
    return !github.inputBoolean('wrapper-cache-enabled', true)
    // Check if either 'distributions' or 'wrapper' cache has been disabled
    const wrapperCacheEnabled = github.inputBoolean(
        'wrapper-cache-enabled',
        true
    )
    const distributionsCacheEnabled = github.inputBoolean(
        'distributions-cache-enabled',
        true
    )
    return !wrapperCacheEnabled || !distributionsCacheEnabled
}

function getCacheKey(wrapperSlug: string): string {
Loading