Skip to content

Commit 015963b

Browse files
committed
chore: add CI workflow for rust 🚀
- Enable automated build and test for push and pull requests - Config matrix for stable, beta, and nightly toolchains - Run clippy, fmt, build, and test
1 parent 534b24f commit 015963b

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

.github/workflows/rust.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!#
2+
# Copyright (c) 2025 Hangzhou Guanwaii Technology Co,.Ltd.
3+
#
4+
# This source code is licensed under the MIT License,
5+
# which is located in the LICENSE file in the source tree's root directory.
6+
#
7+
# File: rust.yml
8+
# Author: mingcheng ([email protected])
9+
# File Created: 2025-03-05 11:10:40
10+
#
11+
# Modified By: mingcheng ([email protected])
12+
# Last Modified: 2025-03-05 11:12:03
13+
##
14+
15+
name: Cargo Build & Test
16+
17+
on:
18+
push:
19+
pull_request:
20+
21+
env:
22+
CARGO_TERM_COLOR: always
23+
24+
jobs:
25+
build_and_test:
26+
name: Rust project - latest
27+
runs-on: ubuntu-latest
28+
strategy:
29+
matrix:
30+
toolchain:
31+
- stable
32+
- beta
33+
- nightly
34+
steps:
35+
- uses: actions/checkout@v4
36+
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
37+
- run: cargo clippy -- -D warnings
38+
- run: cargo fmt --all -- --check
39+
- run: cargo build --verbose
40+
- run: cargo test --verbose

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ keywords = [
1616
]
1717
authors = ["mingcheng<[email protected]"]
1818
repository = "https://github.com/mingcheng/aigitcommit"
19+
homepage = "https://github.com/mingcheng/aigitcommit"
20+
exclude = ["assets/*", "hooks/*"]
1921

2022
[dependencies]
2123
reqwest = { version = "0.12.12", features = [

src/openai.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* File Created: 2025-03-01 21:55:58
1010
*
1111
* Modified By: mingcheng ([email protected])
12-
* Last Modified: 2025-03-05 10:41:39
12+
* Last Modified: 2025-03-05 10:46:26
1313
*/
1414

1515
use askama::Template;
@@ -46,6 +46,8 @@ impl Default for OpenAI {
4646
}
4747

4848
impl OpenAI {
49+
/// Create a new OpenAI client instance.
50+
/// This function sets up the OpenAI client with the API key, base URL, and optional proxy settings.
4951
pub fn new() -> Self {
5052
// Set up OpenAI client configuration
5153
let ai_config = OpenAIConfig::new()
@@ -80,13 +82,16 @@ impl OpenAI {
8082
OpenAI { client }
8183
}
8284

85+
#[deprecated]
86+
/// Check if the OpenAI API is reachable.
8387
pub async fn check(&self) -> Result<(), Box<dyn Error>> {
8488
match self.client.models().list().await {
8589
Ok(_) => Ok(()),
8690
Err(e) => Err(e.into()),
8791
}
8892
}
8993

94+
/// Send a chat message to the OpenAI API and return the response.
9095
pub async fn chat(
9196
&self,
9297
model_name: &str,

0 commit comments

Comments
 (0)