Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Automatically disable unsupported cache actions #989

Open
sschuberth opened this issue Feb 9, 2022 · 7 comments
Open

Enhancement: Automatically disable unsupported cache actions #989

sschuberth opened this issue Feb 9, 2022 · 7 comments
Labels
kind/feature-request New feature or request

Comments

@sschuberth
Copy link

sschuberth commented Feb 9, 2022

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.

@catthehacker
Copy link
Member

This is way too much work and almost impossible to get right

@domaslasauskas
Copy link

domaslasauskas commented Mar 5, 2022

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' }}

@jamesdh
Copy link

jamesdh commented Jun 15, 2022

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?

@KnisterPeter
Copy link
Member

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.

@KnisterPeter
Copy link
Member

Instead it would be possible to implement chaching with the embedded artifact server.
But that would be up for the requestors to implement.

@sschuberth
Copy link
Author

But that would be up for the requestors to implement.

Any hints at what parts of the code base would need to get touched?

@KnisterPeter
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants