act
act copied to clipboard
Enhancement: Automatically disable unsupported cache actions
I realize act
does not support jobs that use caching actions. However, for user convenience I wonder whether the work-arounds (by leveraging if: ${{ !env.ACT }}
) could be avoided by "patching" the original workflow definition.
For example, if there was some (e.g. regex based) search & replace logic, code like
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11
cache: gradle
could automatically be replaced with
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11
by omitting the final cache: gradle
. For for a more complex example, code like
- name: Build all classes
uses: burrunan/gradle-cache-action@v1
with:
arguments: --stacktrace classes -x :reporter-web-app:yarnBuild
could be replaced with
- name: Build all classes
run: ./gradlew --stacktrace classes -x :reporter-web-app:yarnBuild
Such a replace logic could either be built into act
directly, or be freely configurable via some configuration file.
This is way too much work and almost impossible to get right
As a workaround for the first example, you can set cache
conditionally:
- uses: actions/setup-node@v2
with:
cache: ${{ !env.ACT && 'npm' || '' }}
Note: Empty string is considered false
, so it can't be first value and this wouldn't work: ${{ env.ACT && '' || 'npm' }}
Plastering your workflow files with if: ${{ !env.ACT }}
is really not a solution, especially given the increasing number of tools that use caching or even how frequently just actions/cache
is used in ordinary workflows.
Would it not be possible to just stub this out such that it always returns a negative cache hit, and thus essentially just skips the caching altogether?
Since act is not only used for local execution this is not an option. Also, for example the setup-node action, does use the toolkit cache which could not be easily stubbed.
Instead it would be possible to implement chaching with the embedded artifact server. But that would be up for the requestors to implement.
But that would be up for the requestors to implement.
Any hints at what parts of the code base would need to get touched?
These: https://github.com/nektos/act/tree/master/pkg/artifacts :wink: