Skip to content

Commit 9fd390a

Browse files
authored
Merge pull request #2 from ptcodes/add-github-workflows
add github workflows to run tests, clippy and rustmt on push to main …
2 parents 0d1f807 + 8a04701 commit 9fd390a

3 files changed

Lines changed: 60 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
fmt:
14+
name: Format
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: dtolnay/rust-toolchain@stable
19+
with:
20+
components: rustfmt
21+
- run: cargo fmt --check
22+
23+
clippy:
24+
name: Clippy
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: dtolnay/rust-toolchain@stable
29+
with:
30+
components: clippy
31+
- uses: Swatinem/rust-cache@v2
32+
- run: cargo clippy -- -D warnings
33+
34+
test:
35+
name: Test
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: dtolnay/rust-toolchain@stable
40+
- uses: Swatinem/rust-cache@v2
41+
- run: cargo test

src/renderer.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,20 @@ mod tests {
5858
#[test]
5959
fn lava_color_clamps_large_input() {
6060
// v=100 * 0.35 = 35, clamped to 1.0 → same as v where v*0.35 == 1.0
61-
let Color::Rgb { r: r1, g: g1, b: b1 } = lava_color(100.0) else {
61+
let Color::Rgb {
62+
r: r1,
63+
g: g1,
64+
b: b1,
65+
} = lava_color(100.0)
66+
else {
6267
panic!("expected Rgb variant");
6368
};
64-
let Color::Rgb { r: r2, g: g2, b: b2 } = lava_color(3.0) else {
69+
let Color::Rgb {
70+
r: r2,
71+
g: g2,
72+
b: b2,
73+
} = lava_color(3.0)
74+
else {
6575
panic!("expected Rgb variant");
6676
};
6777
assert_eq!((r1, g1, b1), (r2, g2, b2));

src/simulation.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ mod tests {
5656
use super::*;
5757

5858
fn make_ball(x: f32, y: f32, vx: f32, vy: f32, radius: f32) -> Metaball {
59-
Metaball { x, y, vx, vy, radius }
59+
Metaball {
60+
x,
61+
y,
62+
vx,
63+
vy,
64+
radius,
65+
}
6066
}
6167

6268
// clamp_and_bounce tests (tested via update_balls)

0 commit comments

Comments
 (0)