Skip to content

Commit

Permalink
Check for bevy_internal imports in CI (#9612)
Browse files Browse the repository at this point in the history
# 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]>
  • Loading branch information
ameknite and rparrett authored Aug 29, 2023
1 parent 1399078 commit f2f39c8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions examples/animation/animated_fox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f2f39c8

Please sign in to comment.