- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 39
 
Description
My toast tasks spent a lot of time repeatedly downloading language dependencies into, e.g., ~/.cargo/registry (Rust) and ~/.m2/ (Java / Clojure).
I've run into two problems trying to share these host dependency caches with containers.
Consider a task definition like:
image: ubuntu:22.04
tasks:
  compile-rust:
    dependencies:
      - install-rust
    mount_paths:
      - ~/.cargo/registry:/root/.cargo/registry
    command: |
      cargo buildProblem 1: Containers with mount_paths are not cachable.
Running toast compile-rust will fail with:
[ERROR] Unable to parse file /Users/dev/software/toast/scratch/toast.yml. Reason: Task compile-rust has mount_paths but does not disable caching. To fix this, set cache: false for this task.
I understand the intent here --- the contents of the mount_paths are untracked by toast and so in general caching build output could lead to reproducibility problems.
However, for the specific need of sharing the host's already-downloaded dependencies, it feels a bit different.
We're trusting language tooling (cargo, mvn, whatever) to handle downloading/validating libraries in a sensible way.
Since toast is already fine caching containers that download arbitrary stuff from the Internet (i.e., isn't aiming for bitwise-reproducible dependency tracking), it feels reasonable to ignore some of the "inputs" for the purposes of caching.
Perhaps we should break out this need out as a separate concept, say cache_paths.
Then we'd have:
input_paths: tracked by toast, for anything where content changes should re-run command (source code, dependency lockfiles, etc.)mount_paths: untracked by toast, for transient data used by commands that never "finish" (e.g., database server)cache_paths: untracked by toast, for data that a command will read/write and handle its own dependencies for.
Alternatively, we could allow specifying a "don't cache this" option for specific input paths or a "please allow caching" for containers that use mount_paths, but I think it'll be clearer to have an explicitly named concept.
Problem 2: Intended host paths vary.
I pulled a fast one with:
mount_paths:
  - ~/.cargo/registry:/root/.cargo/registry
It actually needs to be a path relative to the toast file (../../.cargo/registry) or an absolute one (/Users/kevin/.cargo/registry).
Unfortunately, both make it difficult to make toast-driven projects portable, since it'll force you to checkout the project to a specific folder or run as a specific user.
The obvious fix in this case is to write a bit of code to expand ~ into the executing user's home directory, though there be more general ways to solve this need (e.g., allowing for interpretation of environment variables in toast config values beyond just the command string).
If you agree that the need is in-scope for toast, I'm happy to submit PRs in the next few days.