Skip to content

Commit

Permalink
perf: save cache as long as the installation step succeeds (#317)
Browse files Browse the repository at this point in the history
even if the entire job fails

use environment variable SETUP_TEXLIVE_ACTION_NO_CACHE_ON_FAILURE
to revert to the previous behavior
  • Loading branch information
teatimeguest committed Oct 7, 2024
1 parent 8172c9f commit 4efd0d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ You can also specify packages by file using the `package-file` input:
### Caching
By default, the action will save `TEXDIR` to cache using [`@actions/cache`].
This is done in the [post-process] of a successfully completed workflow,
so that, for example, LuaTeX font cache files generated in your jobs are
This is done in the [post-process] of a completed workflow job,
so that, for example, LuaTeX font cache files generated in your job are
also saved and restored as part of the cache entry.

If you have problems due to a corrupt cache entry,
Expand Down Expand Up @@ -414,10 +414,11 @@ The action reads the following environment variable:

<!-- U+200B ZERO WIDTH SPACE -->

| Name | Type | Description |
| ------------------------------------------------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <code>SETUP_TEXLIVE_ACTION_&#x200B;FORCE_UPDATE_CACHE</code> | String | Setting this to anything other than `0`, the action will use a [unique cache key each time][update-a-cache] to keep the cache up-to-date.<p /><blockquote>:warning:&ensp;Enabling this will consume more [cache space][cache-limits].</blockquote><p /> **Default:**&ensp;<var>unset</var> |
| [`NO_COLOR`](https://no-color.org/) | String | Disable color output. |
| Name | Type | Description |
| ------------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <code>SETUP_TEXLIVE_ACTION_&#x200B;FORCE_UPDATE_CACHE</code> | String | Setting this to anything other than `0`, the action will use a [unique cache key each time][update-a-cache] to keep the cache up-to-date.<p /><blockquote>:warning:&ensp;Enabling this will consume more [cache space][cache-limits].</blockquote> |
| <code>SETUP_TEXLIVE_ACTION_&#x200B;NO_CACHE_ON_FAILURE</code> | String | Setting this to anything other than `0`, no cache will be saved when a job fails. |
| [`NO_COLOR`](https://no-color.org/) | String | Disable color output. |

[cache-limits]: https://github.com/actions/cache#cache-limits
[update-a-cache]: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
Expand Down
10 changes: 9 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ runs:
using: node20
main: dist/index.mjs
post: dist/index.mjs
post-if: success()
# - Use `fromJSON` since there are no array literals.
# - Use `toJSON` for strict value comparison.
post-if: >-
contains(
fromJSON('["null", "\"0\""]'),
toJSON(env.SETUP_TEXLIVE_ACTION_NO_CACHE_ON_FAILURE)
)
&& !cancelled()
|| success()
branding:
color: green
icon: type

0 comments on commit 4efd0d1

Please sign in to comment.