Skip to content

Commit 616fc89

Browse files
committed
Merge remote-tracking branch 'origin/main' into bevy_0.16
2 parents 802c864 + f564116 commit 616fc89

File tree

29 files changed

+470
-281
lines changed

29 files changed

+470
-281
lines changed

.github/workflows/bencher_on_pr_or_fork.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
benchmark_fork_pr_branch:
9-
name: Run Fork PR Benchmarks
9+
name: Run PR Benchmarks
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4

.github/workflows/bevy_mod_scripting.yml

Lines changed: 26 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,23 @@ jobs:
7575
jq -c . matrix.json > matrix-one-line.json
7676
echo "matrix=$(cat matrix-one-line.json)" >> $GITHUB_OUTPUT
7777
78+
check-is-fork:
79+
runs-on: ubuntu-latest
80+
outputs:
81+
is_fork: ${{ steps.check-fork.outputs.is_fork }}
82+
steps:
83+
- name: Check if fork
84+
id: check-fork
85+
run: |
86+
if [ "${{ github.repository }}" != "${{ github.event.pull_request.head.repo.full_name }}" ]; then
87+
echo "This is a forked repository."
88+
echo "is_fork=true" >> $GITHUB_OUTPUT
89+
else
90+
echo "This is not a forked repository."
91+
echo "is_fork=false" >> $GITHUB_OUTPUT
92+
fi
7893
check:
79-
needs: [check-needs-run, generate-job-matrix]
94+
needs: [check-needs-run, generate-job-matrix, check-is-fork]
8095
permissions:
8196
pull-requests: write
8297
contents: write
@@ -103,49 +118,49 @@ jobs:
103118
# # run: |
104119
# # sudo rm -rf /usr/share/dotnet; sudo rm -rf /opt/ghc; sudo rm -rf "/usr/local/share/boost"; sudo rm -rf "$AGENT_TOOLSDIRECTORY"
105120
- name: Checkout
106-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
121+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
107122
uses: actions/checkout@v4
108123
- uses: actions-rs/toolchain@v1
109-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
124+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
110125
with:
111126
toolchain: stable
112127
override: true
113128
- name: Rust Cache
114-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
129+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
115130
uses: Swatinem/rust-cache@v2.7.7
116131
with:
117132
# reasoning: we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that
118133
save-if: ${{ github.ref == 'refs/heads/main' }}
119134
cache-all-crates: true
120135

121136
- name: Setup
122-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
137+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
123138
run: |
124139
cargo xtask init
125140
126141
- name: Setup GPU Drivers
127-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.requires_gpu }}
142+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') && matrix.run_args.requires_gpu }}
128143
run: |
129144
sudo add-apt-repository ppa:kisak/turtle -y
130145
sudo apt-get install --no-install-recommends libxkbcommon-x11-0 xvfb libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
131146
- name: Check
132-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && !matrix.run_args.requires_gpu }}
147+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') && !matrix.run_args.requires_gpu }}
133148
run: |
134149
${{ matrix.run_args.command }}
135150
- name: Check With virtual X11 server
136-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.requires_gpu }}
151+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') && matrix.run_args.requires_gpu }}
137152
run: |
138153
xvfb-run ${{ matrix.run_args.command }}
139154
140155
- name: Upload coverage artifact
141-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.generates_coverage }}
156+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') && matrix.run_args.generates_coverage }}
142157
uses: actions/upload-artifact@v4
143158
with:
144159
name: code-coverage-report
145160
path: target/coverage/html/
146161

147162
- name: Update coverage badge
148-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.generates_coverage }}
163+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') && matrix.run_args.generates_coverage }}
149164
continue-on-error: true
150165
run: |
151166
git checkout -b chore/_update-coverage-badge || git checkout chore/_update-coverage-badge
@@ -163,45 +178,4 @@ jobs:
163178
sed -n 's/.*pull\/\([0-9]*\).*/\1/p' pr.txt > pr_number.txt
164179
PRNUMBER=$(cat pr_number.txt)
165180
gh pr merge $PRNUMBER --squash
166-
fi
167-
generate_bindings:
168-
name: Bindings - Synchronise
169-
permissions:
170-
contents: write
171-
pull-requests: write
172-
runs-on: ubuntu-latest
173-
if: github.repository_owner == 'makspll'
174-
steps:
175-
- name: Checkout
176-
uses: actions/checkout@v4
177-
with:
178-
ref: ${{ github.head_ref || github.ref_name }}
179-
- name: Rust Cache
180-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
181-
uses: Swatinem/rust-cache@v2.7.7
182-
with:
183-
# reasoning: we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that
184-
save-if: ${{ github.ref == 'refs/heads/main' }}
185-
cache-all-crates: true
186-
- name: Setup Bot GitHub Credentials
187-
run: |
188-
git config user.name "github-actions[bot]"
189-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
190-
- name: Setup
191-
run: |
192-
cargo xtask init
193-
- name: Generate Bindings
194-
run: |
195-
cargo xtask codegen
196-
- name: Check for changes
197-
id: check_changes
198-
run: |
199-
if [[ -n $(git status --porcelain) ]]; then
200-
echo "changes=true" >> "$GITHUB_OUTPUT";
201-
fi
202-
- name: Commit Changes
203-
if: steps.check_changes.outputs.changes
204-
run: |
205-
git add -A
206-
git commit -m "chore(codegen): update bevy bindings"
207-
git push
181+
fi
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- "**"
5+
6+
name: Synchronize Bindings
7+
8+
concurrency:
9+
# Use github.run_id on main branch
10+
# Use github.event.pull_request.number on pull requests, so it's unique per pull request
11+
# Use github.ref on other branches, so it's unique per branch
12+
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
generate_bindings:
17+
name: Synchronise Bindings (Not Fork)
18+
permissions:
19+
contents: write
20+
pull-requests: write
21+
runs-on: ubuntu-latest
22+
if: github.event.pull_request.head.repo.full_name == github.repository
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.head_ref || github.ref_name }}
28+
- name: Rust Cache
29+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
30+
uses: Swatinem/rust-cache@v2.7.7
31+
with:
32+
# reasoning: we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that
33+
save-if: ${{ github.ref == 'refs/heads/main' }}
34+
cache-all-crates: true
35+
- name: Setup Bot GitHub Credentials
36+
run: |
37+
git config user.name "github-actions[bot]"
38+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
39+
- name: Setup
40+
run: |
41+
cargo xtask init
42+
- name: Generate Bindings
43+
run: |
44+
cargo xtask codegen
45+
- name: Check for changes
46+
id: check_changes
47+
run: |
48+
if [[ -n $(git status --porcelain) ]]; then
49+
echo "changes=true" >> "$GITHUB_OUTPUT";
50+
fi
51+
- name: Commit Changes
52+
if: steps.check_changes.outputs.changes
53+
run: |
54+
git add -A
55+
git commit -m "chore(codegen): update bevy bindings"
56+
git push

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ codegen-units = 8
148148
incremental = false
149149
debug = false
150150

151-
[profile.ephemeral-coverage]
152-
inherits = "ephemeral-build"
153-
debug = true
151+
# [profile.ephemeral-coverage]
152+
# inherits = "ephemeral-build"
153+
# debug = true
154154

155155
[profile.release-with-debug]
156156
inherits = "release"

benches/benchmarks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn script_benchmarks(criterion: &mut Criterion, filter: Option<Regex>) {
110110
}
111111

112112
for (group, tests) in grouped {
113-
println!("Running benchmarks for group: {}", group);
113+
println!("Running benchmarks for group: {group}");
114114
let mut benchmark_group = criterion.benchmark_group(group);
115115

116116
for t in tests {

crates/bevy_mod_scripting_core/src/asset.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ mod tests {
431431
LoadState::NotLoaded => panic!("Asset not loaded"),
432432
LoadState::Loaded => {}
433433
LoadState::Failed(asset_load_error) => {
434-
panic!("Asset load failed: {:?}", asset_load_error)
434+
panic!("Asset load failed: {asset_load_error:?}")
435435
}
436436
_ => panic!("Unexpected load state"),
437437
}
@@ -532,7 +532,7 @@ mod tests {
532532
mut event_target: ResMut<EventTarget>| {
533533
println!("Reading asset events this frame");
534534
for event in reader.read() {
535-
println!("{:?}", event);
535+
println!("{event:?}");
536536
if matches!(
537537
(event_target.event, event),
538538
(AssetEvent::Added { .. }, AssetEvent::Added { .. })

crates/bevy_mod_scripting_core/src/bindings/function/namespace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Namespace {
5050
pub fn prefix(self) -> Cow<'static, str> {
5151
match self {
5252
Namespace::Global => Cow::Borrowed(""),
53-
Namespace::OnType(type_id) => Cow::Owned(format!("{:?}::", type_id)),
53+
Namespace::OnType(type_id) => Cow::Owned(format!("{type_id:?}::")),
5454
}
5555
}
5656

crates/bevy_mod_scripting_core/src/bindings/function/script_function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ impl ScriptFunctionRegistry {
463463
if i == 0 {
464464
self.get_function(namespace, name.clone())
465465
} else {
466-
let name: Cow<'static, str> = format!("{}-{i}", name).into();
466+
let name: Cow<'static, str> = format!("{name}-{i}").into();
467467
self.get_function(namespace, name)
468468
}
469469
})

crates/bevy_mod_scripting_core/src/bindings/pretty_print.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl ReflectReferencePrinter {
9090

9191
if let Some(tail_type_id) = tail_type_id {
9292
let type_path = tail_type_id.display_with_world(world);
93-
pretty_path.push_str(&format!(" -> {}", type_path));
93+
pretty_path.push_str(&format!(" -> {type_path}"));
9494
}
9595
} else {
9696
Self::pretty_print_base(&self.reference.base, None, &mut pretty_path);
@@ -111,7 +111,7 @@ impl ReflectReferencePrinter {
111111
self.pretty_print_value_inner(r, &mut output);
112112
})
113113
.unwrap_or_else(|e| {
114-
output.push_str(&format!("<Error in printing: {}>", e));
114+
output.push_str(&format!("<Error in printing: {e}>"));
115115
});
116116
}
117117
None => {
@@ -131,12 +131,12 @@ impl ReflectReferencePrinter {
131131
};
132132

133133
let base_kind = match base.base_id {
134-
ReflectBase::Component(e, _) => format!("Component on entity {}", e),
134+
ReflectBase::Component(e, _) => format!("Component on entity {e}"),
135135
ReflectBase::Resource(_) => "Resource".to_owned(),
136-
ReflectBase::Owned(ref id) => format!("Allocation({})", id),
136+
ReflectBase::Owned(ref id) => format!("Allocation({id})"),
137137
};
138138

139-
out.push_str(&format!("{}({})", base_kind, type_path));
139+
out.push_str(&format!("{base_kind}({type_path})"));
140140
}
141141

142142
/// Pretty prints a value of an opaque type.
@@ -317,7 +317,7 @@ impl ReflectReferencePrinter {
317317
// for function_reflection from bevy or other feature gated things
318318
#[allow(unreachable_patterns)]
319319
_ => {
320-
output.push_str(&format!("{:?}", v));
320+
output.push_str(&format!("{v:?}"));
321321
}
322322
}
323323
}
@@ -414,7 +414,7 @@ impl DisplayWithWorld for ComponentId {
414414
.map(|info| info.name());
415415

416416
match component_name {
417-
Some(n) => format!("ComponentOrResource({})", n),
417+
Some(n) => format!("ComponentOrResource({n})"),
418418
None => "ComponentOrResource(<Unknown>)".to_owned(),
419419
}
420420
}
@@ -450,14 +450,14 @@ impl DisplayWithWorld for ReflectAccessId {
450450
if let Some(allocation) = allocator.get(&allocation_id) {
451451
let ptr = allocation.get_ptr();
452452
let val = unsafe { &*ptr };
453-
let o = format!("Allocation({:?})", val);
453+
let o = format!("Allocation({val:?})");
454454
unsafe { world.release_access(raid) };
455455
o
456456
} else {
457-
format!("Allocation({})", allocation_id)
457+
format!("Allocation({allocation_id})")
458458
}
459459
} else {
460-
format!("Allocation({})", allocation_id)
460+
format!("Allocation({allocation_id})")
461461
}
462462
}
463463
super::access_map::ReflectAccessKind::Global => "Global".to_owned(),
@@ -491,7 +491,7 @@ impl DisplayWithWorld for TypeId {
491491
}
492492

493493
fn display_without_world(&self) -> String {
494-
format!("{:?}", self)
494+
format!("{self:?}")
495495
}
496496
}
497497
#[profiling::all_functions]
@@ -687,15 +687,15 @@ mod test {
687687
let type_id = TypeId::of::<usize>();
688688
assert_eq!(type_id.display_with_world(world.clone()), "usize");
689689
assert_eq!(type_id.display_value_with_world(world.clone()), "usize");
690-
assert_eq!(type_id.display_without_world(), format!("{:?}", type_id));
690+
assert_eq!(type_id.display_without_world(), format!("{type_id:?}"));
691691

692692
let type_id = TypeId::of::<FakeType>();
693693
assert_eq!(type_id.display_with_world(world.clone()), "Unknown Type");
694694
assert_eq!(
695695
type_id.display_value_with_world(world.clone()),
696696
"Unknown Type"
697697
);
698-
assert_eq!(type_id.display_without_world(), format!("{:?}", type_id));
698+
assert_eq!(type_id.display_without_world(), format!("{type_id:?}"));
699699
}
700700

701701
#[test]
@@ -729,7 +729,7 @@ mod test {
729729
type_id,
730730
}
731731
.display_without_world(),
732-
format!("Allocation(0)({:?})", type_id)
732+
format!("Allocation(0)({type_id:?})")
733733
);
734734
}
735735

@@ -763,7 +763,7 @@ mod test {
763763

764764
assert_eq!(
765765
reflect_reference.display_without_world(),
766-
format!("<Reference to Allocation({id})({:?})>", type_id)
766+
format!("<Reference to Allocation({id})({type_id:?})>")
767767
);
768768
}
769769

crates/bevy_mod_scripting_core/src/bindings/schedule.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ mod tests {
306306
if let Some(system) = graph.get_system_at(node_id) {
307307
system.name().clone().to_string()
308308
} else if let Some(system_set) = graph.get_set_at(node_id) {
309-
format!("{:?}", system_set).to_string()
309+
format!("{system_set:?}").to_string()
310310
} else {
311311
// try schedule systems
312312
let mut default = format!("{node_id:?}").to_string();
@@ -351,10 +351,7 @@ mod tests {
351351
for &(exp_from, exp_to) in expected_edges {
352352
assert!(
353353
found_edges.contains(&(exp_from.to_owned(), exp_to.to_owned())),
354-
"Expected edge ({} -> {}) not found. Found edges: {:?}",
355-
exp_from,
356-
exp_to,
357-
found_edges
354+
"Expected edge ({exp_from} -> {exp_to}) not found. Found edges: {found_edges:?}"
358355
);
359356
}
360357

0 commit comments

Comments
 (0)