Skip to content

Commit

Permalink
Merge pull request #28 from tontsa28/next
Browse files Browse the repository at this point in the history
fix: various fixes & improvements for v0.3.0
  • Loading branch information
tontsa28 authored Sep 15, 2024
2 parents 76d4e0d + d0b87ce commit e8833c5
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 78 deletions.
11 changes: 11 additions & 0 deletions .github/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

mkdir berserk
cd berserk
git clone https://github.com/lichess-org/berserk .
git clone https://github.com/lichess-org/lila-docker
mv lila-docker/scripts/ .
rm -rf lila-docker
sed -i 's/nginx/lila:9663/g' scripts/berserk-connect-bots.py
pip install -e .
python scripts/berserk-connect-bots.py
15 changes: 12 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: licheszter integration tests

on:
push:
branches: [ main ]
branches:
- main
pull_request:
branches: [ main ]
branches:
- main
workflow_dispatch:
schedule:
- cron: '0 18 * * 6'
Expand All @@ -19,8 +21,15 @@ jobs:
options: --restart=always --name lila
ports:
- 8080:9663
lila-bots:
image: python:latest
options: -t --name lila-bots --entrypoint "/bin/sh"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Connect to bot accounts
run: docker cp ${{ github.workspace }}/.github/docker/entrypoint.sh lila-bots:/entrypoint.sh && docker exec -d lila-bots ./entrypoint.sh && sleep 5s

- name: Run all integration tests
run: cargo test --release --features=serde-strict,all -- --test-threads=1
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "licheszter"
version = "0.2.0"
version = "0.3.0"
authors = ["tontsa28 <miika@tontsa.fi>"]
license = "MIT OR Apache-2.0"
description = "An API wrapper for the Lichess API"
Expand All @@ -19,19 +19,19 @@ path = "src/lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = "1.39.2"
tokio-stream = { version = "0.1.15", default-features = false, features = ["io-util"] }
tokio-util = "0.7.11"
reqwest = { version = "0.12.5", default-features = false, features = ["stream", "rustls-tls"] }
tokio = "1.40.0"
tokio-stream = { version = "0.1.16", default-features = false, features = ["io-util"] }
tokio-util = "0.7.12"
reqwest = { version = "0.12.7", default-features = false, features = ["stream", "rustls-tls"] }
time = "0.3.36"
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.122"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
serde_with = { version = "3.9.0", features = ["time_0_3"] }
futures-util = { version = "0.3.30", default-features = false }
comma_serde_urlencoded = "0.8.1"

[dev-dependencies]
tokio = { version = "1.39.2", features = ["macros"] }
tokio = { version = "1.40.0", features = ["macros"] }

[features]
default = ["bot"]
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,32 @@ async fn main() {
}
```

## Features
Below is a list of supported API endpoints as of the last release:
| Category | Supported |
| -------- | --------- |
| Account ||
| Users ||
| Relations ||
| Games ||
| TV ||
| Puzzles ||
| Teams ||
| Bot ||
| Board ||
| Challenges ||
| Bulk pairings ||
| Arena tournaments | ❌ |
| Swiss tournaments ||
| Simuls ||
| Studies ||
| Messaging ||
| Broadcasts ||
| Analysis ||
| External engine ||
| Opening explorer ||
| Tablebase ||

## Contributions
All contributions are greatly appreciated, no matter if they provide improvements to code, documentation or anything else related to the project.
Please follow [semantic commit message](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716) guidelines in your commits.
Expand Down
12 changes: 6 additions & 6 deletions src/api/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Licheszter {
url.set_path("api/account");
let builder = self.client.get(url);

self.to_model::<User>(builder).await
self.into::<User>(builder).await
}

/// Read the email address of the logged in user.
Expand All @@ -23,7 +23,7 @@ impl Licheszter {
url.set_path("api/account/email");
let builder = self.client.get(url);

self.to_model::<Email>(builder).await
self.into::<Email>(builder).await
}

/// Read the preferences of the logged in user.
Expand All @@ -32,7 +32,7 @@ impl Licheszter {
url.set_path("api/account/preferences");
let builder = self.client.get(url);

self.to_model::<Preferences>(builder).await
self.into::<Preferences>(builder).await
}

/// Read the kid mode status of the logged in user.
Expand All @@ -41,7 +41,7 @@ impl Licheszter {
url.set_path("api/account/kid");
let builder = self.client.get(url);

self.to_model::<KidMode>(builder).await
self.into::<KidMode>(builder).await
}

/// Set the kid mode status of the logged in user.
Expand All @@ -50,7 +50,7 @@ impl Licheszter {
url.set_path("api/account/kid");
let builder = self.client.post(url).query(&[("v", kid)]);

self.to_model::<OkResponse>(builder).await
self.into::<OkResponse>(builder).await
}

/// Get the timeline events of the logged in user.
Expand All @@ -59,6 +59,6 @@ impl Licheszter {
url.set_path("api/timeline");
let builder = self.client.get(url).query(&(("since", since), ("nb", nb)));

self.to_model::<Timeline>(builder).await
self.into::<Timeline>(builder).await
}
}
22 changes: 11 additions & 11 deletions src/api/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Licheszter {
.header(header::CONTENT_TYPE, "application/x-www-form-urlencoded")
}

self.to_model_stream::<()>(builder).await
self.into_stream::<()>(builder).await
}

/// Stream game state using the Board API.
Expand All @@ -42,7 +42,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.get(url);

self.to_model_stream::<BoardState>(builder).await
self.into_stream::<BoardState>(builder).await
}

/// Make a move in a game using the Board API.
Expand All @@ -58,7 +58,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url).query(&[("offeringDraw", draw_offer)]);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -72,7 +72,7 @@ impl Licheszter {
.post(url)
.form(&(("room", room), ("text", text)));

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -83,7 +83,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.get(url);

self.to_model::<Vec<ChatMessage>>(builder).await
self.into::<Vec<ChatMessage>>(builder).await
}

/// Abort a bot game using the Board API.
Expand All @@ -93,7 +93,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -104,7 +104,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -115,7 +115,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -126,7 +126,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -137,7 +137,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -150,7 +150,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}
}
16 changes: 8 additions & 8 deletions src/api/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.get(url);

self.to_model_stream::<BoardState>(builder).await
self.into_stream::<BoardState>(builder).await
}

/// Make a move in a game using the Bot API.
Expand All @@ -36,7 +36,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url).query(&[("offeringDraw", draw_offer)]);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -50,7 +50,7 @@ impl Licheszter {
.post(url)
.form(&(("room", room), ("text", text)));

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -61,7 +61,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.get(url);

self.to_model::<Vec<ChatMessage>>(builder).await
self.into::<Vec<ChatMessage>>(builder).await
}

/// Abort a bot game using the Bot API.
Expand All @@ -71,7 +71,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -82,7 +82,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -93,7 +93,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}

Expand All @@ -104,7 +104,7 @@ impl Licheszter {
url.set_path(&path);
let builder = self.client.post(url);

self.to_model::<OkResponse>(builder).await?;
self.into::<OkResponse>(builder).await?;
Ok(())
}
}
Loading

0 comments on commit e8833c5

Please sign in to comment.