From 658e4358cc03ebd70db0e670384a74314d3b543a Mon Sep 17 00:00:00 2001 From: "Ame :]" <104745335+ameknite@users.noreply.github.com> Date: Tue, 29 Aug 2023 13:11:06 -0600 Subject: [PATCH] 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 https://github.com/bevyengine/bevy/pull/9547#issuecomment-1689377999 - 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 --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ examples/animation/animated_fox.rs | 4 +--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a135c6e4e662..6e9e82dc2bfc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -333,3 +333,25 @@ jobs: with: name: msrv path: msrv/ + + check-bevy-internal-imports: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - name: Check for bevy_internal imports + shell: bash + run: | + errors="" + for file in $(find examples tests -name '*.rs'); do + if grep -q "use bevy_internal" "$file"; then + errors+="ERROR: Detected 'use bevy_internal' in $file\n" + fi + done + if [ -n "$errors" ]; then + echo -e "$errors" + echo " Avoid importing bevy_internal, it should not be used directly" + echo " Fix the issue by replacing 'bevy_internal' with 'bevy'" + echo " Example: 'use bevy::sprite::MaterialMesh2dBundle;' instead of 'bevy_internal::sprite::MaterialMesh2dBundle;'" + exit 1 + fi \ No newline at end of file diff --git a/examples/animation/animated_fox.rs b/examples/animation/animated_fox.rs index 808d04adf13f7..87fe9dd0989a7 100644 --- a/examples/animation/animated_fox.rs +++ b/examples/animation/animated_fox.rs @@ -3,9 +3,7 @@ use std::f32::consts::PI; use std::time::Duration; -use bevy::pbr::CascadeShadowConfigBuilder; -use bevy::prelude::*; -use bevy_internal::animation::RepeatAnimation; +use bevy::{animation::RepeatAnimation, pbr::CascadeShadowConfigBuilder, prelude::*}; fn main() { App::new()