Skip to content

feat(ir): add typed helper for Cache@2#1097

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
feat/ir-cache-v2-task-cc8cdca91e31dd6d
Draft

feat(ir): add typed helper for Cache@2#1097
github-actions[bot] wants to merge 1 commit into
mainfrom
feat/ir-cache-v2-task-cc8cdca91e31dd6d

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Adds a typed factory function cache_step(key, path) for Cache@2 to src/compile/ir/tasks.rs.

Motivation

Previously, any compiler code that needed to emit a pipeline caching step had to hand-craft TaskStep::new("Cache@2", ...) with raw string inputs. This PR introduces a well-typed helper that makes required inputs explicit at the call site and documents optional inputs with a clear API.

Changes

  • src/compile/ir/tasks.rs: cache_step(key, path) factory function + three unit tests covering required inputs, cacheHitVar, and restoreKeys.

ADO Task Reference

Usage example

use crate::compile::ir::tasks::cache_step;

// Cache npm dependencies
steps.push(Step::Task(
    cache_step(
        "npm | \"$(Agent.OS)\" | package-lock.json",
        "$(Pipeline.Workspace)/.npm",
    )
    .with_input("cacheHitVar", "CACHE_RESTORED"),
));

Validation

  • cargo build --all-targets
  • cargo test --bin ado-aw -- compile::ir::tasks
  • cargo clippy --all-targets --all-features --workspace -- -D warnings

Created by the ado-task-ir-contributor workflow.

Generated by ADO Task IR Contributor · 498.1 AIC · ⌖ 20.1 AIC · ⊞ 36.9K ·

Add `cache_step(key, path)` factory function to `src/compile/ir/tasks.rs`
for the ADO `Cache@2` built-in task.

Required inputs are positional parameters:
- `key`  — the `|`-delimited cache key (e.g. `"npm | \"...\"`|
  `package-lock.json``).
- `path` — the folder to cache (absolute or relative to
  `$(System.DefaultWorkingDirectory)`).

Optional inputs are available via `.with_input(…)` on the returned
`TaskStep`:
- `cacheHitVar`  — variable set to `true`/`inexact`/`false` based on
  restoration outcome.
- `restoreKeys`  — newline-delimited fallback key prefixes.

Three unit tests cover the required-input baseline, `cacheHitVar`, and
`restoreKeys` optional inputs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants