Skip to content
Merged
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
77 changes: 77 additions & 0 deletions .github/workflows/release-rust-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Release Rust Client to crates.io

# Release prerequisites:
# - The `memind` crate name must be available on crates.io or owned by OpenMemind maintainers.
# - The GitHub repository must define an environment named `crates-io`.
# - The `crates-io` environment must expose a `CARGO_REGISTRY_TOKEN` secret.

on:
workflow_dispatch:
inputs:
version:
description: Rust client release version, for example 0.2.0
required: true
type: string

permissions:
contents: read

jobs:
release:
name: Build and publish Rust client
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
environment: crates-io

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Validate release version
working-directory: memind-clients/rust
shell: bash
run: |
version="${{ inputs.version }}"
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Release version must be a stable semver version like 0.2.0." >&2
exit 1
fi
package_version="$(cargo metadata --no-deps --format-version 1 | python3 -c 'import json, sys; print(json.load(sys.stdin)["packages"][0]["version"])')"
if [[ "${package_version}" != "${version}" ]]; then
echo "Workflow version ${version} does not match Cargo.toml version ${package_version}." >&2
exit 1
fi

- name: Verify
working-directory: memind-clients/rust
run: |
rustup toolchain install 1.86.0 --profile minimal
cargo +1.86.0 check --lib --all-features
cargo fmt --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-features
cargo doc --all-features --no-deps
cargo package

- name: Publish to crates.io
working-directory: memind-clients/rust
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish
82 changes: 82 additions & 0 deletions .github/workflows/rust-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Rust Client CI

on:
push:
paths:
- 'memind-clients/rust/**'
- '.github/workflows/rust-client.yml'
- '.github/workflows/release-rust-client.yml'
pull_request:
paths:
- 'memind-clients/rust/**'
- '.github/workflows/rust-client.yml'
- '.github/workflows/release-rust-client.yml'

permissions:
contents: read

jobs:
check:
name: Rust ${{ matrix.toolchain }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: [1.86.0, stable]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy

- name: Cargo check MSRV
if: matrix.toolchain == '1.86.0'
working-directory: memind-clients/rust
run: cargo check --lib --all-features

- name: Cargo check stable
if: matrix.toolchain == 'stable'
working-directory: memind-clients/rust
run: cargo check --all-targets --all-features

- name: Format check
if: matrix.toolchain == 'stable'
working-directory: memind-clients/rust
run: cargo fmt --check

- name: Clippy
if: matrix.toolchain == 'stable'
working-directory: memind-clients/rust
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Test
if: matrix.toolchain == 'stable'
working-directory: memind-clients/rust
run: cargo test --all-features

- name: Docs
if: matrix.toolchain == 'stable'
working-directory: memind-clients/rust
run: cargo doc --all-features --no-deps

- name: Package check
if: matrix.toolchain == 'stable'
working-directory: memind-clients/rust
run: cargo package
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ Official API clients:
- Python: [`memind-clients/python`](./memind-clients/python)
- Java: [`memind-clients/java`](./memind-clients/java)
- Go: [`github.com/openmemind/memind/memind-clients/go`](./memind-clients/go)
- Rust: [`memind-clients/rust`](./memind-clients/rust)

---

Expand Down
13 changes: 13 additions & 0 deletions memind-clients/rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Cargo build output.
/target/

# This directory is a library crate; Cargo generates this during local checks,
# but published dependencies are resolved by Cargo for downstream applications.
/Cargo.lock

# Local packaging and publishing scratch files.
*.crate

# Local environment files used for integration testing.
.env
.env.*
42 changes: 42 additions & 0 deletions memind-clients/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[package]
name = "memind"
version = "0.2.0"
edition = "2021"
resolver = "3"
rust-version = "1.86"
license = "Apache-2.0"
description = "Official Rust client for the Memind memory engine API"
homepage = "https://github.com/openmemind/memind"
repository = "https://github.com/openmemind/memind"
readme = "README.md"
keywords = ["memind", "memory", "ai", "client"]
categories = ["api-bindings", "web-programming::http-client"]
include = [
"Cargo.toml",
"LICENSE",
"README.md",
"src/**/*.rs",
"tests/**/*.rs",
]

[features]
default = ["rustls"]
rustls = ["reqwest/rustls"]
native-tls = ["reqwest/native-tls"]
tracing = ["dep:tracing"]

[dependencies]
fastrand = "2"
httpdate = "1"
reqwest = { version = "0.13", default-features = false, features = ["json"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "2"
time = { version = "0.3", features = ["serde", "serde-well-known", "formatting", "parsing"] }
tokio = { version = "1", default-features = false, features = ["time"] }
tracing = { version = "0.1", optional = true }
url = "2"

[dev-dependencies]
tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] }
wiremock = "0.6"
Loading
Loading