diff --git a/.moon/workspace.yml b/.moon/workspace.yml index 0606f6ab054..57f5a6b637c 100644 --- a/.moon/workspace.yml +++ b/.moon/workspace.yml @@ -16,7 +16,7 @@ projects: - '!packages/core-*' - 'website' -actionRunner: +runner: logRunningCommand: true vcs: diff --git a/crates/action-runner/src/actions/run_target.rs b/crates/action-runner/src/actions/run_target.rs index 1022da1f1e2..0a8b7db5285 100644 --- a/crates/action-runner/src/actions/run_target.rs +++ b/crates/action-runner/src/actions/run_target.rs @@ -306,12 +306,7 @@ impl<'a> TargetRunner<'a> { command.args(&context.passthrough_args); } - if self - .workspace - .config - .action_runner - .inherit_colors_for_piped_tasks - { + if self.workspace.config.runner.inherit_colors_for_piped_tasks { command.inherit_colors(); } @@ -470,7 +465,7 @@ impl<'a> TargetRunner<'a> { } pub fn print_target_command(&self, passthrough_args: &[String]) { - if !self.workspace.config.action_runner.log_running_command { + if !self.workspace.config.runner.log_running_command { return; } diff --git a/crates/action-runner/src/runner.rs b/crates/action-runner/src/runner.rs index 42fd1a001ce..3ae009503fa 100644 --- a/crates/action-runner/src/runner.rs +++ b/crates/action-runner/src/runner.rs @@ -372,7 +372,7 @@ impl ActionRunner { workspace .cache - .clean_stale_cache(&workspace.config.action_runner.cache_lifetime) + .clean_stale_cache(&workspace.config.runner.cache_lifetime) .await?; Ok(()) diff --git a/crates/cli/tests/run_test.rs b/crates/cli/tests/run_test.rs index e73858767df..87653c861bc 100644 --- a/crates/cli/tests/run_test.rs +++ b/crates/cli/tests/run_test.rs @@ -75,7 +75,7 @@ mod general { fn logs_command_for_project_root() { let fixture = create_sandbox_with_git("cases"); - append_workspace_config(fixture.path(), "actionRunner:\n logRunningCommand: true"); + append_workspace_config(fixture.path(), "runner:\n logRunningCommand: true"); let assert = create_moon_command(fixture.path()) .arg("run") @@ -89,7 +89,7 @@ mod general { fn logs_command_for_workspace_root() { let fixture = create_sandbox_with_git("cases"); - append_workspace_config(fixture.path(), "actionRunner:\n logRunningCommand: true"); + append_workspace_config(fixture.path(), "runner:\n logRunningCommand: true"); let assert = create_moon_command(fixture.path()) .arg("run") diff --git a/crates/config/src/workspace/config.rs b/crates/config/src/workspace/config.rs index 49c833d1552..a7de8e7a611 100644 --- a/crates/config/src/workspace/config.rs +++ b/crates/config/src/workspace/config.rs @@ -5,9 +5,9 @@ use crate::helpers::gather_extended_sources; use crate::providers::url::Url; use crate::types::{FileGlob, FilePath}; use crate::validators::{validate_child_relative_path, validate_extends, validate_id}; -use crate::workspace::action_runner::ActionRunnerConfig; use crate::workspace::hasher::HasherConfig; use crate::workspace::node::NodeConfig; +use crate::workspace::runner::RunnerConfig; use crate::workspace::typescript::TypeScriptConfig; use crate::workspace::vcs::VcsConfig; use crate::ConfigError; @@ -63,9 +63,6 @@ impl Default for WorkspaceProjects { #[schemars(default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceConfig { - #[validate] - pub action_runner: ActionRunnerConfig, - #[validate(custom = "validate_extends")] pub extends: Option, @@ -78,6 +75,9 @@ pub struct WorkspaceConfig { #[validate(custom = "validate_projects")] pub projects: WorkspaceProjects, + #[validate] + pub runner: RunnerConfig, + #[validate] pub typescript: Option, diff --git a/crates/config/src/workspace/mod.rs b/crates/config/src/workspace/mod.rs index 3a045aebb0a..eb39069bb5c 100644 --- a/crates/config/src/workspace/mod.rs +++ b/crates/config/src/workspace/mod.rs @@ -1,13 +1,13 @@ -mod action_runner; mod config; mod hasher; mod node; +mod runner; mod typescript; mod vcs; -pub use action_runner::*; pub use config::*; pub use hasher::*; pub use node::*; +pub use runner::*; pub use typescript::*; pub use vcs::*; diff --git a/crates/config/src/workspace/action_runner.rs b/crates/config/src/workspace/runner.rs similarity index 84% rename from crates/config/src/workspace/action_runner.rs rename to crates/config/src/workspace/runner.rs index 867ff186a42..52f5277e05c 100644 --- a/crates/config/src/workspace/action_runner.rs +++ b/crates/config/src/workspace/runner.rs @@ -19,7 +19,7 @@ fn validate_cache_lifetime(value: &str) -> Result<(), ValidationError> { #[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize, Validate)] #[schemars(default)] #[serde(rename_all = "camelCase")] -pub struct ActionRunnerConfig { +pub struct RunnerConfig { #[validate(custom = "validate_cache_lifetime")] pub cache_lifetime: String, @@ -30,9 +30,9 @@ pub struct ActionRunnerConfig { pub log_running_command: bool, } -impl Default for ActionRunnerConfig { +impl Default for RunnerConfig { fn default() -> Self { - ActionRunnerConfig { + RunnerConfig { cache_lifetime: "7 days".to_owned(), implicit_inputs: string_vec![ // When a project changes @@ -57,12 +57,12 @@ mod tests { }; use std::path::PathBuf; - const CONFIG_FILENAME: &str = "action-runner.yml"; + const CONFIG_FILENAME: &str = "runner.yml"; - fn load_jailed_config() -> Result { - let figment = Figment::from(Serialized::defaults(ActionRunnerConfig::default())) + fn load_jailed_config() -> Result { + let figment = Figment::from(Serialized::defaults(RunnerConfig::default())) .merge(Yaml::file(&PathBuf::from(CONFIG_FILENAME))); - let config: ActionRunnerConfig = figment.extract()?; + let config: RunnerConfig = figment.extract()?; config .validate() diff --git a/crates/config/tests/workspace_test.rs b/crates/config/tests/workspace_test.rs index 68191a1d07d..0554dd69f84 100644 --- a/crates/config/tests/workspace_test.rs +++ b/crates/config/tests/workspace_test.rs @@ -1,6 +1,6 @@ use moon_config::{ - ActionRunnerConfig, ConfigError, HasherConfig, NodeConfig, VcsConfig, VcsManager, - WorkspaceConfig, WorkspaceProjects, + ConfigError, HasherConfig, NodeConfig, RunnerConfig, VcsConfig, VcsManager, WorkspaceConfig, + WorkspaceProjects, }; use moon_constants::CONFIG_WORKSPACE_FILENAME; use moon_utils::test::get_fixtures_dir; @@ -27,7 +27,7 @@ fn loads_defaults() { assert_eq!( config, WorkspaceConfig { - action_runner: ActionRunnerConfig::default(), + runner: RunnerConfig::default(), extends: None, hasher: HasherConfig::default(), node: None, @@ -56,10 +56,10 @@ mod extends { assert_eq!( config, WorkspaceConfig { - action_runner: ActionRunnerConfig { + runner: RunnerConfig { cache_lifetime: "3 hours".into(), log_running_command: false, - ..ActionRunnerConfig::default() + ..RunnerConfig::default() }, node: Some(NodeConfig { version: "4.5.6".into(), @@ -286,7 +286,7 @@ node: assert_eq!( config, WorkspaceConfig { - action_runner: ActionRunnerConfig::default(), + runner: RunnerConfig::default(), extends: None, hasher: HasherConfig::default(), node: Some(NodeConfig { @@ -786,7 +786,7 @@ vcs: assert_eq!( config, WorkspaceConfig { - action_runner: ActionRunnerConfig::default(), + runner: RunnerConfig::default(), extends: None, hasher: HasherConfig::default(), node: None, // NodeConfig::default(), diff --git a/crates/project-graph/src/graph.rs b/crates/project-graph/src/graph.rs index 5b480319e40..847bbca248d 100644 --- a/crates/project-graph/src/graph.rs +++ b/crates/project-graph/src/graph.rs @@ -295,7 +295,7 @@ impl ProjectGraph { // Expand all tasks for the project (this must happen last) project.expand_tasks( &self.workspace_root, - &self.workspace_config.action_runner.implicit_inputs, + &self.workspace_config.runner.implicit_inputs, )?; Ok(project) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index a484e0c823c..92aaa674a43 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -7,6 +7,7 @@ - The `node` setting in `.moon/workspace.yml` is now optional, allowing repos to opt-out of Node.js support (in preparation for future languages support). This shouldn't affect you if the setting is already explicitly defined. +- Renamed `actionRunner` setting to `runner` in `.moon/workspace.yml`. #### 🚀 Updates diff --git a/tests/fixtures/config-extends/workspace/base-0.yml b/tests/fixtures/config-extends/workspace/base-0.yml index 853b9f71472..f374671b6cc 100644 --- a/tests/fixtures/config-extends/workspace/base-0.yml +++ b/tests/fixtures/config-extends/workspace/base-0.yml @@ -1,4 +1,4 @@ -actionRunner: +runner: cacheLifetime: '3 hours' node: diff --git a/tests/fixtures/config-extends/workspace/base-1.yml b/tests/fixtures/config-extends/workspace/base-1.yml index d7cb4eb938b..bb49a35b4b9 100644 --- a/tests/fixtures/config-extends/workspace/base-1.yml +++ b/tests/fixtures/config-extends/workspace/base-1.yml @@ -1,6 +1,6 @@ extends: './base-0.yml' -actionRunner: +runner: logRunningCommand: true node: diff --git a/tests/fixtures/config-extends/workspace/base-2.yml b/tests/fixtures/config-extends/workspace/base-2.yml index cc781553c09..11734862b16 100644 --- a/tests/fixtures/config-extends/workspace/base-2.yml +++ b/tests/fixtures/config-extends/workspace/base-2.yml @@ -1,6 +1,6 @@ extends: './base-1.yml' -actionRunner: +runner: logRunningCommand: false node: diff --git a/website/blog/2022-09-01_v0.13.md b/website/blog/2022-09-01_v0.13.md index b71f3758aa5..e418ecee63e 100644 --- a/website/blog/2022-09-01_v0.13.md +++ b/website/blog/2022-09-01_v0.13.md @@ -29,3 +29,23 @@ At moon, we believe in providing consumers with the ability to configure to thei such, have added a new [`hasher`](../docs/config/workspace#hasher) setting to [`.moon/workspace.yml`](../docs/config/workspace). This setting will allow you to choose between the 2 hashing patterns above! + +## Other changes + +View the +[official release](https://github.com/moonrepo/moon/releases/tag/%40moonrepo%2Fcli%400.13.0) for a +full list of changes. + +- The runner will now fail with an error if a task has defined `outputs` but an output was not + created after the task is executed. This change was made so that artifacts are deterministic. +- The `actionRunner` setting in [`.moon/workspace.yml`](../docs/config/workspace) was renamed to + `runner`. + +## What's next? + +Expect the following in the next v0.14 release! + +- A `moon new` command to generate new projects, files, scaffolding, and more from pre-defined + templates. +- Implicit dependency discovery. Moon will now scan manifest files and determine project + relationships. diff --git a/website/docs/commands/overview.mdx b/website/docs/commands/overview.mdx index 88bae849240..1933e507382 100644 --- a/website/docs/commands/overview.mdx +++ b/website/docs/commands/overview.mdx @@ -66,7 +66,7 @@ However, many tools and CLIs support a `--color` option to work around this limi force colors, even when not a TTY. To mitigate this problem as a whole, and to avoid requiring `--color` for every task, moon supports -the [`actionRunner.inheritColorsForPipedTasks`](../config/workspace#inheritcolorsforpipedtasks) +the [`runner.inheritColorsForPipedTasks`](../config/workspace#inheritcolorsforpipedtasks) configuration setting. When enabled, all piped child processes will inherit the color settings of the currently running terminal. diff --git a/website/docs/config/workspace.mdx b/website/docs/config/workspace.mdx index e78796771c3..4b7ac5f02db 100644 --- a/website/docs/config/workspace.mdx +++ b/website/docs/config/workspace.mdx @@ -424,13 +424,33 @@ Would result in the following `references` within both `tsconfig.json`s. ## Features -## `actionRunner` +## `hasher` + +> `HasherConfig` + +Configures aspects of smart hashing layer. + +### `optimization` + +Determines the optimization level to utilize when hashing content before running targets. + +- `accuracy` (default) - When hashing dependency versions, utilize the resolved value in the + lockfile. This requires parsing the lockfile, which may reduce performance. +- `performance` - When hashing dependency versions, utilize the value defined in the manifest. This + is typically a version range or requirement. + +```yaml title=".moon/workspace.yml" {2} +hasher: + optimization: 'performance' +``` + +## `runner` -> `ActionRunnerConfig` +> `RunnerConfig` Configures aspects of the action runner. -### `cacheLifetime` +### `cacheLifetime` > `string` @@ -439,11 +459,11 @@ the action runner. Defaults to "7 days". This field requires an integer and a ti can be [parsed as a duration](https://docs.rs/humantime/2.1.0/humantime/fn.parse_duration.html). ```yaml title=".moon/workspace.yml" {2} -actionRunner: +runner: cacheLifetime: '24 hours' ``` -### `implicitInputs` +### `implicitInputs` > `string[]` @@ -456,7 +476,7 @@ Like `inputs`, file paths/globs defined here are relative from the inheriting pr supported and encouraged. ```yaml title=".moon/workspace.yml" {2-5} -actionRunner: +runner: implicitInputs: - 'package.json' - '/.moon/project.yml' @@ -476,7 +496,7 @@ and their output is piped to the action runner. Defaults to `true`. [View more about color handling in moon](../commands/overview#colors). ```yaml title=".moon/workspace.yml" {2} -actionRunner: +runner: inheritColorsForPipedTasks: true ``` @@ -488,30 +508,10 @@ When enabled, will log the task's command, resolved arguments, and working direc is ran. Defaults to `false`. ```yaml title=".moon/workspace.yml" {2} -actionRunner: +runner: logRunningCommand: true ``` -## `hasher` - -> `HasherConfig` - -Configures aspects of smart hashing layer. - -### `optimization` - -Determines the optimization level to utilize when hashing content before running targets. - -- `accuracy` (default) - When hashing dependency versions, utilize the resolved value in the - lockfile. This requires parsing the lockfile, which may reduce performance. -- `performance` - When hashing dependency versions, utilize the value defined in the manifest. This - is typically a version range or requirement. - -```yaml title=".moon/workspace.yml" {2} -hasher: - optimization: 'performance' -``` - ## `vcs` > `VcsConfig` diff --git a/website/static/schemas/workspace.json b/website/static/schemas/workspace.json index 1ab3500a7fe..82249e6e970 100644 --- a/website/static/schemas/workspace.json +++ b/website/static/schemas/workspace.json @@ -4,23 +4,6 @@ "description": "Docs: https://moonrepo.dev/docs/config/workspace", "type": "object", "properties": { - "actionRunner": { - "default": { - "cacheLifetime": "7 days", - "implicitInputs": [ - "package.json", - "/.moon/project.yml", - "/.moon/workspace.yml" - ], - "inheritColorsForPipedTasks": true, - "logRunningCommand": false - }, - "allOf": [ - { - "$ref": "#/definitions/ActionRunnerConfig" - } - ] - }, "extends": { "default": null, "type": [ @@ -28,26 +11,24 @@ "null" ] }, - "node": { + "hasher": { "default": { - "addEnginesConstraint": true, - "aliasPackageNames": null, - "dedupeOnLockfileChange": true, - "dependencyVersionFormat": "workspace-caret", - "inferTasksFromScripts": false, - "npm": { - "version": "inherit" - }, - "packageManager": "npm", - "pnpm": null, - "syncProjectWorkspaceDependencies": true, - "syncVersionManagerConfig": null, - "version": "16.16.0", - "yarn": null + "optimization": "accuracy" }, "allOf": [ + { + "$ref": "#/definitions/HasherConfig" + } + ] + }, + "node": { + "default": null, + "anyOf": [ { "$ref": "#/definitions/NodeConfig" + }, + { + "type": "null" } ] }, @@ -59,6 +40,23 @@ } ] }, + "runner": { + "default": { + "cacheLifetime": "7 days", + "implicitInputs": [ + "package.json", + "/.moon/project.yml", + "/.moon/workspace.yml" + ], + "inheritColorsForPipedTasks": true, + "logRunningCommand": false + }, + "allOf": [ + { + "$ref": "#/definitions/RunnerConfig" + } + ] + }, "typescript": { "default": null, "anyOf": [ @@ -83,34 +81,26 @@ } }, "definitions": { - "ActionRunnerConfig": { + "HasherConfig": { "type": "object", "properties": { - "cacheLifetime": { - "default": "7 days", - "type": "string" - }, - "implicitInputs": { - "default": [ - "package.json", - "/.moon/project.yml", - "/.moon/workspace.yml" - ], - "type": "array", - "items": { - "type": "string" - } - }, - "inheritColorsForPipedTasks": { - "default": true, - "type": "boolean" - }, - "logRunningCommand": { - "default": false, - "type": "boolean" + "optimization": { + "default": "accuracy", + "allOf": [ + { + "$ref": "#/definitions/HasherOptimization" + } + ] } } }, + "HasherOptimization": { + "type": "string", + "enum": [ + "accuracy", + "performance" + ] + }, "NodeConfig": { "type": "object", "properties": { @@ -262,6 +252,34 @@ } } }, + "RunnerConfig": { + "type": "object", + "properties": { + "cacheLifetime": { + "default": "7 days", + "type": "string" + }, + "implicitInputs": { + "default": [ + "package.json", + "/.moon/project.yml", + "/.moon/workspace.yml" + ], + "type": "array", + "items": { + "type": "string" + } + }, + "inheritColorsForPipedTasks": { + "default": true, + "type": "boolean" + }, + "logRunningCommand": { + "default": false, + "type": "boolean" + } + } + }, "TypeScriptConfig": { "type": "object", "properties": {