Skip to content

Commit f2f39c8

Browse files
amekniterparrett
andauthored
Check for bevy_internal imports in CI (#9612)
# Objective - Avoid using bevy_internal imports in examples. ## Solution - Add CI to check for bevy_internal imports like suggested in #9547 (comment) - Fix another import I don't know much about CI so I don't know if this is the better approach, but I think is better than doing a pull request every time I found this lol, any suggestion is welcome. --------- Co-authored-by: Rob Parrett <[email protected]>
1 parent 1399078 commit f2f39c8

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,25 @@ jobs:
333333
with:
334334
name: msrv
335335
path: msrv/
336+
337+
check-bevy-internal-imports:
338+
runs-on: ubuntu-latest
339+
timeout-minutes: 30
340+
steps:
341+
- uses: actions/checkout@v3
342+
- name: Check for bevy_internal imports
343+
shell: bash
344+
run: |
345+
errors=""
346+
for file in $(find examples tests -name '*.rs'); do
347+
if grep -q "use bevy_internal" "$file"; then
348+
errors+="ERROR: Detected 'use bevy_internal' in $file\n"
349+
fi
350+
done
351+
if [ -n "$errors" ]; then
352+
echo -e "$errors"
353+
echo " Avoid importing bevy_internal, it should not be used directly"
354+
echo " Fix the issue by replacing 'bevy_internal' with 'bevy'"
355+
echo " Example: 'use bevy::sprite::MaterialMesh2dBundle;' instead of 'bevy_internal::sprite::MaterialMesh2dBundle;'"
356+
exit 1
357+
fi

examples/animation/animated_fox.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
use std::f32::consts::PI;
44
use std::time::Duration;
55

6-
use bevy::pbr::CascadeShadowConfigBuilder;
7-
use bevy::prelude::*;
8-
use bevy_internal::animation::RepeatAnimation;
6+
use bevy::{animation::RepeatAnimation, pbr::CascadeShadowConfigBuilder, prelude::*};
97

108
fn main() {
119
App::new()

0 commit comments

Comments
 (0)