Commit graph

40 commits

Author SHA1 Message Date
daz
07023d3e3e
Refactor input parameters
Moved reading of all input parameters into a common source: `input-params.ts`.
This centralized all input parameter reads, and allowed an improved implementation
of reading boolean parameters. In particular, the implementation now provides a default
value for a boolean input parameter that isn't declared for an action.
2023-06-06 10:47:56 -06:00
Daz DeBoer
eb126d771e
Update for Gradle 8.1 release
With Gradle 8.1, the configuration-cache has changed and is now stable. 
As a temporary measure, this commit disables save/restore of the configuration-cache
data to avoid issues until we can deal with this change properly.
2023-04-14 16:23:09 -06:00
Daz DeBoer
b49446f8e1
Improved cache reporting
- Fix count of saved entries
- Catch and report errors on save and restore
- Correctly report entries that are never requested
2022-08-16 16:37:17 -06:00
Daz DeBoer
3d091fa7a8
Move initscripts into src/resources/init-scripts 2022-06-11 09:33:38 -06:00
Daz DeBoer
7a15005377
Avoid printing "reason unknown" for extract entries
This was happening when the main Gradle User Home entry was not saved due to
having an unchanged cache key.

Fixes #309
2022-06-06 15:07:13 -06:00
Daz DeBoer
52ebf2721a
Allow daemons to run across workflow steps
Now that we are stopping all Gradle daemons in the post-job action,
we can allow daemon processes to be re-used across steps in a workflow job.

Fixes #113
2022-06-05 09:20:54 -06:00
Daz DeBoer
e644288a42
Use build-results file for root project dirs
Instead of using a separate mechanism and init script, reuse the information
captured in the build-results file.
2022-06-05 08:34:07 -06:00
Daz DeBoer
5203a0b09d
Capture build results when config-cache is enabled
When enabled, the configuration-cache will cause the build to fail when a
`buildFinished` listener is added. Instead, use a BuildService to listen for task
failures and to write the results on build completion.
2022-06-05 00:29:42 -06:00
Daz DeBoer
ae74c01440
Use a BuildService to always collect project root
Using `settingsEvaluated` meant that the project root was not recorded
when the build was run with a config-cache hit. This meant that the subsequent
build would not restore the config-cache, resulting in a cache miss.

In order to avoid issues running the init script on older versions of Gradle
the project-collection is extracted into a separate groovy file that is only
applied conditionally on Gradle 7 or higher.
2022-06-03 13:51:36 -06:00
Daz DeBoer
cde0632795
Update comment for accuracy 2022-06-03 07:50:08 -06:00
Daz DeBoer
143774290e
Add more details to cache summary report 2022-06-02 22:39:55 -06:00
Daz DeBoer
d95713bd5d
Extract init scripts into resource files 2022-06-02 11:53:33 -06:00
Daz DeBoer
28b774ebdb
Allow override of sections of cache key
These internal env vars are designed primarily for testing,
but may also prove useful for folks to experiment with more optimal
caching setups.
2022-05-29 09:32:24 -06:00
Daz DeBoer
7645e6e536
Replace emoji characters with markdown 2022-05-24 16:37:15 +02:00
Daz DeBoer
646074d659
Write build scan link to GHA job summary
The new Job Summary functionality permits better rendering of build
results, including clickable build scan links
2022-05-24 15:01:44 +02:00
Daz DeBoer
d63db6a05e
Remove unclickable buildScan link from failure
Build scan links will be rendered in GHA Job Summary.
2022-05-24 15:01:08 +02:00
Daz DeBoer
53e57a851c
Make Gradle Home detection compatible with MacOS
MacOS runners are initialized with a Gradle User Home directory including
the `~/.gradle/notifications` directory. This was causing the action to skip
restoring the Gradle User Home on MacOS.

This fix limits the pre-existing GUH check to the `~/.gradle/caches` directory
which isn't pre-initialized in the runner.

Fixes #155
2022-02-03 09:46:37 -07:00
Daz DeBoer
702bb97ecb
Do not overwrite existing gradle.properties 2022-01-24 15:18:11 -07:00
Daz DeBoer
f75a3e8436
Make build-scan notice a WARNING for failed builds 2022-01-21 08:09:32 -07:00
Daz DeBoer
08d5b40ca5
Add experimental support for 'cache-write-only'
There may be cases where it a "fresh" cache entry would be beneficial,
for example if the Gradle User Home cache entry grows over time.

This setting would run the build as if no prior cache entry exists.
2022-01-20 15:04:11 -07:00
Daz DeBoer
0a5ede19a9
Improve cache-reporting when entry already exists 2022-01-20 15:04:11 -07:00
Daz DeBoer
a23ac1d61c
Add experimental support for 'strict-match' caching
By default, the action will attempt to restore a Gradle User Home
cache entry from a different set of matrix inputs (or a different Job entirely)
if an existing entry is not found for the current Job (including matrix inputs).

By specifying the experimental `gradle-home-cache-strict-match` parameter, a user
can avoid this fuzzy matching and ensure that a job execution starts with an
empty Gradle User Home if no entry from a prior execution is found.
2022-01-20 15:03:54 -07:00
Daz DeBoer
7dee0f45c2
Fix check for pre-existing Gradle User Home 2022-01-17 14:44:32 -07:00
Daz DeBoer
3aa7bfe163
Initialize pre-existing Gradle User Home 2022-01-17 14:44:32 -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
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
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
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
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
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
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
Daz DeBoer
717db318c1
Fix logging of cache key for Gradle User Home 2021-10-31 20:49:29 -06:00
Daz DeBoer
472ac8a356
Report sizes of cache entries
Using the patched version of @actions/cache, we now report the total
size of cache entries restored/saved, as well as details of each one.
2021-10-30 13:45:39 -06:00
Daz DeBoer
d785346c8c
Use cache.description 2021-10-30 13:44:22 -06:00
Daz DeBoer
6ca4d4ade2
Improve formatting for caching report 2021-10-30 12:15:00 -06:00
Daz DeBoer
75cec40e58
Rename 'report' classes to 'listener'
- `CachingReport` -> `CacheListener`
- `CacheEntryReport` -> `CacheEntryListener`
2021-10-30 12:15:00 -06:00
Daz DeBoer
c317ccac62
Refactor: extract cache-base out of cache-utils 2021-10-30 12:15:00 -06:00