Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: Add new experiments setting. #987

Merged
merged 3 commits into from
Jul 31, 2023
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
2 changes: 0 additions & 2 deletions crates/core/test-utils/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ pub fn create_moon_command<T: AsRef<Path>>(path: T) -> assert_cmd::Command {
// Enable logging for code coverage
cmd.env("MOON_LOG", "trace");
cmd.env("PROTO_LOG", "trace");
// Feature flags
// cmd.env("MOON_DISABLE_OVERLAPPING_OUTPUTS", "true");
cmd
}

Expand Down
10 changes: 10 additions & 0 deletions nextgen/config/src/workspace/experiments_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use moon_common::cacheable;
use schematic::{env, Config};

cacheable!(
#[derive(Config, Debug)]
pub struct ExperimentsConfig {
#[setting(default = true, env = "MOON_DISABLE_OVERLAPPING_OUTPUTS", parse_env = env::parse_bool)]
pub task_output_boundaries: bool,
}
);
2 changes: 2 additions & 0 deletions nextgen/config/src/workspace/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod codeowners_config;
mod constraints_config;
mod experiments_config;
mod generator_config;
mod hasher_config;
mod notifier_config;
Expand All @@ -8,6 +9,7 @@ mod vcs_config;

pub use codeowners_config::*;
pub use constraints_config::*;
pub use experiments_config::*;
pub use generator_config::*;
pub use hasher_config::*;
pub use notifier_config::*;
Expand Down
3 changes: 3 additions & 0 deletions nextgen/config/src/workspace_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ pub struct WorkspaceConfig {
#[setting(nested)]
pub constraints: ConstraintsConfig,

#[setting(nested)]
pub experiments: ExperimentsConfig,

#[setting(extend, validate = validate::extends_string)]
pub extends: Option<String>,

Expand Down
6 changes: 2 additions & 4 deletions nextgen/project-graph/src/project_graph.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::project_graph_error::ProjectGraphError;
use miette::IntoDiagnostic;
use moon_common::path::WorkspaceRelativePathBuf;
use moon_common::{color, is_test_env, Id};
use moon_common::{color, Id};
use moon_config::DependencyScope;
use moon_project::Project;
use moon_project_expander::{ExpanderContext, ExpansionBoundaries, ProjectExpander};
Expand All @@ -15,7 +15,6 @@ use petgraph::Direction;
use rustc_hash::FxHashMap;
use serde::Serialize;
use starbase_utils::json;
use std::env;
use std::path::{Path, PathBuf};
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};
use tracing::{debug, trace};
Expand Down Expand Up @@ -66,8 +65,7 @@ impl ProjectGraph {
projects: Arc::new(RwLock::new(FxHashMap::default())),
workspace_root: workspace_root.to_owned(),
query_cache: OnceMap::new(),
check_boundaries: !is_test_env()
&& env::var("MOON_DISABLE_OVERLAPPING_OUTPUTS").is_err(),
check_boundaries: false,
}
}

Expand Down
13 changes: 8 additions & 5 deletions nextgen/project-graph/src/project_graph_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::project_graph_hash::ProjectGraphHash;
use crate::projects_locator::locate_projects_with_globs;
use async_recursion::async_recursion;
use moon_cache::CacheEngine;
use moon_common::is_test_env;
use moon_common::path::{to_virtual_string, WorkspaceRelativePath, WorkspaceRelativePathBuf};
use moon_common::{color, consts, Id};
use moon_config::{InheritedTasksManager, ToolchainConfig, WorkspaceConfig, WorkspaceProjects};
Expand Down Expand Up @@ -151,6 +152,7 @@ impl<'app> ProjectGraphBuilder<'app> {
pub async fn build(mut self) -> miette::Result<ProjectGraph> {
self.enforce_constraints()?;

let context = self.context.take().unwrap();
let mut nodes = FxHashMap::default();

for (id, index) in self.nodes {
Expand All @@ -172,11 +174,12 @@ impl<'app> ProjectGraphBuilder<'app> {
});
}

Ok(ProjectGraph::new(
self.graph,
nodes,
self.context.unwrap().workspace_root,
))
let mut graph = ProjectGraph::new(self.graph, nodes, context.workspace_root);

graph.check_boundaries =
!is_test_env() && context.workspace_config.experiments.task_output_boundaries;

Ok(graph)
}

/// Load a single project by name or alias into the graph.
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
- Graph edges now indicate the type of relationship: development, production, build, peer.
- Updated `moon project-graph --json` to include the fully expanded graph data.
- Identifiers (project names, file groups, etc) can now be prefixed with underscores (`_`).
- Added Poetry detection support for Python projects.
- Added an `experiments` setting to `.moon/workspace.yml`.
- **Tasks**
- Environment variables in `command` and `args` are now substituted.
- Task `deps` can now depend on tag targets (`#tag:task`).
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/project-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export interface PartialProjectConfig {
export interface DependencyConfig {
id: string;
scope: DependencyScope;
source: DependencySource | null;
source: DependencySource;
via: string | null;
}

Expand Down
12 changes: 12 additions & 0 deletions packages/types/src/workspace-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export interface PartialConstraintsConfig {
tagRelationships?: Record<string, string[]> | null;
}

export interface PartialExperimentsConfig {
/** @default true */
taskOutputBoundaries?: boolean | null;
}

export interface PartialGeneratorConfig {
templates?: string[] | null;
}
Expand Down Expand Up @@ -77,6 +82,7 @@ export interface PartialWorkspaceConfig {
$schema?: string | null;
codeowners?: PartialCodeownersConfig | null;
constraints?: PartialConstraintsConfig | null;
experiments?: PartialExperimentsConfig | null;
extends?: string | null;
generator?: PartialGeneratorConfig | null;
hasher?: PartialHasherConfig | null;
Expand All @@ -101,6 +107,11 @@ export interface ConstraintsConfig {
tagRelationships: Record<string, string[]>;
}

export interface ExperimentsConfig {
/** @default true */
taskOutputBoundaries: boolean;
}

export interface GeneratorConfig {
templates: string[];
}
Expand Down Expand Up @@ -151,6 +162,7 @@ export interface WorkspaceConfig {
$schema: string;
codeowners: CodeownersConfig;
constraints: ConstraintsConfig;
experiments: ExperimentsConfig;
extends: string | null;
generator: GeneratorConfig;
hasher: HasherConfig;
Expand Down
19 changes: 19 additions & 0 deletions website/docs/config/workspace.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,25 @@ dependsOn: ['components']
tags: ['react']
```

## `experiments`<VersionLabel version="1.11.0" />

<HeadingApiLink to="/api/types/interface/WorkspaceConfig#experiments" />

Enable or disable experiments that alter core functionality.

### `taskOutputBoundaries`

<HeadingApiLink to="/api/types/interface/ExperimentsConfig#taskOutputBoundaries" />

Enforces strict boundaries for task outputs and will error when multiple tasks write to the same
output location. This includes output globs that overlap with literal output file paths. Defaults to
`true`, and will be fully enabled by default in a future release.

```yaml title=".moon/workspace.yml" {2}
experiments:
taskOutputBoundaries: false
```

## `generator`

<HeadingApiLink to="/api/types/interface/WorkspaceConfig#generator" />
Expand Down
28 changes: 28 additions & 0 deletions website/static/schemas/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
}
]
},
"experiments": {
"anyOf": [
{
"$ref": "#/definitions/PartialExperimentsConfig"
},
{
"type": "null"
}
]
},
"extends": {
"anyOf": [
{
Expand Down Expand Up @@ -233,6 +243,24 @@
},
"additionalProperties": false
},
"PartialExperimentsConfig": {
"title": "PartialExperimentsConfig",
"type": "object",
"properties": {
"taskOutputBoundaries": {
"default": true,
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
},
"PartialGeneratorConfig": {
"title": "PartialGeneratorConfig",
"type": "object",
Expand Down