Skip to content

Commit e24976d

Browse files
committed
feat: add CI
1 parent adb7aba commit e24976d

7 files changed

Lines changed: 99 additions & 12 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
run: docker-compose -f docket-compose.test.yaml -d
74+
75+
- name: Test
76+
run: pnpm test
77+
env:
78+
SQLX_OFFLINE: true
79+
DATABASE_URL: postgresql://unen:unen@localhost/unen

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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 & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::{
1010
event::{
1111
event_handler::{EventHandler, RawCallback},
1212
Event,
13-
},
13+
}, Error,
1414
};
1515

1616
pub struct Application {
@@ -36,21 +36,18 @@ impl Application {
3636
}
3737
}
3838

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

4343
// Creates the event loop and sets it to `ControlFlow::Poll`, that way
4444
// we continously run the event loop
4545
let event_loop = EventLoop::new().unwrap();
4646
event_loop.set_control_flow(ControlFlow::Poll);
4747

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-
}
48+
event_loop.run_app(self)?;
49+
50+
Ok(())
5451
}
5552

5653
/// Sets the `EventHandler`.
@@ -77,7 +74,7 @@ impl ApplicationHandler for Application {
7774
) {
7875
match event {
7976
WindowEvent::CloseRequested => {
80-
self.engine.shutdown();
77+
let _ = self.engine.shutdown();
8178
}
8279
WindowEvent::RedrawRequested => {
8380
// 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)