Skip to content

Commit 120a99c

Browse files
authored
test: add ci (#20)
* chore: remove version test * chore: add ci * fix: use venv for test * fix: warning
1 parent aaea81c commit 120a99c

6 files changed

Lines changed: 53 additions & 10 deletions

File tree

.github/workflows/test.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [ '3.12' ]
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- uses: dtolnay/rust-toolchain@stable
27+
28+
- name: Set up venv and install dependencies
29+
run: |
30+
python -m venv .venv
31+
. .venv/bin/activate
32+
python -m pip install --upgrade pip
33+
pip install -r requirements-dev.txt
34+
pip install maturin
35+
36+
- name: Build and install package
37+
run: |
38+
. .venv/bin/activate
39+
maturin develop --quiet
40+
41+
- name: Run tests
42+
run: |
43+
. .venv/bin/activate
44+
pytest -q
45+
46+

src/awareness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ impl Awareness {
2525
Self(loro::awareness::Awareness::new(peer, timeout))
2626
}
2727

28-
pub fn encode(&self, peers: Vec<PeerID>) -> Cow<[u8]> {
28+
pub fn encode(&self, peers: Vec<PeerID>) -> Cow<'_, [u8]> {
2929
let ans: Vec<u8> = self.0.encode(&peers);
3030
Cow::Owned(ans)
3131
}
3232

33-
pub fn encode_all(&self) -> Cow<[u8]> {
33+
pub fn encode_all(&self) -> Cow<'_, [u8]> {
3434
let ans: Vec<u8> = self.0.encode_all();
3535
Cow::Owned(ans)
3636
}

src/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub fn pyobject_to_loro_value(obj: &Bound<'_, PyAny>) -> PyResult<loro::LoroValu
125125
Err(PyTypeError::new_err("Invalid LoroValue"))
126126
}
127127

128-
pub fn loro_value_to_pyobject(py: Python, value: LoroValue) -> PyResult<Bound<'_, PyAny>> {
128+
pub fn loro_value_to_pyobject(py: Python<'_>, value: LoroValue) -> PyResult<Bound<'_, PyAny>> {
129129
match value.0 {
130130
loro::LoroValue::Null => Ok(py.None().into_pyobject(py)?.into_any().into_bound()),
131131
loro::LoroValue::Bool(b) => Ok(PyBool::new(py, b)

src/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ impl LoroDoc {
802802
}
803803

804804
/// Export the document in the given mode.
805-
pub fn export(&self, mode: ExportMode) -> PyLoroResult<Cow<[u8]>> {
805+
pub fn export(&self, mode: ExportMode) -> PyLoroResult<Cow<'_, [u8]>> {
806806
let ans = self.doc.export(mode.into())?;
807807
Ok(Cow::Owned(ans))
808808
}

src/version.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Frontiers {
4848
))
4949
}
5050

51-
pub fn encode(&self) -> Cow<[u8]> {
51+
pub fn encode(&self) -> Cow<'_, [u8]> {
5252
let ans: Vec<u8> = self.0.encode();
5353
Cow::Owned(ans)
5454
}
@@ -311,7 +311,7 @@ impl VersionVector {
311311
}
312312

313313
#[inline(always)]
314-
pub fn encode(&self) -> Cow<[u8]> {
314+
pub fn encode(&self) -> Cow<'_, [u8]> {
315315
let ans: Vec<u8> = self.0.encode();
316316
Cow::Owned(ans)
317317
}

tests/test_basic.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from loro import LoroDoc, ExportMode, VersionVector, LORO_VERSION
2-
3-
def test_version():
4-
assert LORO_VERSION == "1.4.2"
1+
from loro import LoroDoc, ExportMode, VersionVector
52

63
def test_basic():
74
doc = LoroDoc()

0 commit comments

Comments
 (0)