Skip to content

Commit f3fd83d

Browse files
authored
fix: Audit 02/11 (#1826)
* Fix pg dupes. * Fix. * Add node state. * Fix affected/touched files. * Fix CI.
1 parent c0e1078 commit f3fd83d

26 files changed

+265
-201
lines changed

.github/workflows/moon.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ on:
1919
- Cargo.toml
2020
- rust-toolchain.toml
2121

22+
env:
23+
# For setup-rust
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
2226
jobs:
2327
ci:
2428
name: CI

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Release
22

33
env:
44
APP_NAME: moon
5+
# For setup-rust
6+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57

68
on:
79
# Manually release cli/core packages

.github/workflows/rust.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Rust
2+
23
on:
34
push:
45
branches:
@@ -18,6 +19,10 @@ concurrency:
1819
group: ${{ github.workflow }}-${{ github.ref }}
1920
cancel-in-progress: true
2021

22+
env:
23+
# For setup-rust
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
2126
jobs:
2227
build-wasm:
2328
name: Build WASM

.moon/workspace.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Trigger CI: 25
1+
# Trigger CI: 26
22

33
$schema: '../website/static/schemas/workspace.json'
44

.yarn/versions/4e37e450.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
releases:
2+
"@moonrepo/cli": patch
3+
"@moonrepo/core-linux-arm64-gnu": patch
4+
"@moonrepo/core-linux-arm64-musl": patch
5+
"@moonrepo/core-linux-x64-gnu": patch
6+
"@moonrepo/core-linux-x64-musl": patch
7+
"@moonrepo/core-macos-arm64": patch
8+
"@moonrepo/core-macos-x64": patch
9+
"@moonrepo/core-windows-x64-msvc": patch

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
#### 🐞 Fixes
6+
7+
- Fixed an issue where a project could be inserted into the project graph multiple times.
8+
- Fixed an issue where touched files would sometimes not be available outside of affected scopes.
9+
310
## 1.32.3
411

512
#### 🐞 Fixes

crates/action-graph/src/action_graph_builder.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct ActionGraphBuilder<'app> {
4444

4545
// Affected states
4646
affected: Option<AffectedTracker<'app>>,
47-
touched_files: Option<&'app FxHashSet<WorkspaceRelativePathBuf>>,
47+
touched_files: Option<FxHashSet<WorkspaceRelativePathBuf>>,
4848

4949
// Target tracking
5050
initial_targets: FxHashSet<Target>,
@@ -124,6 +124,19 @@ impl<'app> ActionGraphBuilder<'app> {
124124
Runtime::system()
125125
}
126126

127+
pub fn set_affected(&mut self) {
128+
let Some(touched_files) = &self.touched_files else {
129+
return;
130+
};
131+
132+
if self.affected.is_none() {
133+
self.affected = Some(AffectedTracker::new(
134+
self.workspace_graph,
135+
touched_files.to_owned(),
136+
));
137+
}
138+
}
139+
127140
pub fn set_affected_scopes(
128141
&mut self,
129142
upstream: UpstreamScope,
@@ -138,9 +151,10 @@ impl<'app> ActionGraphBuilder<'app> {
138151
self.workspace_graph.get_tasks_with_internal()?;
139152
}
140153

154+
self.set_affected();
141155
self.affected
142156
.as_mut()
143-
.expect("Affected tracker not set!")
157+
.unwrap()
144158
.with_scopes(upstream, downstream);
145159

146160
Ok(())
@@ -154,10 +168,9 @@ impl<'app> ActionGraphBuilder<'app> {
154168

155169
pub fn set_touched_files(
156170
&mut self,
157-
touched_files: &'app FxHashSet<WorkspaceRelativePathBuf>,
171+
touched_files: FxHashSet<WorkspaceRelativePathBuf>,
158172
) -> miette::Result<()> {
159173
self.touched_files = Some(touched_files);
160-
self.affected = Some(AffectedTracker::new(self.workspace_graph, touched_files));
161174

162175
Ok(())
163176
}

crates/action-graph/tests/action_graph_test.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,8 @@ mod action_graph {
903903

904904
// Empty set works fine, just needs to be some
905905
let touched_files = FxHashSet::default();
906-
builder.set_touched_files(&touched_files).unwrap();
906+
builder.set_touched_files(touched_files).unwrap();
907+
builder.set_affected();
907908

908909
builder
909910
.run_task(&project, &task, &RunRequirements::default())
@@ -934,7 +935,8 @@ mod action_graph {
934935
task.input_files.insert(file.clone());
935936

936937
let touched_files = FxHashSet::from_iter([file]);
937-
builder.set_touched_files(&touched_files).unwrap();
938+
builder.set_touched_files(touched_files).unwrap();
939+
builder.set_affected();
938940
builder.mock_affected(|affected| {
939941
affected
940942
.mark_task_affected(&task, AffectedBy::AlwaysAffected)
@@ -967,7 +969,8 @@ mod action_graph {
967969

968970
let touched_files =
969971
FxHashSet::from_iter([WorkspaceRelativePathBuf::from("deps-affected/b.txt")]);
970-
builder.set_touched_files(&touched_files).unwrap();
972+
builder.set_touched_files(touched_files).unwrap();
973+
builder.set_affected();
971974
builder.mock_affected(|affected| {
972975
affected
973976
.mark_task_affected(&task, AffectedBy::AlwaysAffected)

crates/action-graph/tests/snapshots/action_graph_test__action_graph__run_task_dependencies__includes_dependents.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ digraph {
77
1 [ label="SetupToolchain(system)" ]
88
2 [ label="SyncProject(system, deps)" ]
99
3 [ label="RunTask(deps:base)" ]
10-
4 [ label="SyncProject(system, deps-external)" ]
11-
5 [ label="RunTask(deps-external:external)" ]
12-
6 [ label="RunTask(deps:parent2)" ]
13-
7 [ label="RunTask(deps:parent1)" ]
10+
4 [ label="RunTask(deps:parent2)" ]
11+
5 [ label="RunTask(deps:parent1)" ]
12+
6 [ label="SyncProject(system, deps-external)" ]
13+
7 [ label="RunTask(deps-external:external)" ]
1414
1 -> 0 [ ]
1515
2 -> 1 [ ]
1616
3 -> 2 [ ]
17-
4 -> 1 [ ]
1817
4 -> 2 [ ]
19-
5 -> 4 [ ]
18+
4 -> 3 [ ]
19+
5 -> 2 [ ]
2020
5 -> 3 [ ]
21+
6 -> 1 [ ]
2122
6 -> 2 [ ]
22-
6 -> 3 [ ]
23-
7 -> 2 [ ]
23+
7 -> 6 [ ]
2424
7 -> 3 [ ]
2525
}

crates/action-graph/tests/snapshots/action_graph_test__action_graph__run_task_dependencies__includes_dependents_for_ci.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ digraph {
77
1 [ label="SetupToolchain(system)" ]
88
2 [ label="SyncProject(system, deps)" ]
99
3 [ label="RunTask(deps:base)" ]
10-
4 [ label="SyncProject(system, deps-external)" ]
11-
5 [ label="RunTask(deps-external:external)" ]
12-
6 [ label="RunTask(deps:parent2)" ]
13-
7 [ label="RunTask(deps:parent1)" ]
10+
4 [ label="RunTask(deps:parent2)" ]
11+
5 [ label="RunTask(deps:parent1)" ]
12+
6 [ label="SyncProject(system, deps-external)" ]
13+
7 [ label="RunTask(deps-external:external)" ]
1414
1 -> 0 [ ]
1515
2 -> 1 [ ]
1616
3 -> 2 [ ]
17-
4 -> 1 [ ]
1817
4 -> 2 [ ]
19-
5 -> 4 [ ]
18+
4 -> 3 [ ]
19+
5 -> 2 [ ]
2020
5 -> 3 [ ]
21+
6 -> 1 [ ]
2122
6 -> 2 [ ]
22-
6 -> 3 [ ]
23-
7 -> 2 [ ]
23+
7 -> 6 [ ]
2424
7 -> 3 [ ]
2525
}

0 commit comments

Comments
 (0)