Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions crates/vt/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ pub struct RunFlags {
///
/// If you don't pass this flag, `VP_REMOTE_CACHE` selects the mode. If neither
/// is set, the mode is `read` when an endpoint is configured, or `off` otherwise.
// Accepted but hidden from help while remote caching is unreleased.
#[clap(long, hide = true)]
#[clap(long)]
pub remote_cache: Option<RemoteCacheMode>,

/// Maximum number of tasks to run concurrently. Defaults to 4.
Expand Down
48 changes: 46 additions & 2 deletions crates/vt_graph/run-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,35 @@ base: InputBase, };

export type InputBase = "package" | "workspace";

export type RemoteCacheConfig = {
/**
* Optional HTTP or HTTPS namespace endpoint. Overridden by
* `VP_REMOTE_CACHE_URL`; can be omitted when the endpoint is supplied via
* `VP_REMOTE_CACHE_URL` (for example, when configuring only `headers`).
*
* In a GitHub Actions job with `permissions: id-token: write`, uploads
* authenticate with a GitHub Actions OIDC token whose audience is the
* endpoint without a trailing slash.
*/
url?: string,
/**
* Custom HTTP headers sent on every remote cache request (`fetch`,
* `download`, and `store`) to whichever remote cache endpoint is active
* (including values configured in `vite.config.*` when the endpoint is
* overridden via `VP_REMOTE_CACHE_URL`), never on GitHub Actions OIDC
* token requests.
*
* Empty string values are preserved as valid HTTP header values (to omit a
* header when an env var is unset in `vite.config.*`, omit the key or set
* it to `undefined`).
* Overridden per header by `VP_REMOTE_CACHE_HEADER_<NAME>` env vars
* (because `_` maps to `-` in env var suffixes, configured headers
* containing literal `_` cannot be overridden via env).
* Setting an `Authorization` header suppresses automatic GitHub Actions
* OIDC.
*/
headers?: { [key in string]: string | undefined }, };

export type Task = {
/**
* Command to run, or an array of commands to run in order.
Expand Down Expand Up @@ -87,7 +116,18 @@ input?: Array<string | GlobWithBase | AutoTracking>,
* - `{auto: true}` enables automatic output tracking
* - Negative patterns (e.g. `"!dist/cache/**"`) exclude matched files
*/
output?: Array<string | GlobWithBase | AutoTracking>, };
output?: Array<string | GlobWithBase | AutoTracking>,
/**
* Whether this task can use the remote cache. Defaults to `true`.
*
* The remote cache is used only when these also hold:
* - Caching isn't turned off by `--no-cache` or the workspace root's `cache` setting.
* - An endpoint is set with `cache.remote.url` in the workspace root config or with
* `VP_REMOTE_CACHE_URL`.
* - Remote access isn't set to `off` with `--remote-cache` or `VP_REMOTE_CACHE`. It
* defaults to `read`, which downloads cached results without uploading new ones.
*/
remote?: boolean, };

export type TaskDefinition = Task | Command;

Expand All @@ -111,7 +151,11 @@ scripts?: boolean,
*
* Default: `true`
*/
tasks?: boolean, };
tasks?: boolean,
/**
* Remote cache shared by tasks in the workspace.
*/
remote?: RemoteCacheConfig, };

export type UserPackageDependency = {
/**
Expand Down
10 changes: 6 additions & 4 deletions crates/vt_graph/src/config/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ pub struct EnabledCacheConfig {
/// `VP_REMOTE_CACHE_URL`.
/// - Remote access isn't set to `off` with `--remote-cache` or `VP_REMOTE_CACHE`. It
/// defaults to `read`, which downloads cached results without uploading new ones.
// Parsed but left out of the public types while remote caching is unreleased.
#[cfg_attr(all(test, not(clippy)), ts(skip))]
pub remote: Option<bool>,
}

Expand Down Expand Up @@ -395,8 +393,6 @@ pub enum UserGlobalCacheConfig {
tasks: Option<bool>,

/// Remote cache shared by tasks in the workspace.
// Parsed but left out of the public types while remote caching is unreleased.
#[cfg_attr(all(test, not(clippy)), ts(skip))]
remote: Option<UserRemoteCacheConfig>,
},
}
Expand Down Expand Up @@ -475,6 +471,8 @@ impl ResolvedGlobalCacheConfig {

/// Remote cache settings in the workspace root's `cache` config.
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Eq)]
// TS derive macro generates code using std types that clippy disallows; skip derive during linting
#[cfg_attr(all(test, not(clippy)), derive(TS), ts(optional_fields, rename = "RemoteCacheConfig"))]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub struct UserRemoteCacheConfig {
/// Optional HTTP or HTTPS namespace endpoint. Overridden by
Expand All @@ -500,6 +498,10 @@ pub struct UserRemoteCacheConfig {
/// containing literal `_` cannot be overridden via env).
/// Setting an `Authorization` header suppresses automatic GitHub Actions
/// OIDC.
#[cfg_attr(
all(test, not(clippy)),
ts(optional, type = "{ [key in string]: string | undefined }")
)]
pub headers: Option<FxHashMap<Str, Secret>>,
}

Expand Down
Loading