Skip to content

Commit

Permalink
Re-enable test-code CI job and update examples to Bevy 0.9 (#512)
Browse files Browse the repository at this point in the history
- Re-enable `test-code` CI job
- Update failing examples to Bevy `0.9`
  • Loading branch information
doup committed Jan 14, 2023
1 parent 16c3cb0 commit 97fef72
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,19 @@ jobs:
test-code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@master

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
override: true
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
override: true

# Temporarily disable steps
# - name: Install alsa and udev
# run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
- name: Install alsa and udev
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev

# - name: Build & run tests
# run: cd code-validation && cargo test
- name: Build & run tests
run: cd code-validation && cargo test

build-website:
runs-on: ubuntu-latest
Expand Down
54 changes: 27 additions & 27 deletions content/learn/book/ecs/entities-components/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ As a result, we must use [`Commands`], which queue up work to do later.
// which operate on the `World` once all of the current systems have finished running
fn spawning_system(mut commands: Commands){
// Spawning a single entity with no components
commands.spawn();
commands.spawn(());
// Getting the `Entity` identifier of a new entity
let my_entity = commands.spawn().id();
let my_entity = commands.spawn(()).id();
// Selecting and then despawning the just-spawned second entity
commands.entity(my_entity).despawn();
}
Expand Down Expand Up @@ -112,35 +112,35 @@ Now that we have some components defined, let's try adding them to our entities
# }

fn spawn_combatants_system(mut commands: Commands) {
commands
.spawn()
commands.spawn((
// This inserts a data-less `Combatant` component into the entity we're spawning
.insert(Combatant)
Combatant,
// We configure starting component values by passing in concrete instances of our types
.insert(Life(10))
Life(10),
// By chaining .insert method calls like this, we continue to add more components to our entity
// Instances of named structs are constructed with {field_name: value}
.insert(Stats {
Stats {
strength: 15,
dexterity: 10,
intelligence: 8,
})
},
// Instances of enums are created by picking one of their variants
.insert(Allegiance::Friendly);
Allegiance::Friendly,
));

// We've ended our Commands method chain using a ;,
// and so now we can create a second entity
// by calling .spawn() again
commands
.spawn()
.insert(Combatant)
.insert(Life(10))
.insert(Stats {
commands.spawn((
Combatant,
Life(10),
Stats {
strength: 17,
dexterity: 8,
intelligence: 6,
})
.insert(Allegiance::Hostile);
},
Allegiance::Hostile,
));
}
```

Expand All @@ -160,15 +160,15 @@ struct InCombat;
// This query returns the `Entity` identifier of all entities
// that have the `Combatant` component but do not yet have the `InCombat` component
fn start_combat_system(query: Query<Entity, (With<Combatant>, Without<InCombat>)>, mut commands: Commands){
for entity in query.iter(){
for entity in query.iter() {
// The component will be inserted at the end of the current stage
commands.entity(entity).insert(InCombat);
}
}

// Now to undo our hard work
fn end_combat_system(query: Query<Entity, (With<Combatant>, With<InCombat>)>, mut commands: Commands){
for entity in query.iter(){
for entity in query.iter() {
// The component will be removed at the end of the current stage
// It is provided as a type parameter,
// as we do not need to know a specific value in order to remove a component of the correct type
Expand Down Expand Up @@ -237,32 +237,32 @@ impl Default for CombatantBundle {
}

fn spawn_combatants_system(mut commands: Commands) {
commands
.spawn()
// We're using struct-update syntax to modify
commands.spawn((
// We're using struct-update syntax to modify
// the instance of `CombatantBundle` returned by its default() method
// See the page on Rust Tips and Tricks at the end of this chapter for more info!
.insert_bundle(CombatantBundle{
CombatantBundle{
stats: Stats {
strength: 15,
dexterity: 10,
intelligence: 8,
},
allegiance: Allegiance::Friendly,
..default()
});
},
));

commands
// .spawn_bundle is just syntactic sugar for .spawn().insert_bundle
.spawn_bundle(CombatantBundle{
commands.spawn((
CombatantBundle{
stats: Stats {
strength: 17,
dexterity: 8,
intelligence: 6,
},
allegiance: Allegiance::Hostile,
..default()
});
},
));
}
```

Expand Down
5 changes: 3 additions & 2 deletions content/learn/book/welcome/apps/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The process is straightforward: we first create a new [`App`].
Then, we add a simple system, which prints "Hello, Bevy!" when it is run.
Finally once we're done configuring the app, we call [`App`] to actually make our app *do things*.

```no_run,rust
```rust,no_run
use bevy::prelude::*;
fn main() {
Expand Down Expand Up @@ -43,7 +43,7 @@ The most basic tools are:
3. Importing other blocks of [`App`]-modifying code using [`Plugins`].
Let's write a very simple demo that shows how those work.

```no_run,rust
```rust,no_run
use bevy::prelude::*;
fn main() {
Expand All @@ -59,6 +59,7 @@ fn main() {
}
// This resource can store a string
#[derive(Resource)]
struct Message {
string: String,
}
Expand Down
4 changes: 2 additions & 2 deletions content/learn/book/welcome/plugins/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ There's no magic to be found here; they're just a straightforward tool for code

Plugins are types that implement the [`Plugin`] trait:

```no_run,rust
```rust,no_run
use bevy::prelude::*;
fn main(){
Expand Down Expand Up @@ -46,7 +46,7 @@ impl Plugin for ScorePlugin {
}
}
#[derive(Default, Debug)]
#[derive(Default, Debug, Resource)]
struct Score(u8);
fn increment_score(mut score: ResMut<Score>) {
Expand Down
4 changes: 2 additions & 2 deletions content/learn/book/welcome/setup/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ Now that we have our Bevy project set up, we're ready to start making our first

Within `main.rs`, let's create our first app and check that all the dependencies are working correctly!

```no_run,rust
```rust,no_run
use bevy::prelude::*;
fn main(){
fn main() {
App::new().add_plugins(DefaultPlugins).run();
}
```
Expand Down

0 comments on commit 97fef72

Please sign in to comment.