make workspace build and test reproducibly

- add Gitea sparse registry config for rmath
- commit Cargo.lock
- add default-members so host tests skip GTK/wasm frontends
- fix checkers example to use DraughtsBoard::get
- add README with prerequisites and per-frontend commands
- add Gitea CI workflow (core, wasm, wasm4, MSRV)
- fix repository metadata and stop tracking generated wasm dist
This commit is contained in:
2026-10-19 19:10:39 +00:00
parent 325ee25b2e
commit 5ab62eaabc
8 changed files with 2824 additions and 31 deletions
+2
View File
@@ -0,0 +1,2 @@
[registries.gitea]
index = "sparse+https://gitea.woggioni.net/api/packages/woggioni/cargo/"
+90
View File
@@ -0,0 +1,90 @@
name: CI
on:
push:
branches: [master]
pull_request:
jobs:
core:
runs-on: woryzen
steps:
- name: Checkout
uses: https://github.com/RouxAntoine/checkout@v3.5.4
- name: Install Rust
run: rustup toolchain install stable --profile minimal
- name: Install Rust components
run: rustup component add --toolchain stable rustfmt clippy
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --check
- name: Test default members
run: cargo test --locked
- name: Test engine
run: cargo test -p rdraught --features std --lib --locked
- name: Check shared UI crate
run: cargo check -p rdraught-ui-common --locked
- name: Check CLI scratch crate
run: cargo check -p rdraught-cli --locked
- name: Clippy (advisory)
run: cargo clippy -p rdraught --features std --all-targets --locked
wasm:
runs-on: woryzen
steps:
- name: Checkout
uses: https://github.com/RouxAntoine/checkout@v3.5.4
- name: Install Rust
run: rustup toolchain install stable --profile minimal
- name: Add wasm target
run: rustup target add wasm32-unknown-unknown
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Check browser front end
working-directory: rdraught-wasm
run: cargo check --locked --target wasm32-unknown-unknown
wasm4:
runs-on: woryzen
steps:
- name: Checkout
uses: https://github.com/RouxAntoine/checkout@v3.5.4
- name: Install Rust
run: rustup toolchain install stable --profile minimal
- name: Add wasm target
run: rustup target add wasm32-unknown-unknown
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Build WASM-4 front end
working-directory: rdraught-w4
run: cargo build --release --locked --target wasm32-unknown-unknown
msrv:
runs-on: woryzen
steps:
- name: Checkout
uses: https://github.com/RouxAntoine/checkout@v3.5.4
- name: Install MSRV toolchain
run: rustup toolchain install 1.87.0 --profile minimal
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Test engine on MSRV
run: cargo +1.87.0 test -p rdraught --features std --lib --locked
- name: Check shared UI crate on MSRV
run: cargo +1.87.0 check -p rdraught-ui-common --locked
# Enable this job once the self-hosted runner has the GTK4 development
# libraries installed:
#
# gtk:
# runs-on: woryzen
# steps:
# - name: Checkout
# uses: https://github.com/RouxAntoine/checkout@v3.5.4
# - name: Install Rust
# run: rustup toolchain install stable --profile minimal
# - name: Cache
# uses: Swatinem/rust-cache@v2
# - name: Check GTK front end
# run: cargo check -p rdraught-gtk --all-targets --locked
Generated
+2606
View File
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -8,13 +8,16 @@ members = [
"rdraught-sdl",
"rdraught-ui-common",
]
# Frontends requiring system libraries or a wasm target are checked explicitly.
# See README.md for their build commands.
default-members = ["rdraught", "rdraught-ui-common"]
resolver = "3"
[workspace.package]
homepage = "https://gitea.woggioni.net/woggioni/rdraught"
authors = ["Walter Oggioni <oggioni.walter@gmail.com>"]
version = "0.1.0"
repository = "https://github.com/gtk-rs/gtk-rs-core"
repository = "https://gitea.woggioni.net/woggioni/rdraught"
license = "MIT"
edition = "2024"
rust-version = "1.87"
+119
View File
@@ -1,2 +1,121 @@
# rdraught
A draughts (checkers) engine written in Rust, with a `no_std` core library and
several front ends.
## Workspace
| Crate | Description |
| --- | --- |
| `rdraught` | `no_std` game engine, move generation, AI, and undo/redo history. |
| `rdraught-ui-common` | Small geometry and shared-state helpers used by the graphical front ends. |
| `rdraught-gtk` | GTK4 desktop front end (the most complete one). |
| `rdraught-wasm` | Browser front end using the Canvas 2D API and `wasm-bindgen`. |
| `rdraught-w4` | WASM-4 front end. Work in progress. |
| `rdraught-sdl` | SDL3 front end. Work in progress. |
| `rdraught-cli` | Scratch `rustyline` program; not a playable CLI yet. |
## Rules
The rules implemented by the engine are an 8x8 draughts variant:
- Each player starts with twelve men.
- Captures are mandatory.
- Men move one square diagonally forward.
- Men cannot capture backwards in this implementation.
- Kings move one square diagonally in any direction and can capture in any
direction.
- A man is promoted to a king when it reaches the opponent's back row.
- Draw rules (repetition, move limits) are not implemented yet.
## Requirements
- Rust 1.87 or newer. The workspace uses edition 2024.
- `rustfmt` and `clippy` for the checks described below.
- GTK4 development packages (including Graphene and librsvg) for
`rdraught-gtk`.
- The `wasm32-unknown-unknown` target and [Trunk](https://trunkrs.dev/) for
`rdraught-wasm`.
- The WASM-4 toolchain for `rdraught-w4`.
- A C/C++ toolchain for `rdraught-sdl`, which builds SDL3 from source.
On Debian/Ubuntu, the GTK front end needs packages such as:
```sh
sudo apt install libgtk-4-dev libgraphene-1.0-dev librsvg2-dev pkg-config
```
## Building and testing
The default workspace members are `rdraught` and `rdraught-ui-common`, so the
common host-side checks do not require GTK or a wasm target:
```sh
cargo test
cargo test -p rdraught --features std
cargo fmt --check
cargo clippy -p rdraught --features std --all-targets
```
The draughts and AI unit tests are gated behind the `std` feature because they
use `std::collections::HashMap`.
`cargo test --workspace` requires all front-end prerequisites (GTK libraries,
the wasm target, and the SDL build toolchain). Use the per-front-end commands
below instead.
### GTK
```sh
cargo run -p rdraught-gtk
```
### Browser WASM
```sh
rustup target add wasm32-unknown-unknown
cd rdraught-wasm
trunk serve --open
```
The `.cargo/config.toml` inside `rdraught-wasm` is only read when Cargo runs
from that directory.
### WASM-4
```sh
cd rdraught-w4
cargo build --release --target wasm32-unknown-unknown
```
Run Cargo from `rdraught-w4` so its linker configuration is applied. The
resulting module is in `target/wasm32-unknown-unknown/release/`.
### SDL3
```sh
cargo run -p rdraught-sdl
```
The first build compiles SDL3 from source and can take a while.
### CLI scratch program
```sh
cargo run -p rdraught-cli --bin rustyline-test
```
## Dependencies
`rdraught-ui-common` uses `rmath`, which is published in the author's Gitea
Cargo registry. The required registry configuration is committed in
`.cargo/config.toml`, so no extra local setup is needed:
```toml
[registries.gitea]
index = "sparse+https://gitea.woggioni.net/api/packages/woggioni/cargo/"
```
## License
MIT. See [LICENSE](LICENSE).
+1
View File
@@ -2,6 +2,7 @@ use glib::ExitCode;
use rdraught::{DraughtsBoard, DraughtsGame, Move, Piece, Player, Position};
use rdraught_gtk::run;
use std::collections::HashMap;
use std::mem::size_of;
fn main() -> ExitCode {
println!("move: {}", size_of::<Move>());
-27
View File
@@ -1,27 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<style>
body {
margin: 0px;
}
</style>
<link rel="modulepreload" href="/rdraught-wasm-1d648b9090e33d1f.js" crossorigin="anonymous" integrity="sha384-T7IqpVlu6X9Lrf6TI9E2mHL6bPl2B4DHWKUGmbtsfGa1QSmnJBFB8IRe7clx0yWb"><link rel="preload" href="/rdraught-wasm-1d648b9090e33d1f_bg.wasm" crossorigin="anonymous" integrity="sha384-v+/7HPNa68RnAHRmXFFl7L7bUCWjUJnc8AGKHfn6l5NJiPANQ7yqdGRb+abf1wyh" as="fetch" type="application/wasm"></head>
<body>
<script type="module">
import init, * as bindings from '/rdraught-wasm-1d648b9090e33d1f.js';
const wasm = await init({ module_or_path: '/rdraught-wasm-1d648b9090e33d1f_bg.wasm' });
window.wasmBindings = bindings;
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));
</script></body>
</html>
+2 -3
View File
@@ -1,5 +1,5 @@
use heapless::Vec;
use rdraught::{DraughtsBoard, Piece, Position};
use rdraught::{DraughtsBoard, Piece};
fn main() {
let board = DraughtsBoard::default();
@@ -15,8 +15,7 @@ fn main() {
board
.pieces(pieces)
.for_each(|pos| println!("({}, {}): {:?}", pos.row(), pos.col(), board[pos]));
// println!("{:?}", board[Position::new(0, 0)]);
.for_each(|pos| println!("({}, {}): {:?}", pos.row(), pos.col(), board.get(pos)));
// board
// .moves_for_piece(Position::new(2, 0), false)