Compare commits

...

3 Commits

Author SHA1 Message Date
7cef2fedd5 chore: Upgrade to Bevy 0.14.
All checks were successful
Test / test (ubuntu-latest) (push) Successful in 2m8s
2024-07-07 10:44:14 -05:00
6cf5d92cb8 chore: Switch to Gitea Actions. 2024-07-07 09:52:51 -05:00
3d422dc9e4 chore: Add pre-commit. 2024-07-07 09:50:30 -05:00
8 changed files with 104 additions and 72 deletions

View File

@ -1,47 +0,0 @@
kind: pipeline
type: docker
name: default
environment:
DEPENDENCIES: cmake pkg-config libx11-dev libasound2-dev libudev-dev libxcb-xfixes0-dev libwayland-dev libxkbcommon-dev libvulkan-dev libpulse-dev
steps:
- name: test
image: rust:bullseye
pull: always
commands:
- apt-get update -qq
- apt-get install -qqy $DEPENDENCIES
- rustup component add clippy rustfmt
- cargo fmt --check
- cargo test
- cargo clippy
- name: release
image: rust:bullseye
pull: always
commands:
- apt-get update -qq
- apt-get install -qqy $DEPENDENCIES
- cargo publish
when:
ref:
- refs/tags/v*
environment:
CARGO_REGISTRY_TOKEN:
from_secret: cargo_registry_token
- name: discord notification
image: appleboy/drone-discord
when:
status: [success, failure]
settings:
webhook_id:
from_secret: discord_webhook_id
webhook_token:
from_secret: discord_webhook_token
tts: true
message: >
{{#success build.status}}
{{repo.name}} build {{build.number}} succeeded: <{{build.link}}>
{{else}}
{{repo.name}} build {{build.number}} failed: <{{build.link}}>
{{/success}}

View File

@ -0,0 +1,39 @@
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy
- name: install Linux build dependencies
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev libwayland-dev libclang-dev cmake
if: runner.os == 'linux'
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.1
- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

37
.gitea/workflows/test.yml Normal file
View File

@ -0,0 +1,37 @@
name: Test
on:
pull_request:
push:
jobs:
test:
strategy:
matrix:
# os: [windows-latest, ubuntu-latest, macos-latest]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy
- name: install Linux build dependencies
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev libwayland-dev libclang-dev cmake
if: runner.os == 'linux'
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.1

10
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,10 @@
fail_fast: true
repos:
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
args: [--, --check]
- id: cargo-check
args: [--bins, --examples]
- id: clippy

View File

@ -10,11 +10,12 @@ repository = "https://labs.lightsout.games/projects/bevy_synthizer"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy = { version = "0.13", default-features = false, features = ["bevy_asset"] }
bevy = { version = "0.14", default-features = false, features = ["bevy_asset"] }
synthizer = "0.5.6"
thiserror = "1"
[dev-dependencies]
bevy = { version = "0.13", default-features = true }
bevy = { version = "0.14", default-features = true }
[package.metadata.release]
publish = false

View File

@ -51,7 +51,7 @@ fn load_and_create(
fn rotate_listener(time: Res<Time>, mut query: Query<(&mut RotationTimer, &mut Transform)>) {
for (mut timer, mut transform) in query.iter_mut() {
timer.tick(time.delta());
let angle = f32::consts::PI * 2. * timer.percent();
let angle = f32::consts::PI * 2. * timer.fraction();
transform.rotation = Quat::from_rotation_z(angle);
}
}
@ -68,9 +68,6 @@ fn main() {
))
.init_resource::<AssetHandles>()
.add_systems(Startup, setup)
.add_systems(
Update,
(bevy::window::close_on_esc, load_and_create, rotate_listener),
)
.add_systems(Update, (load_and_create, rotate_listener))
.run();
}

View File

@ -35,7 +35,7 @@ fn setup(mut commands: Commands, context: Res<Context>) {
fn rotate_listener(time: Res<Time>, mut query: Query<(&mut RotationTimer, &mut Transform)>) {
for (mut timer, mut transform) in query.iter_mut() {
timer.tick(time.delta());
let angle = f32::consts::PI * 2. * timer.percent();
let angle = f32::consts::PI * 2. * timer.fraction();
transform.rotation = Quat::from_rotation_z(angle);
}
}
@ -51,6 +51,6 @@ fn main() {
},
))
.add_systems(Startup, setup)
.add_systems(Update, (bevy::window::close_on_esc, rotate_listener))
.add_systems(Update, rotate_listener)
.run();
}

View File

@ -6,12 +6,9 @@ use bevy::{
prelude::*,
reflect::TypePath,
transform::TransformSystem,
utils::{
thiserror::{self, Error},
BoxedFuture,
},
};
pub use synthizer as syz;
use thiserror::Error;
#[derive(Asset, Clone, Debug, Deref, DerefMut, PartialEq, Eq, TypePath)]
pub struct Buffer(syz::Buffer);
@ -33,18 +30,16 @@ impl AssetLoader for BufferAssetLoader {
type Settings = ();
type Error = BufferAssetLoaderError;
fn load<'a>(
async fn load<'a>(
&'a self,
reader: &'a mut Reader,
reader: &'a mut Reader<'_>,
_settings: &'a (),
_load_context: &'a mut LoadContext,
) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> {
Box::pin(async move {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;
let buffer = syz::Buffer::from_encoded_data(&bytes).map(Buffer)?;
Ok(buffer)
})
_load_context: &'a mut LoadContext<'_>,
) -> Result<Self::Asset, Self::Error> {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;
let buffer = syz::Buffer::from_encoded_data(&bytes).map(Buffer)?;
Ok(buffer)
}
fn extensions(&self) -> &[&str] {
@ -707,10 +702,10 @@ pub struct SynthizerPlugin {
impl Plugin for SynthizerPlugin {
fn build(&self, app: &mut App) {
if !app.world.contains_resource::<SynthizerPlugin>() {
if !app.world().contains_resource::<SynthizerPlugin>() {
app.insert_resource(*self);
}
let config = *app.world.get_resource::<SynthizerPlugin>().unwrap();
let config = *app.world().get_resource::<SynthizerPlugin>().unwrap();
let mut syz_config = syz::LibraryConfig::new();
syz_config.log_level(config.log_level);
if config.log_to_stderr {