Skip to content

Commit 4010cf1

Browse files
committed
feat: add CI
1 parent adb7aba commit 4010cf1

8 files changed

Lines changed: 104 additions & 13 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CI 🛠️
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
pull_request:
7+
type: [opened, synchronize]
8+
merge_group:
9+
type: [checks_requested]
10+
11+
jobs:
12+
build:
13+
name: Build, Test and Lint
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 2
21+
22+
- name: Cache turbo build setup
23+
uses: actions/cache@v4
24+
with:
25+
path: .turbo
26+
key: ${{ runner.os }}-turbo-${{ github.sha }}
27+
restore-keys: |
28+
${{ runner.os }}-turbo-
29+
30+
- name: Install build dependencies
31+
run: |
32+
sudo apt-get update
33+
34+
- name: Setup Node.JS environment
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: 22
38+
39+
- name: Install pnpm via corepack
40+
shell: bash
41+
run: |
42+
corepack enable
43+
corepack prepare --activate
44+
45+
- name: Get pnpm store directory
46+
id: pnpm-cache
47+
shell: bash
48+
run: |
49+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
50+
51+
- name: Setup pnpm cache
52+
uses: actions/cache@v4
53+
with:
54+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
55+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
56+
restore-keys: |
57+
${{ runner.os }}-pnpm-store-
58+
59+
- name: Install dependencies
60+
run: pnpm install
61+
62+
- name: Build
63+
run: pnpm build
64+
env:
65+
SQLX_OFFLINE: true
66+
67+
- name: Lint
68+
run: pnpm lint
69+
env:
70+
SQLX_OFFLINE: true
71+
72+
- name: Start docker compose
73+
uses: hoverkraft-tech/compose-action@2.2.0
74+
with:
75+
compose-file: "docker-compose.test.yaml"
76+
up-flags: "--detach"
77+
78+
- name: Test
79+
run: pnpm test
80+
env:
81+
SQLX_OFFLINE: true
82+
DATABASE_URL: postgresql://unen:unen@localhost/unen

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,4 @@ version = "0.8.1"
168168
# RENDERING
169169
################################################################################
170170
[workspace.dependencies.winit]
171-
version = "0.30.8"
171+
version = "0.30.9"

apps/client/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ use unen_engine::core::application::Application;
22

33
fn main() {
44
let mut app = Application::new("UnnamedClient");
5-
app.run();
5+
let _ = app.run();
66
}

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
"version": "0.0.0",
44
"private": true,
55
"scripts": {
6+
"web:build": "turbo run web:build --continue",
7+
"web:dev": "turbo run web:dev --continue",
8+
"web:lint": "turbo run web:lint --continue",
9+
"web:test": "turbo run web:test --continue",
10+
"engine:build": "turbo run engine:build --continue",
11+
"engine:dev": "turbo run engine:dev --continue",
12+
"engine:lint": "turbo run engine:lint --continue",
13+
"engine:test": "turbo run engine:test --continue",
614
"build": "turbo run build --continue",
715
"dev": "turbo run dev --continue",
816
"lint": "turbo run lint --continue",

packages/engine/src/core/application.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use super::{
1111
event_handler::{EventHandler, RawCallback},
1212
Event,
1313
},
14+
Error,
1415
};
1516

1617
pub struct Application {
@@ -36,21 +37,18 @@ impl Application {
3637
}
3738
}
3839

39-
pub fn run(&mut self) {
40+
pub fn run(&mut self) -> Result<(), Error> {
4041
// Start the engine
41-
self.engine.run();
42+
self.engine.run()?;
4243

4344
// Creates the event loop and sets it to `ControlFlow::Poll`, that way
4445
// we continously run the event loop
4546
let event_loop = EventLoop::new().unwrap();
4647
event_loop.set_control_flow(ControlFlow::Poll);
4748

48-
match event_loop.run_app(self) {
49-
Ok(_) => {}
50-
Err(err) => {
51-
log::error!("Failed to run event_loop: {}", err.to_string());
52-
}
53-
}
49+
event_loop.run_app(self)?;
50+
51+
Ok(())
5452
}
5553

5654
/// Sets the `EventHandler`.
@@ -77,7 +75,7 @@ impl ApplicationHandler for Application {
7775
) {
7876
match event {
7977
WindowEvent::CloseRequested => {
80-
self.engine.shutdown();
78+
let _ = self.engine.shutdown();
8179
}
8280
WindowEvent::RedrawRequested => {
8381
// Redraw the application

packages/engine/src/core/event/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub use window_event::WindowEvent;
1919
/// There **is** a naming convention for any `Event`:
2020
///
2121
/// - past-sentence names are refered to events that already occurred.
22+
///
2223
/// Other events are yet to occurr and reacting to them can have some sort of
2324
/// influence on the final result.
2425
///

packages/engine/src/core/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ pub mod scheduler;
1010
pub enum Error {
1111
#[error("Invalid State: expected {0} got {1}")]
1212
InvalidState(EngineState, EngineState),
13+
#[error("Event Loop Error: {0}")]
14+
EventLoopError(#[from] winit::error::EventLoopError),
1315
}

0 commit comments

Comments
 (0)