Skip to content

Commit

Permalink
Merge branch 'develop-1.30' of https://github.com/moonrepo/moon into …
Browse files Browse the repository at this point in the history
…python-plattform-support
  • Loading branch information
harlequin committed Nov 14, 2024
2 parents c655e88 + 3d77456 commit 63dc2c7
Show file tree
Hide file tree
Showing 36 changed files with 1,852 additions and 716 deletions.
21 changes: 15 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,28 @@

- If you renamed a project using the `id` setting in `moon.yml`, you can no longer reference that
project in dependencies and targets using its original ID.
- Refactored the `moon query tasks` command.
- CLI options have been replaced with new task based options, instead of being project based.
- Now utilizes the new task graph and affected tracker.

#### 🚀 Updates

- Resolved the `strictProjectIds` experiment and you can no longer reference the original ID.
- Resolved the `disallowRunInCiMismatch` experiment and you can no longer have a CI based task
depend on a non-CI based task.
- Added a new task graph, that enables new granular based functionality for task related features.
- Added Python tier 3 support.
- Will download and install Python into the toolchain when a `version` is configured.
- Will parse the `requirements.txt` to resolve and install dependencies.
- Added a `python.version` setting to `.moon/toolchain.yml`.
- Added a `toolchain.python` setting to `moon.yml`.
- Updated `moon bin` commands to support Python.
- Added a new `moon task-graph` command.
- Can now control the depth of upstream (dependencies) and downstream (dependents).
- Affected information now tracks based on dependent graph connections.
- Added `--upstream` and `--downstream` options to `moon query tasks`.
- Added 7 new token variables: `$arch`, `$os`, `$osFamily`, `$vcsBranch`, `$vcsRepository`,
`$vcsRevision`, `$workingDir`
- Added a `rust.binstallVersion` setting to `.moon/toolchain.yml`.

#### 🐞 Fixes

- Fixed `moon project-graph <id>` not including all dependencies/dependents. It was only showing
direct relationships.

## 1.29.4

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/action-graph/src/action_graph_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ impl<'app> ActionGraphBuilder<'app> {
// If we require dependents, then we must load all projects into the
// graph so that the edges are created!
if downstream != DownstreamScope::None {
debug!("Force loading all projects to determine downstream relationships");
debug!("Force loading all projects and tasks to determine relationships");

self.workspace_graph.get_all_projects()?;
self.workspace_graph.get_all_tasks()?;
}

self.affected
Expand Down
6 changes: 6 additions & 0 deletions crates/affected/src/affected.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ pub struct AffectedProjectState {
#[serde(skip_serializing_if = "FxHashSet::is_empty")]
pub files: FxHashSet<WorkspaceRelativePathBuf>,

#[serde(skip_serializing_if = "FxHashSet::is_empty")]
pub tasks: FxHashSet<Target>,

#[serde(skip_serializing_if = "FxHashSet::is_empty")]
pub upstream: FxHashSet<Id>,

Expand All @@ -95,6 +98,9 @@ impl AffectedProjectState {
AffectedBy::UpstreamProject(id) => {
state.upstream.insert(id);
}
AffectedBy::Task(target) => {
state.tasks.insert(target);
}
_ => {
state.other = true;
}
Expand Down
56 changes: 49 additions & 7 deletions crates/affected/src/affected_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl<'app> AffectedTracker<'app> {
files = ?state.files.iter().collect::<Vec<_>>(),
upstream = ?state.upstream.iter().map(|id| id.as_str()).collect::<Vec<_>>(),
downstream = ?state.downstream.iter().map(|id| id.as_str()).collect::<Vec<_>>(),
tasks = ?state.tasks.iter().map(|target| target.as_str()).collect::<Vec<_>>(),
other = state.other,
"Project {} is affected by", color::id(&id),
);
Expand Down Expand Up @@ -198,17 +199,17 @@ impl<'app> AffectedTracker<'app> {
}
}

for dep_id in self.workspace_graph.projects.dependencies_of(project) {
for dep_config in &project.dependencies {
self.projects
.entry(dep_id.clone())
.entry(dep_config.id.clone())
.or_default()
.push(AffectedBy::DownstreamProject(project.id.clone()));

if depth == 0 && self.project_upstream == UpstreamScope::Direct {
continue;
}

let dep_project = self.workspace_graph.get_project(&dep_id)?;
let dep_project = self.workspace_graph.get_project(&dep_config.id)?;

self.track_project_dependencies(&dep_project, depth + 1)?;
}
Expand All @@ -233,10 +234,7 @@ impl<'app> AffectedTracker<'app> {
"Tracking direct dependents"
);
} else {
trace!(
project_id = project.id.as_str(),
"Tracking deep dependents (entire family)"
);
trace!(project_id = project.id.as_str(), "Tracking deep dependents");
}
}

Expand Down Expand Up @@ -332,6 +330,14 @@ impl<'app> AffectedTracker<'app> {
.push(affected);

self.track_task_dependencies(task, 0)?;
self.track_task_dependents(task, 0)?;

if let Some(project_id) = task.target.get_project_id() {
self.projects
.entry(project_id.to_owned())
.or_default()
.push(AffectedBy::Task(task.target.clone()));
}

Ok(())
}
Expand Down Expand Up @@ -377,4 +383,40 @@ impl<'app> AffectedTracker<'app> {

Ok(())
}

fn track_task_dependents(&mut self, task: &Task, depth: u16) -> miette::Result<()> {
if self.task_downstream == DownstreamScope::None {
trace!(
target = task.target.as_str(),
"Not tracking dependents as downstream scope is none"
);

return Ok(());
}

if depth == 0 {
if self.task_downstream == DownstreamScope::Direct {
trace!(target = task.target.as_str(), "Tracking direct dependents");
} else {
trace!(target = task.target.as_str(), "Tracking deep dependents");
}
}

for dep_target in self.workspace_graph.tasks.dependents_of(task) {
self.tasks
.entry(dep_target.clone())
.or_default()
.push(AffectedBy::UpstreamTask(task.target.clone()));

if depth == 0 && self.task_downstream == DownstreamScope::Direct {
continue;
}

let dep_task = self.workspace_graph.get_task(&dep_target)?;

self.track_task_dependents(&dep_task, depth + 1)?;
}

Ok(())
}
}
19 changes: 19 additions & 0 deletions crates/affected/tests/__fixtures__/tasks/chain/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
tasks:
a:
deps: ['b']
inputs: ['a.txt']
b:
deps: ['c']
inputs: ['b.txt']
c:
deps: ['d']
inputs: ['c.txt']
d:
deps: ['e']
inputs: ['d.txt']
e:
inputs: ['e.txt']

# No relationship
z:
inputs: ['z.txt']
Loading

0 comments on commit 63dc2c7

Please sign in to comment.