Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: cargo
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 3
- package-ecosystem: npm
directories: [/web-admin, /web-console, /ui-tests]
schedule:
interval: weekly
open-pull-requests-limit: 3
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
# librocksdb-sys misses <cstdint> on newer gcc
CXXFLAGS: -include cstdint

jobs:
rust:
name: Rust (fmt, check, test)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- uses: Swatinem/rust-cache@v2

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev libasound2-dev clang libclang-dev

- name: Format check
run: cargo fmt --check

- name: Check all features
run: cargo check --all-features --all-targets

- name: Pull docker images used by tests
run: docker pull docker.io/library/alpine:latest

- name: Test
env:
DOCKER_API_VERSION: '1.45'
run: make test

frontend:
name: Frontend (${{ matrix.dir }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dir: [web-admin, web-console]
defaults:
run:
working-directory: ${{ matrix.dir }}
steps:
- uses: actions/checkout@v7

- uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
cache-dependency-path: ${{ matrix.dir }}/package-lock.json

- run: npm ci
# web-console builds against web-admin/src/shared, which needs react from web-admin
- run: npm ci --prefix ../web-admin
- run: npm run lint
- run: npm run build
- run: npm test

# Single required check for branch protection.
ci-ok:
name: ci-ok
if: always()
needs: [rust, frontend]
runs-on: ubuntu-latest
steps:
- name: Fail if a required job failed
run: |
[ "${{ needs.rust.result }}" = "success" ] && [ "${{ needs.frontend.result }}" = "success" ]
2 changes: 1 addition & 1 deletion examples/kv-examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ async fn example_kv_node_registry() -> Result<(), Box<dyn std::error::Error>> {
/// 示例6:使用Sled的持久化存储
#[cfg(feature = "sled")]
async fn example_sled_persistence() -> Result<(), Box<dyn std::error::Error>> {
use spear_next::storage::{KvStore, SledKvStore};
use spear_next::storage::{create_kv_store, KvStore, KvStoreType, SledKvStore};
use tempfile::TempDir;

println!("=== Sled Persistence Example ===");
Expand Down
3 changes: 2 additions & 1 deletion examples/kv_factory_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,14 @@ async fn create_store_based_on_conditions() -> Result<Box<dyn KvStore>, Box<dyn
{
let config = if env::var("TESTING").is_ok() {
KvStoreConfig::memory().with_param("test_mode", "true")
} else if let Ok(_db_path) = env::var("DATABASE_PATH") {
} else if let Ok(db_path) = env::var("DATABASE_PATH") {
#[cfg(feature = "sled")]
{
KvStoreConfig::sled(db_path)
}
#[cfg(not(feature = "sled"))]
{
let _ = db_path;
KvStoreConfig::memory().with_param("simulated_persistence", "true")
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/kv_storage_edge_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod test_utils {
/// Create test configurations for all supported backends
/// 为所有支持的后端创建测试配置
pub fn create_test_configs() -> Vec<(&'static str, KvStoreConfig, Option<TempDir>)> {
let configs = vec![("memory", KvStoreConfig::memory(), None)];
let mut configs = vec![("memory", KvStoreConfig::memory(), None)];

#[cfg(feature = "sled")]
{
Expand Down
2 changes: 1 addition & 1 deletion tests/kv_storage_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod test_utils {
/// Create test configurations for all supported backends
/// 为所有支持的后端创建测试配置
pub fn create_test_configs() -> Vec<(&'static str, KvStoreConfig, Option<TempDir>)> {
let configs = vec![("memory", KvStoreConfig::memory(), None)];
let mut configs = vec![("memory", KvStoreConfig::memory(), None)];

// Add Sled configuration with temporary directory
// 添加带临时目录的Sled配置
Expand Down
Loading