diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..dd055d2 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,82 @@ +name: CI 🛠️ + +on: + push: + branches: ['main'] + pull_request: + type: [opened, synchronize] + merge_group: + type: [checks_requested] + +jobs: + build: + name: Build, Test and Lint + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Cache turbo build setup + uses: actions/cache@v4 + with: + path: .turbo + key: ${{ runner.os }}-turbo-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-turbo- + + - name: Install build dependencies + run: | + sudo apt-get update + + - name: Setup Node.JS environment + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Install pnpm via corepack + shell: bash + run: | + corepack enable + corepack prepare --activate + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm build + env: + SQLX_OFFLINE: true + + - name: Lint + run: pnpm lint + env: + SQLX_OFFLINE: true + + - name: Start docker compose + uses: hoverkraft-tech/compose-action@v2.2.0 + with: + compose-file: "docker-compose.db.yaml" + up-flags: "--detach" + + - name: Test + run: pnpm test + env: + SQLX_OFFLINE: true + DATABASE_URL: postgresql://unen:unen@localhost/unen diff --git a/Cargo.lock b/Cargo.lock index 19449af..bd04e22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3794,9 +3794,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winit" -version = "0.30.8" +version = "0.30.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d74280aabb958072864bff6cfbcf9025cf8bfacdde5e32b5e12920ef703b0f" +checksum = "a809eacf18c8eca8b6635091543f02a5a06ddf3dad846398795460e6e0ae3cc0" dependencies = [ "ahash", "android-activity", diff --git a/Cargo.toml b/Cargo.toml index 0a7eada..c378149 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -168,4 +168,4 @@ version = "0.8.1" # RENDERING ################################################################################ [workspace.dependencies.winit] -version = "0.30.8" +version = "0.30.9" diff --git a/apps/client/src/main.rs b/apps/client/src/main.rs index 5db37a8..9bcd83a 100644 --- a/apps/client/src/main.rs +++ b/apps/client/src/main.rs @@ -2,5 +2,5 @@ use unen_engine::core::application::Application; fn main() { let mut app = Application::new("UnnamedClient"); - app.run(); + let _ = app.run(); } diff --git a/package.json b/package.json index 410eea1..46385dd 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,14 @@ "version": "0.0.0", "private": true, "scripts": { + "web:build": "turbo run web:build --continue", + "web:dev": "turbo run web:dev --continue", + "web:lint": "turbo run web:lint --continue", + "web:test": "turbo run web:test --continue", + "engine:build": "turbo run engine:build --continue", + "engine:dev": "turbo run engine:dev --continue", + "engine:lint": "turbo run engine:lint --continue", + "engine:test": "turbo run engine:test --continue", "build": "turbo run build --continue", "dev": "turbo run dev --continue", "lint": "turbo run lint --continue", diff --git a/packages/engine/src/core/application.rs b/packages/engine/src/core/application.rs index 8e08613..2f3bc8e 100644 --- a/packages/engine/src/core/application.rs +++ b/packages/engine/src/core/application.rs @@ -11,6 +11,7 @@ use super::{ event_handler::{EventHandler, RawCallback}, Event, }, + Error, }; pub struct Application { @@ -36,21 +37,18 @@ impl Application { } } - pub fn run(&mut self) { + pub fn run(&mut self) -> Result<(), Error> { // Start the engine - self.engine.run(); + self.engine.run()?; // Creates the event loop and sets it to `ControlFlow::Poll`, that way // we continously run the event loop let event_loop = EventLoop::new().unwrap(); event_loop.set_control_flow(ControlFlow::Poll); - match event_loop.run_app(self) { - Ok(_) => {} - Err(err) => { - log::error!("Failed to run event_loop: {}", err.to_string()); - } - } + event_loop.run_app(self)?; + + Ok(()) } /// Sets the `EventHandler`. @@ -77,7 +75,7 @@ impl ApplicationHandler for Application { ) { match event { WindowEvent::CloseRequested => { - self.engine.shutdown(); + let _ = self.engine.shutdown(); } WindowEvent::RedrawRequested => { // Redraw the application diff --git a/packages/engine/src/core/event/mod.rs b/packages/engine/src/core/event/mod.rs index 406ff01..973b6d9 100644 --- a/packages/engine/src/core/event/mod.rs +++ b/packages/engine/src/core/event/mod.rs @@ -19,6 +19,7 @@ pub use window_event::WindowEvent; /// There **is** a naming convention for any `Event`: /// /// - past-sentence names are refered to events that already occurred. +/// /// Other events are yet to occurr and reacting to them can have some sort of /// influence on the final result. /// diff --git a/packages/engine/src/core/mod.rs b/packages/engine/src/core/mod.rs index 381b9a1..c48acfc 100644 --- a/packages/engine/src/core/mod.rs +++ b/packages/engine/src/core/mod.rs @@ -10,4 +10,6 @@ pub mod scheduler; pub enum Error { #[error("Invalid State: expected {0} got {1}")] InvalidState(EngineState, EngineState), + #[error("Event Loop Error: {0}")] + EventLoopError(#[from] winit::error::EventLoopError), }