Skip to content

Commit

Permalink
breaking: Rename actionRunner setting to runner. (#291)
Browse files Browse the repository at this point in the history
* Rename config.

* Update other areas.
  • Loading branch information
milesj committed Aug 31, 2022
1 parent 95d24b7 commit 832ed37
Show file tree
Hide file tree
Showing 17 changed files with 153 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .moon/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ projects:
- '!packages/core-*'
- 'website'

actionRunner:
runner:
logRunningCommand: true

vcs:
Expand Down
9 changes: 2 additions & 7 deletions crates/action-runner/src/actions/run_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion crates/action-runner/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/tests/run_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions crates/config/src/workspace/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String>,

Expand All @@ -78,6 +75,9 @@ pub struct WorkspaceConfig {
#[validate(custom = "validate_projects")]
pub projects: WorkspaceProjects,

#[validate]
pub runner: RunnerConfig,

#[validate]
pub typescript: Option<TypeScriptConfig>,

Expand Down
4 changes: 2 additions & 2 deletions crates/config/src/workspace/mod.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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
Expand All @@ -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<ActionRunnerConfig, figment::Error> {
let figment = Figment::from(Serialized::defaults(ActionRunnerConfig::default()))
fn load_jailed_config() -> Result<RunnerConfig, figment::Error> {
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()
Expand Down
14 changes: 7 additions & 7 deletions crates/config/tests/workspace_test.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -286,7 +286,7 @@ node:
assert_eq!(
config,
WorkspaceConfig {
action_runner: ActionRunnerConfig::default(),
runner: RunnerConfig::default(),
extends: None,
hasher: HasherConfig::default(),
node: Some(NodeConfig {
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion crates/project-graph/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/config-extends/workspace/base-0.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
actionRunner:
runner:
cacheLifetime: '3 hours'

node:
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/config-extends/workspace/base-1.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends: './base-0.yml'

actionRunner:
runner:
logRunningCommand: true

node:
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/config-extends/workspace/base-2.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends: './base-1.yml'

actionRunner:
runner:
logRunningCommand: false

node:
Expand Down
20 changes: 20 additions & 0 deletions website/blog/2022-09-01_v0.13.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion website/docs/commands/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
56 changes: 28 additions & 28 deletions website/docs/config/workspace.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,33 @@ Would result in the following `references` within both `tsconfig.json`s.

## Features

## `actionRunner`
## `hasher`<VersionLabel version="0.13" />

> `HasherConfig`

Configures aspects of smart hashing layer.

### `optimization`<VersionLabel version="0.13" />

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`<VersionLabel updated version="0.13" />

> `ActionRunnerConfig`
> `RunnerConfig`

Configures aspects of the action runner.

### `cacheLifetime`<VersionLabel updated version="0.11" />
### `cacheLifetime`<VersionLabel version="0.11" />

> `string`

Expand All @@ -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`<VersionLabel updated version="0.9" />
### `implicitInputs`<VersionLabel version="0.9" />

> `string[]`

Expand All @@ -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'
Expand All @@ -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
```

Expand All @@ -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`<VersionLabel version="0.13" />

> `HasherConfig`

Configures aspects of smart hashing layer.

### `optimization`<VersionLabel version="0.13" />

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`
Expand Down
Loading

0 comments on commit 832ed37

Please sign in to comment.