【问题标题】:How to effectively cache cargo/Rust projects in an Azure Build Pipeline如何在 Azure Build Pipeline 中有效地缓存 cargo/Rust 项目
【发布时间】:2022-08-05 16:54:54
【问题描述】:

我有一组 Azure Build Pipelines 编译 rust 项目,目前使用 blob 存储将 .cargotarget 文件夹存储为缓存。

在本地编译时,一旦第一次编译了二进制文件,后续cargo build\'s 不会再次编译依赖库/ crates,只是本地二进制文件,但是使用我当前的管道系统,在下载缓存并使用后要构建到正确的目标文件夹,管道仍然会下载并构建板条箱。

这是我用于缓存和任何管道构建的 config.toml。

[build]
target-dir = \"./target\"
dep-info-basedir = \".\"
incremental = true

在某些情况下,它减少了编译时间,但没有我预期的那么多。 我可以缓存更多文件夹以提高速度吗?是否有货物正在检查和污染缓存的缓存标识符?

管道运行自定义 xtask 二进制文件,该二进制文件执行许多任务,包括运行 cargo build --release 这会导致问题吗?

标签: caching rust azure-pipelines azure-blob-storage cargo


【解决方案1】:

您需要缓存 target~/.cargo/registry,正如 Caesar 在上面的 cmets 中提到的那样。

以下对我有用:

- task: Cache@2
  inputs:
    key: '"cargo" | "$(Agent.OS)" | Cargo.lock'
    path: $(Build.SourcesDirectory)\target
  displayName: cache cargo build

- task: Cache@2
  inputs:
    key: '"cargo-registry" | "$(Agent.OS)" | Cargo.lock'
    path: $(UserProfile)\.cargo\registry
  displayName: cache cargo registry

【讨论】:

    猜你喜欢
    • 2021-08-28
    • 2019-09-10
    • 2019-09-10
    • 1970-01-01
    • 2021-08-26
    • 1970-01-01
    • 2019-07-23
    • 1970-01-01
    • 2022-01-11
    相关资源
    最近更新 更多