Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ version = "0.8.1"
# RENDERING
################################################################################
[workspace.dependencies.winit]
version = "0.30.8"
version = "0.30.9"
2 changes: 1 addition & 1 deletion apps/client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ use unen_engine::core::application::Application;

fn main() {
let mut app = Application::new("UnnamedClient");
app.run();
let _ = app.run();
}
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 7 additions & 9 deletions packages/engine/src/core/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use super::{
event_handler::{EventHandler, RawCallback},
Event,
},
Error,
};

pub struct Application {
Expand All @@ -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`.
Expand All @@ -77,7 +75,7 @@ impl ApplicationHandler for Application {
) {
match event {
WindowEvent::CloseRequested => {
self.engine.shutdown();
let _ = self.engine.shutdown();
}
WindowEvent::RedrawRequested => {
// Redraw the application
Expand Down
1 change: 1 addition & 0 deletions packages/engine/src/core/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
2 changes: 2 additions & 0 deletions packages/engine/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}