feat(ir): add typed helper for Cache@2#1097
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a typed factory function
cache_step(key, path)forCache@2tosrc/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, andrestoreKeys.ADO Task Reference
Cache@2key(cache key,|-delimited),path(folder to cache)cacheHitVar(variable set on hit/inexact/miss),restoreKeys(newline-delimited fallback key prefixes)Usage example
Validation
cargo build --all-targetscargo test --bin ado-aw -- compile::ir::taskscargo clippy --all-targets --all-features --workspace -- -D warningsCreated by the ado-task-ir-contributor workflow.