Skip to content

Commit 606249a

Browse files
authored
Improve and fix github actions and workflow (#123)
1 parent e78e4f9 commit 606249a

File tree

14 files changed

+110
-50
lines changed

14 files changed

+110
-50
lines changed

.github/workflows/cross_build.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: cross-build
2+
3+
on:
4+
push:
5+
branches:
6+
- improve-and-fix-workflow
7+
# pull_request:
8+
# types: [closed]
9+
# branches:
10+
# - main
11+
12+
jobs:
13+
wait-for-other-workflow:
14+
name: Wait for Other Workflow
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Wait for Other Workflow to Complete
18+
run: "echo 'Waiting for other workflow to complete...'"
19+
20+
build:
21+
if: github.event.pull_request.merged == true
22+
name: Build C release for ${{ matrix.os.name }}
23+
strategy:
24+
matrix:
25+
os:
26+
- name: ubuntu
27+
lib: libsurrealdb_c.so
28+
- name: macos
29+
lib: libsurrealdb_c.dylib
30+
- name: windows
31+
lib: surrealdb_c.dll
32+
runs-on: ${{ format('{0}-latest', matrix.os.name) }}
33+
steps:
34+
- name: Checkout Surreal C lib
35+
uses: actions/checkout@v3
36+
with:
37+
repository: surrealdb/surrealdb.c
38+
39+
- name: Set up Rust
40+
uses: actions-rs/toolchain@v1
41+
with:
42+
toolchain: stable
43+
override: true
44+
45+
- name: Build Rust library
46+
run: cargo build --release
47+
48+
- name: Archive library
49+
run: |
50+
mkdir -p dist/${{ matrix.os.name }}
51+
cp target/release/${{ matrix.os.lib }} dist/${{ matrix.os.name }}/${{ matrix.os.lib }}
52+
53+
- name: Upload build artifacts
54+
uses: actions/upload-artifact@v3
55+
with:
56+
name: ${{ matrix.os.name }}-build
57+
path: dist/${{ matrix.os.name }}

.github/workflows/unit_tests.yml

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
name: unit-tests
22

33
on:
4+
push:
5+
branches:
6+
- main
47
pull_request:
5-
# push:
68
branches:
79
- "*"
810

911
jobs:
1012
run-unit-tests:
1113
runs-on: ubuntu-latest
1214
strategy:
15+
fail-fast: false
1316
matrix:
14-
python-version: [ "3.7", "3.8", "3.9", "3.10" ]
15-
17+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
18+
surrealdb-version: ["v2.0.0", "v2.1.1", "v2.1.2"] # Issue with v2.1.0
19+
name: Run unit test SurrealDB ${{ matrix.surrealdb-version }} - Python Version ${{ matrix.python-version }}
1620
steps:
17-
- uses: actions/checkout@v3
18-
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v4
20-
with:
21-
python-version: ${{ matrix.python-version }}
22-
- name: Build for tests
23-
run: |
24-
python tests/scripts/local_build_ci.py
25-
pip install docker
26-
pip install requests
27-
# docker-compose build
28-
# docker-compose up -d
29-
# sleep 2
30-
31-
- name: Run Tests
32-
run: sh scripts/run_tests.sh
21+
- name: Checkout repository
22+
uses: actions/checkout@v3
23+
24+
- name: Download and install surrealdb
25+
run: curl -sSf https://install.surrealdb.com | sh -s -- --version ${{ matrix.surrealdb-version }}
26+
27+
- name: Start surrealdb
28+
run: surreal start memory -u root -p root --log trace & sleep 5 &
29+
30+
- name: Install dependencies
31+
run: pip install -r requirements.txt
32+
33+
- name: Run unit tests
34+
env:
35+
SURREALDB_URL: "http://localhost:8000"
36+
run: python -m unittest discover -s tests
37+
38+
3339

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.PHONY: test test_versions
2+
3+
test:
4+
python -m unittest discover -s tests
5+
6+
test_versions:
7+
python tests/scripts/runner.py

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cbor2==5.6.5
2-
docker_py==1.10.6
2+
docker==7.1.0
33
Requests==2.32.3
4-
setuptools==63.2.0
54
setuptools==65.5.1
65
setuptools_rust==1.6.0
76
websockets==14.1

surrealdb/connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class RequestData:
2525

2626
class Connection:
2727
_queues: Dict[int, dict]
28+
_locks: Dict[int, threading.Lock]
2829
_namespace: str | None = None
2930
_database: str | None = None
3031
_auth_token: str | None = None

tests/integration/async/test_live.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ async def asyncSetUp(self):
1818
await self.db.sign_in("root", "root")
1919

2020
async def test_live(self):
21-
live_id = await self.db.live(Table("users"))
22-
print("Live id: ", live_id)
21+
if self.params.protocol.lower() == "ws":
22+
live_id = await self.db.live(Table("users"))
23+
live_queue = await self.db.live_notifications(live_id)
2324

24-
live_queue = await self.db.live_notifications(live_id)
25+
await self.db.query("CREATE users;")
2526

26-
await self.db.query("CREATE users;")
27-
28-
notification_data = await asyncio.wait_for(live_queue.get(), 10) # Set timeout
29-
self.assertEqual(notification_data.get("id"), live_id)
30-
self.assertEqual(notification_data.get("action"), "CREATE")
27+
notification_data = await asyncio.wait_for(live_queue.get(), 10) # Set timeout
28+
self.assertEqual(notification_data.get("id"), live_id)
29+
self.assertEqual(notification_data.get("action"), "CREATE")
3130

3231

tests/integration/async/test_update.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Tests the Update operation of the AsyncSurrealDB class with query and update function.
33
"""
44

5-
import asyncio
65
from typing import List
76
from unittest import IsolatedAsyncioTestCase, main
87

tests/integration/blocking/test_auth.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Handles the integration tests for logging into the database using blocking operations.
33
"""
44

5-
import os
65
from unittest import TestCase, main
76

87
from surrealdb import SurrealDB

tests/integration/blocking/test_live.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ def setUp(self):
1818
self.db.sign_in("root", "root")
1919

2020
def test_live(self):
21-
live_id = self.db.live(Table("users"))
22-
print("Live id: ", live_id)
21+
if self.params.protocol.lower() == "ws":
22+
live_id = self.db.live(Table("users"))
23+
live_queue = self.db.live_notifications(live_id)
2324

24-
live_queue = self.db.live_notifications(live_id)
25+
self.db.query("CREATE users;")
2526

26-
self.db.query("CREATE users;")
27-
28-
loop_manager = AsyncioRuntime()
29-
notification_data = loop_manager.loop.run_until_complete(live_queue.get())
30-
self.assertEqual(notification_data.get("id"), live_id)
31-
self.assertEqual(notification_data.get("action"), "CREATE")
27+
loop_manager = AsyncioRuntime()
28+
notification_data = loop_manager.loop.run_until_complete(live_queue.get())
29+
self.assertEqual(notification_data.get("id"), live_id)
30+
self.assertEqual(notification_data.get("action"), "CREATE")
3231

3332

tests/integration/blocking/test_update.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ def test_update_person_with_tags(self):
6464
},
6565
)
6666

67-
print("outcome: ", outcome)
68-
6967
self.assertEqual(
7068
{
7169
"id": RecordID.parse("person:失败"),

0 commit comments

Comments
 (0)