Commit graph

764 commits

Author SHA1 Message Date
Daz DeBoer
f4e053dda1
Upgrade to reference actions/setup-java@v2
- Update all references in README.md
- Update version used in `pr-build-scan-comment`
- Discourage the use of `cache: gradle` with `setup-java@v2`
2022-01-16 16:18:09 -07:00
Benedikt Ritter
a7c463b44a
Update to latest version of actions/github-script
See https://github.com/marketplace/actions/github-script#breaking-changes-in-v5

* Update docs to latest github-script action version
* Update CI build to latest GitHub API
2022-01-16 15:45:15 -07:00
Daz DeBoer
42faf281e6
Include names of requested tasks in build scan notice
This should make it easier to differentiate between build scan notices for different
Gradle invocations in the same Job.

Fixes: #124
2021-12-31 10:34:53 -07:00
Daz DeBoer
13d93c1ca1
Check executable bit on Gradle script
Fixes #76
2021-12-30 21:40:27 -07:00
Daz DeBoer
3edb3cb004
Reorder inputs in metadata file for v2.1 2021-12-30 18:16:51 -07:00
Daz DeBoer
3609b7787a
Polish README for v2.1 2021-12-30 18:12:37 -07:00
Daz DeBoer
f804351b51
Merge pull request #131 from gradle/cache-jdks
- Cache downloaded Java Toolchains
- Treat configuration-cache entries as extracted entries
2021-12-30 16:19:02 -07:00
Daz DeBoer
39e51526fb
Build outputs 2021-12-30 16:03:02 -07:00
Daz DeBoer
76ea8a76b2
Treat configuration-cache as an extracted entry
Instead of using a fallback strategy to locate a configuration-cache entry
based on the current job and git SHA, these entries are now keyed based on their
file content with the keys persisted in the primary Gradle User Home entry.

This removes the chance of having a configuration-cache entry restored that is
incompatible with the restored Gradle User Home state, and makes the logic easier
to understand.

This change involved a fairly major refactor, with the CacheEntryExtractor being
split out from the primary cache implementation, and adding a separate extractor
implementation for configuration-cache.
2021-12-30 16:03:02 -07:00
Daz DeBoer
12fc52a49a
Combine java-toolchain entry definitions
- Remove configuration parameter for cache-entry-definitions. This allows richer modelling of extracted entries.
- Include both *.zip and *.tar.gz in entry definition for java-toolchains.
2021-12-30 16:03:02 -07:00
Daz DeBoer
c157d0a332
Cache downloaded Java Toolchains
Due to limitations with the way extracted entries are defined, a separate entry
is defined for *nix and windows.

Fixes #33
2021-12-30 16:02:02 -07:00
Daz DeBoer
c61f5d87b4
Test java-toolchain cache 2021-12-17 21:10:31 -07:00
Daz DeBoer
c208b4c1f7
Test caching with gradle-plugin project 2021-12-17 20:54:04 -07:00
Daz DeBoer
b4e6c2b28a
Minor improvements to README 2021-12-17 13:34:22 -07:00
Daz DeBoer
b84b650c31
Merge pull request #130 from gradle/setup-gradle
Allow action to be used without Gradle execution
2021-12-17 13:08:36 -07:00
Daz DeBoer
eda0038770
Reduce the number of automated comments left on PR 2021-12-17 10:49:41 -07:00
Daz DeBoer
ed5b4ae5dc
Verify GUH restore combined with Gradle execution 2021-12-17 10:44:29 -07:00
Daz DeBoer
d50632cfd1
Build outputs 2021-12-17 10:29:59 -07:00
Daz DeBoer
40c0a12211
Update README for use without Gradle execution 2021-12-17 10:29:59 -07:00
Daz DeBoer
e977669c8c
Update most test workflows to separate config from execution 2021-12-17 10:29:59 -07:00
Daz DeBoer
0e8b9655a0
Allow action to be used without Gradle invocation
If the user supplies no 'arguments' parameter, the action will function as a
'setup-gradle' action, adding Gradle to the PATH and enabling other features
without actually running a Gradle build.

Any subsequent Gradle invocations in the workflow will benefit from:
- Save/restore of Gradle User Home
- Save/restore of configuration-cache data
- Capture of build-scan URLs

These features are enabled via Gradle User Home, so any Gradle invocation that
uses the same Gradle User Home will be included.
2021-12-17 10:29:58 -07:00
Daz DeBoer
367ce74a5f
Merge pull request #128 from gradle/configuration-caching
Restore/save configuration-cache data in first action step. This will enable the use of the action for caching without managing all gradle invocations.
2021-12-17 10:28:09 -07:00
Daz DeBoer
3814d56740
Build outputs 2021-12-08 15:14:19 -07:00
Daz DeBoer
e1f84aa44d
Restore/save configuration-cache data in first action
Previously, the action was restoring/saving the configuration-cache data for each
step that applied the action. In order to support Gradle invocations that are _not_
managed by the action, the configuration-cache restore is now performed in the initial
action step, and save is performed in the final post-action step.

The build root directories are recorded for each invocation via an init script.
2021-12-08 15:09:27 -07:00
Daz DeBoer
1041604f29
Ensure save/restore only on first action step
Instead of relying on the separate cache implementations to check for the
existence of cached products, we now explicitly track whether or not the execution
is the first time the action has been invoked for a job.
2021-12-08 15:09:27 -07:00
Daz DeBoer
253d6427fd
Extract cache-reporting into separate file
Cache reporting is self-contained enough that it deserves some separation.
2021-12-08 15:09:26 -07:00
Daz DeBoer
69aad1f173
Test config-cache support for multiple builds in one job 2021-12-08 15:09:26 -07:00
Daz DeBoer
887e1a09ab
Include original error in log messages 2021-12-08 14:44:57 -07:00
Daz DeBoer
f344e25b84
Attempt to reduce duplicate workflows on PR creation 2021-12-08 14:20:13 -07:00
Daz DeBoer
574cf0ddce Build outputs 2021-12-08 14:05:13 -07:00
Daz DeBoer
37f2880a8a Cache wrapper zips and generated jars individually
Using a single cache entry for all files of a type is necessary to avoid
overloading the cache service. However, this mechanism is not very efficient
for certain artifacts like wrapper zips and generated-gradle-jars, where the
same individual files are often shared between different jobs.

With this change, any configured file patterns that do not end in '*' will
be cached as individual files. At this time this includes downloaded wrapper
zips and generated-gradle-jars.

Fixes #78
2021-12-08 14:05:13 -07:00
Daz DeBoer
b88c4086b9
Don't overwrite title in build-scan notice 2021-12-08 13:07:52 -07:00
Daz DeBoer
aa9bf7774e
Add build-scan comment to any PRs 2021-12-08 13:07:51 -07:00
Daz DeBoer
ed2ff1a448
Use a matrix for testing Gradle versions 2021-12-08 10:04:24 -07:00
Daz DeBoer
ddee3ca933
Update all outdated dependencies 2021-12-02 14:35:52 -07:00
Daz DeBoer
03d1894080
Update to build with NPM 8.1 2021-12-02 12:59:54 -07:00
Daz DeBoer
322805e800
Refactor: use a single .json file to describe all cached artifact bundles (#121)
This is a pure refactor, moving from a separate .cache file per bundle to a single cache-metadata.json file describing all bundles. Instead of storing cache metadata in a separate .cache file per artifact bundle, all of the metadata is now stored in a single `.json` file.

This will make it easier to implement more flexible artifact-caching strategies, such as caching each wrapper zip separately.

* Always include cache protocol version in cache key
* Store all cache metadata in a single JSON file
* Rename cache-metadata file and bump protocol version
* Polish and documentation
2021-11-28 10:19:56 -07:00
Daz DeBoer
92a1f98d35
Merge pull request #123 from gradle/toward-setup-gradle
Avoid using command-line modification to enhance build execution. Instead, files are written to Gradle User Home to achieve the same functionality.
2021-11-28 08:22:36 -07:00
Daz DeBoer
fdfc5bf12f
Build outputs 2021-11-28 08:04:54 -07:00
Daz DeBoer
a25c0ce6cb
Improve title on build scan notice 2021-11-28 08:04:54 -07:00
Daz DeBoer
76f85a724c
Record build scan url directly from init script
Instead of writing the URL to a file on disk, reading it later and
using the Actions API to record the output parameter and write the notice,
these things are now done directly via Actions commands emitted directly
from the init script.
2021-11-27 20:49:10 -07:00
Daz DeBoer
45ef022607
Always initialize Gradle User Home with init script
The generated gradle.properties file and init script are not cached,
so need to be generated even when restoring from cache.
2021-11-27 20:45:49 -07:00
Daz DeBoer
a72af0b6a6
Persist build-scan-capture init script into Gradle User Home
Instead of writing this file to a temp directory and referencing it
on the Gradle command line, the init script is now written to Gradle
User Home so that it is picked up automatically.
2021-11-27 20:44:43 -07:00
Daz DeBoer
b0c29bffb7
Use a properties file to disable daemon execution
Instead of passing `--no-daemon` on the command line, the same
functionality is now acheived by writing a gradle.properties file
when initializing Gradle User Home.
2021-11-27 16:07:07 -07:00
Daz DeBoer
996094e8e8
Avoid failing job on any failure in post-action
Failures to store cache entries should not fail the action or the Job.
This fix attempts to catch and log any unexpected errors that occur when
saving cache entries.

Fixes: #119
Fixes: #120
2021-11-15 09:31:56 -07:00
Daz DeBoer
4137be6a8b
Minor improvement to logging in post-action
- Ensure that "Caching Gradle state" group always has 1 message
- Only print cache report when entries were restored or saved
2021-11-05 08:35:45 -06:00
Daz DeBoer
4e899835b3
Avoid failing build on distributions cache errors
- Warn and continue on failure to restore a Gradle distribution from cache
- Warn and continue on failure to save a Gradle distribution to cache
- Extract common functionality for consistent handling of cache failures

Fixes #116
2021-11-05 07:01:48 -06:00
Jonathan Leitschuh
3812292b26
Add CodeQL Analysis (#114) 2021-11-02 09:56:02 -06:00
Daz DeBoer
c12283ec57
Add a section explaining advantages 2021-11-01 12:35:15 -06:00
Daz DeBoer
f2dc0d8256
Add section on optimizing cache effectiveness 2021-11-01 08:17:33 -06:00