Skip to content

Cache shell evaluation result #23

@YorikSar

Description

@YorikSar

Is your feature request related to a problem? Please describe.
If the script running in the shell is quite fast, shell evaluation can take the most of the runtime, especially if one job has multiple scripts running with the same shell. I have a project with a shell that takes ~10s to evaluate and 4 steps running in the shell. It means that even if the actions themselves only check if build results are in cache and take less than a second, job runtime is at least 40s because of the shell evaluation.

Describe the solution you'd like
I think we could have an option to cache evaluation result from the shell, possibly keyed to the hash of the shell.nix/default.nix. It could be off by default. It could also be set by the user to the hash generated by {{ hashFiles('default.nix') }} so that we don't have to guess what to hash.

Describe alternatives you've considered
I could do something along the lines of:

- name: eval-shell 
  run: |
    echo "drv=$(nix-instantiate shell.nix)" >> "$GITHUB_OUTPUT"
- uses: tweag/run-nix-shell@v0
  with:
    derivation-path: ${{ steps.eval-shell.outputs.drv }}
    run: |
      true

But it would be nice to have it integrated (and possibly invisible) in the action itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions