Skip to content

Commit 1c94373

Browse files
authored
Merge pull request #337 from adamantivm/jac/rust_cicd
Add Rust CI/CD workflow with comprehensive testing
2 parents c828c56 + 16a394c commit 1c94373

File tree

4 files changed

+121
-5
lines changed

4 files changed

+121
-5
lines changed

.github/workflows/python-app.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@ name: Python application
55

66
on:
77
push:
8-
branches: ["main"]
8+
paths:
9+
- 'deep_quoridor/src/**'
10+
- 'deep_quoridor/test/**'
11+
- 'deep_quoridor/experiments/**'
12+
- 'deep_quoridor/*requirements.txt'
13+
- '.github/workflows/python-app.yml'
914
pull_request:
10-
branches: ["main"]
15+
paths:
16+
- 'deep_quoridor/src/**'
17+
- 'deep_quoridor/test/**'
18+
- 'deep_quoridor/experiments/**'
19+
- 'deep_quoridor/*requirements.txt'
20+
- '.github/workflows/python-app.yml'
1121
workflow_dispatch:
1222
inputs:
1323
debug_enabled:

.github/workflows/rust-ci.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Rust CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'deep_quoridor/rust/**'
7+
- '.github/workflows/rust-ci.yml'
8+
pull_request:
9+
paths:
10+
- 'deep_quoridor/rust/**'
11+
- '.github/workflows/rust-ci.yml'
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
test:
19+
name: Test
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Install Rust toolchain
27+
uses: dtolnay/rust-toolchain@stable
28+
with:
29+
components: rustfmt, clippy
30+
31+
- name: Cache cargo registry
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.cargo/registry
35+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
36+
restore-keys: |
37+
${{ runner.os }}-cargo-registry-
38+
39+
- name: Cache cargo index
40+
uses: actions/cache@v4
41+
with:
42+
path: ~/.cargo/git
43+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
44+
restore-keys: |
45+
${{ runner.os }}-cargo-git-
46+
47+
- name: Check formatting
48+
working-directory: deep_quoridor/rust
49+
run: cargo fmt --all -- --check
50+
51+
- name: Run clippy
52+
working-directory: deep_quoridor/rust
53+
run: cargo clippy --all-targets --all-features
54+
55+
- name: Build
56+
working-directory: deep_quoridor/rust
57+
run: cargo build --verbose
58+
59+
- name: Run tests with all features
60+
working-directory: deep_quoridor/rust
61+
env:
62+
RUST_BACKTRACE: 1
63+
run: cargo test --all-features --verbose
64+
65+
- name: Build release
66+
working-directory: deep_quoridor/rust
67+
run: cargo build --release --verbose
68+
69+
build-python-extension:
70+
name: Build Python Extension
71+
runs-on: ubuntu-latest
72+
73+
steps:
74+
- name: Checkout code
75+
uses: actions/checkout@v4
76+
77+
- name: Set up Python
78+
uses: actions/setup-python@v5
79+
with:
80+
python-version: "3.12"
81+
82+
- name: Install Rust toolchain
83+
uses: dtolnay/rust-toolchain@stable
84+
85+
- name: Install maturin
86+
run: pip install maturin
87+
88+
- name: Build Python wheel
89+
working-directory: deep_quoridor/rust
90+
run: maturin build --release
91+
92+
- name: Test Python import
93+
working-directory: deep_quoridor/rust
94+
run: |
95+
pip install target/wheels/*.whl
96+
python -c "import quoridor_rs; print('Successfully imported quoridor_rs')"

deep_quoridor/rust/src/compact/q_game_mechanics.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,12 @@ mod tests {
685685
// This should be invalid if it blocks the only remaining path
686686
// (depends on whether there's still a way around)
687687

688-
// For now, just test that pathfinding completes without error
689-
assert!(is_valid || !is_valid, "Pathfinding should complete");
688+
// Log the result to verify pathfinding completed
689+
eprintln!(
690+
"Pathfinding completed successfully: wall at (2,1) is {}",
691+
if is_valid { "valid" } else { "invalid" }
692+
);
693+
// Test passes as long as we get here without panic
690694
}
691695

692696
#[test]

deep_quoridor/rust/src/validation.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,13 @@ pub fn is_wall_action_valid_mut(
199199
}
200200

201201
// Check if wall cells are free
202-
if !check_wall_cells(&grid.view(), wall_row, wall_col, wall_orientation, CELL_FREE) {
202+
if !check_wall_cells(
203+
&grid.view(),
204+
wall_row,
205+
wall_col,
206+
wall_orientation,
207+
CELL_FREE,
208+
) {
203209
return false;
204210
}
205211

0 commit comments

Comments
 (0)