From d79a520ce0027322b70300bc85e7ae0df4ae58f0 Mon Sep 17 00:00:00 2001 From: Remade Date: Tue, 26 Nov 2024 20:43:42 +0100 Subject: [PATCH 01/15] WIP --- .github/workflows/unit_tests.yml | 58 ++++++++++++++++------- requirements.txt | 3 +- surrealdb/connection.py | 1 + tests/integration/async/test_live.py | 15 +++--- tests/integration/async/test_update.py | 1 - tests/integration/blocking/test_auth.py | 1 - tests/integration/blocking/test_live.py | 17 ++++--- tests/integration/blocking/test_update.py | 2 - tests/unit/test_cbor.py | 4 +- tests/unit/test_ws_connection.py | 2 - 10 files changed, 60 insertions(+), 44 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index fea55156..254689d8 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -1,8 +1,10 @@ name: unit-tests on: + push: + branches: + - main pull_request: - # push: branches: - "*" @@ -11,23 +13,47 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ "3.7", "3.8", "3.9", "3.10" ] - +# python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] +# surrealdb-version: [ "v2.0.0", "v1.2.1", "v1.2.0", "v1.0.1", "v1.1.1", "v1.1.0", "v1.0.1", "1.0.0"] + python-version: [ "3.9"] + surrealdb-version: [ "v2.0.0"] + services: + surrealdb: + image: surrealdb/surrealdb:${{ matrix.surrealdb-version }} + ports: + - 8000:8000 + options: >- + --health-cmd="curl --fail http://localhost:8000 || exit 1" + --health-interval=10s + --health-timeout=5s + --health-retries=3 steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} - - name: Build for tests - run: | - python tests/scripts/local_build_ci.py - pip install docker - pip install requests -# docker-compose build -# docker-compose up -d -# sleep 2 + python-version: '3.9' + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Run unit tests + env: + SURREALDB_URL: "http://localhost:8000" + run: python -m unittest discover -s tests - - name: Run Tests - run: sh scripts/run_tests.sh +# - uses: actions/checkout@v3 +# - name: Set up Python ${{ matrix.python-version }} +# uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python-version }} +# - name: Build for tests +# run: | +# python tests/scripts/local_build_ci.py +# pip install docker +# pip install requests +# - name: Run Tests +# run: sh scripts/run_tests.sh diff --git a/requirements.txt b/requirements.txt index 29208180..db002b1c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ cbor2==5.6.5 -docker_py==1.10.6 +docker==7.1.0 Requests==2.32.3 -setuptools==63.2.0 setuptools==65.5.1 setuptools_rust==1.6.0 websockets==14.1 diff --git a/surrealdb/connection.py b/surrealdb/connection.py index 5279c2ae..ad8c75e3 100644 --- a/surrealdb/connection.py +++ b/surrealdb/connection.py @@ -25,6 +25,7 @@ class RequestData: class Connection: _queues: Dict[int, dict] + _locks: Dict[int, threading.Lock] _namespace: str | None = None _database: str | None = None _auth_token: str | None = None diff --git a/tests/integration/async/test_live.py b/tests/integration/async/test_live.py index ddec1f7e..3989e6fd 100644 --- a/tests/integration/async/test_live.py +++ b/tests/integration/async/test_live.py @@ -18,15 +18,14 @@ async def asyncSetUp(self): await self.db.sign_in("root", "root") async def test_live(self): - live_id = await self.db.live(Table("users")) - print("Live id: ", live_id) + if self.params.protocol.lower() == "ws": + live_id = await self.db.live(Table("users")) + live_queue = await self.db.live_notifications(live_id) - live_queue = await self.db.live_notifications(live_id) + await self.db.query("CREATE users;") - await self.db.query("CREATE users;") - - notification_data = await asyncio.wait_for(live_queue.get(), 10) # Set timeout - self.assertEqual(notification_data.get("id"), live_id) - self.assertEqual(notification_data.get("action"), "CREATE") + notification_data = await asyncio.wait_for(live_queue.get(), 10) # Set timeout + self.assertEqual(notification_data.get("id"), live_id) + self.assertEqual(notification_data.get("action"), "CREATE") diff --git a/tests/integration/async/test_update.py b/tests/integration/async/test_update.py index 5d501086..912d09c5 100644 --- a/tests/integration/async/test_update.py +++ b/tests/integration/async/test_update.py @@ -2,7 +2,6 @@ Tests the Update operation of the AsyncSurrealDB class with query and update function. """ -import asyncio from typing import List from unittest import IsolatedAsyncioTestCase, main diff --git a/tests/integration/blocking/test_auth.py b/tests/integration/blocking/test_auth.py index 31851d1a..94f45b51 100644 --- a/tests/integration/blocking/test_auth.py +++ b/tests/integration/blocking/test_auth.py @@ -2,7 +2,6 @@ Handles the integration tests for logging into the database using blocking operations. """ -import os from unittest import TestCase, main from surrealdb import SurrealDB diff --git a/tests/integration/blocking/test_live.py b/tests/integration/blocking/test_live.py index dcb27ddf..e362b2d7 100644 --- a/tests/integration/blocking/test_live.py +++ b/tests/integration/blocking/test_live.py @@ -18,16 +18,15 @@ def setUp(self): self.db.sign_in("root", "root") def test_live(self): - live_id = self.db.live(Table("users")) - print("Live id: ", live_id) + if self.params.protocol.lower() == "ws": + live_id = self.db.live(Table("users")) + live_queue = self.db.live_notifications(live_id) - live_queue = self.db.live_notifications(live_id) + self.db.query("CREATE users;") - self.db.query("CREATE users;") - - loop_manager = AsyncioRuntime() - notification_data = loop_manager.loop.run_until_complete(live_queue.get()) - self.assertEqual(notification_data.get("id"), live_id) - self.assertEqual(notification_data.get("action"), "CREATE") + loop_manager = AsyncioRuntime() + notification_data = loop_manager.loop.run_until_complete(live_queue.get()) + self.assertEqual(notification_data.get("id"), live_id) + self.assertEqual(notification_data.get("action"), "CREATE") diff --git a/tests/integration/blocking/test_update.py b/tests/integration/blocking/test_update.py index 6bab1471..2b3488b6 100644 --- a/tests/integration/blocking/test_update.py +++ b/tests/integration/blocking/test_update.py @@ -64,8 +64,6 @@ def test_update_person_with_tags(self): }, ) - print("outcome: ", outcome) - self.assertEqual( { "id": RecordID.parse("person:失败"), diff --git a/tests/unit/test_cbor.py b/tests/unit/test_cbor.py index bc9ca4f2..45139a96 100644 --- a/tests/unit/test_cbor.py +++ b/tests/unit/test_cbor.py @@ -47,6 +47,4 @@ def test_uuid(self): uid = uuid.uuid4() encoded = encode(uid) decoded = decode(encoded) - print(encoded.hex()) - print(uid) - print(decoded) + diff --git a/tests/unit/test_ws_connection.py b/tests/unit/test_ws_connection.py index 1802d8e4..d79d0d8d 100644 --- a/tests/unit/test_ws_connection.py +++ b/tests/unit/test_ws_connection.py @@ -19,8 +19,6 @@ async def test_send(self): self.ws_con.set_token(token) live_id = await self.ws_con.send("live", "users") - print("Live id: ", live_id) - live_queue = await self.ws_con.live_notifications(live_id) await self.ws_con.send("query", "CREATE users;") From 49109b32eb0819472e83282e0ba3686796c8cfe2 Mon Sep 17 00:00:00 2001 From: Remade Date: Wed, 27 Nov 2024 03:49:36 +0100 Subject: [PATCH 02/15] WIP --- .github/workflows/unit_tests.yml | 41 +++++++++++++------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 254689d8..6904f0a6 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -17,24 +17,26 @@ jobs: # surrealdb-version: [ "v2.0.0", "v1.2.1", "v1.2.0", "v1.0.1", "v1.1.1", "v1.1.0", "v1.0.1", "1.0.0"] python-version: [ "3.9"] surrealdb-version: [ "v2.0.0"] - services: - surrealdb: - image: surrealdb/surrealdb:${{ matrix.surrealdb-version }} - ports: - - 8000:8000 - options: >- - --health-cmd="curl --fail http://localhost:8000 || exit 1" - --health-interval=10s - --health-timeout=5s - --health-retries=3 steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: addnab/docker-run-action@v3 with: - python-version: '3.9' + image: surrealdb/surrealdb:${{ matrix.surrealdb-version }} + shell: bash + options: >- + --health-cmd is-ready + --health-interval 10s + --health-timeout 5s + --health-retries 3 + -p 8000:8000 + run: ./surreal start memory -u root -p root --log trac +# - name: Download and install surrealdb +# run: curl -sSf https://install.surrealdb.com | sh +# +# - name: Start surrealdb +# run: surreal start memory -u root -p root --log trace - name: Install dependencies run: pip install -r requirements.txt @@ -44,16 +46,5 @@ jobs: SURREALDB_URL: "http://localhost:8000" run: python -m unittest discover -s tests -# - uses: actions/checkout@v3 -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v4 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Build for tests -# run: | -# python tests/scripts/local_build_ci.py -# pip install docker -# pip install requests -# - name: Run Tests -# run: sh scripts/run_tests.sh + From a3ffc83e8ab16ff6b3615b9cecd3cba2238bf8a8 Mon Sep 17 00:00:00 2001 From: Remade Date: Wed, 27 Nov 2024 03:59:00 +0100 Subject: [PATCH 03/15] WIP --- .github/workflows/unit_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 6904f0a6..78751d3b 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -31,7 +31,7 @@ jobs: --health-timeout 5s --health-retries 3 -p 8000:8000 - run: ./surreal start memory -u root -p root --log trac + run: ./surreal start memory -u root -p root --log trac & sleep 5 & # - name: Download and install surrealdb # run: curl -sSf https://install.surrealdb.com | sh # From a1c4cd4400911c31c90aa47d76021618c9c3ec6a Mon Sep 17 00:00:00 2001 From: Remade Date: Wed, 27 Nov 2024 04:00:11 +0100 Subject: [PATCH 04/15] WIP --- .github/workflows/unit_tests.yml | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 78751d3b..dcd6e260 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -21,22 +21,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - uses: addnab/docker-run-action@v3 - with: - image: surrealdb/surrealdb:${{ matrix.surrealdb-version }} - shell: bash - options: >- - --health-cmd is-ready - --health-interval 10s - --health-timeout 5s - --health-retries 3 - -p 8000:8000 - run: ./surreal start memory -u root -p root --log trac & sleep 5 & -# - name: Download and install surrealdb -# run: curl -sSf https://install.surrealdb.com | sh -# -# - name: Start surrealdb -# run: surreal start memory -u root -p root --log trace + - name: Download and install surrealdb + run: curl -sSf https://install.surrealdb.com | sh + + - name: Start surrealdb + run: surreal start memory -u root -p root --log trace & sleep 5 & - name: Install dependencies run: pip install -r requirements.txt From 9399e4bff90ea4e1354d44ce47c6f0534a267c48 Mon Sep 17 00:00:00 2001 From: Remade Date: Wed, 27 Nov 2024 04:02:58 +0100 Subject: [PATCH 05/15] WIP --- tests/unit/test_clib_connection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_clib_connection.py b/tests/unit/test_clib_connection.py index 8f5c959a..10766073 100644 --- a/tests/unit/test_clib_connection.py +++ b/tests/unit/test_clib_connection.py @@ -11,5 +11,5 @@ async def asyncSetUp(self): self.clib = CLibConnection(base_url='surrealkv://', logger=self.logger, encoder=encode, decoder=decode) await self.clib.connect() - async def test_send(self): - await self.clib.send('use', "test_ns", "test_db") + # async def test_send(self): + # await self.clib.send('use', "test_ns", "test_db") From 3d835fcc9606d76ed4ec53e8cfc7063911adbf07 Mon Sep 17 00:00:00 2001 From: Remade Date: Wed, 27 Nov 2024 04:07:38 +0100 Subject: [PATCH 06/15] WIP --- .github/workflows/unit_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index dcd6e260..a96110d8 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: -# python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] + python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] # surrealdb-version: [ "v2.0.0", "v1.2.1", "v1.2.0", "v1.0.1", "v1.1.1", "v1.1.0", "v1.0.1", "1.0.0"] - python-version: [ "3.9"] surrealdb-version: [ "v2.0.0"] + name: Run unit test SurrealDB ${{ matrix.surrealdb-version }} - Python Version ${{ matrix.python-version }} steps: - name: Checkout repository uses: actions/checkout@v3 From b21f30f226305894c652036d0fd24444adce1fb0 Mon Sep 17 00:00:00 2001 From: Remade Date: Wed, 27 Nov 2024 04:26:09 +0100 Subject: [PATCH 07/15] WIP --- .github/workflows/unit_tests.yml | 5 +- tests/scripts/runner.py | 105 ------------------------------- 2 files changed, 2 insertions(+), 108 deletions(-) delete mode 100644 tests/scripts/runner.py diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index a96110d8..0e81320a 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -14,15 +14,14 @@ jobs: strategy: matrix: python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] -# surrealdb-version: [ "v2.0.0", "v1.2.1", "v1.2.0", "v1.0.1", "v1.1.1", "v1.1.0", "v1.0.1", "1.0.0"] - surrealdb-version: [ "v2.0.0"] + surrealdb-version: [ "v1.5.6", "v2.0.0", "v2.1.0", "v2.1.1", "v2.1.2"] name: Run unit test SurrealDB ${{ matrix.surrealdb-version }} - Python Version ${{ matrix.python-version }} steps: - name: Checkout repository uses: actions/checkout@v3 - name: Download and install surrealdb - run: curl -sSf https://install.surrealdb.com | sh + run: curl -sSf https://install.surrealdb.com | sh -s -- --version ${{ matrix.surrealdb-version }} - name: Start surrealdb run: surreal start memory -u root -p root --log trace & sleep 5 & diff --git a/tests/scripts/runner.py b/tests/scripts/runner.py deleted file mode 100644 index aca119e9..00000000 --- a/tests/scripts/runner.py +++ /dev/null @@ -1,105 +0,0 @@ -""" -Testing script that runs all the tests and handles the Docker containers as well as the tests. -""" - -import os -import time -import unittest - -import docker - -TEST_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..") -ROOT_DIR = os.path.join(TEST_DIR, "..") -os.environ["PYTHONPATH"] = ROOT_DIR -DOCKER_CLIENT = docker.from_env() - - -class DbInstance: - """ - Handles the Docker container for the SurrealDB. - - Attributes: - version (str): The version of the SurrealDB to run. - port (int): The port to run the SurrealDB on. - container (docker.models.containers.Container): The Docker container instance. - id (str): The id of the Docker container. - """ - - def __init__(self, version: str, port: int = 8000) -> None: - """ - The constructor for the DbInstance class. - - :param version: The version of the SurrealDB to run. - :param port: The port to run the SurrealDB on. - """ - self.version: str = version - self.port: int = port - self.container = None - self.id = None - - def start(self) -> None: - """ - Starts the Docker container. - - :return: None - """ - self.container = DOCKER_CLIENT.containers.run( - image=f"surrealdb/surrealdb:{self.version}", - command="start", - environment={ - "SURREAL_USER": "root", - "SURREAL_PASS": "root", - "SURREAL_LOG": "trace", - }, - ports={"8000/tcp": self.port}, - detach=True, - ) - self.id = self.container.id - - def stop(self) -> None: - """ - Stops the Docker container. - - :return: None - """ - self.container.stop() - - def remove(self) -> None: - """ - Removes the Docker container. - - :return: None - """ - self.container.remove() - - -def run_tests(port: int, protocol: str) -> None: - os.environ["CONNECTION_PROTOCOL"] = f"{protocol}" - os.environ["CONNECTION_PORT"] = f"{port}" - test_loader = unittest.TestLoader() - test_suite = test_loader.discover(start_dir=TEST_DIR, pattern="test*.py") - test_runner = unittest.TextTestRunner(verbosity=2) - _ = test_runner.run(test_suite) - - -if __name__ == "__main__": - port = 8000 - for version in [ - "v2.0.0", - "v1.2.1", - "v1.2.0", - "v1.0.1", - "v1.1.1", - "v1.1.0", - "v1.0.1", - "1.0.0", - ]: - container = DbInstance(version=version, port=port) - container.start() - time.sleep(0.3) - print(f"Running tests for version {version} on port {container.port}") - run_tests(port=container.port, protocol="http") - run_tests(port=container.port, protocol="ws") - container.stop() - container.remove() - port += 1 From b81d940cc3bd137f0a9ea6609da4e7daa67f4041 Mon Sep 17 00:00:00 2001 From: Remade Date: Wed, 27 Nov 2024 04:33:30 +0100 Subject: [PATCH 08/15] WIP --- .github/workflows/unit_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 0e81320a..0bacf758 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] - surrealdb-version: [ "v1.5.6", "v2.0.0", "v2.1.0", "v2.1.1", "v2.1.2"] + surrealdb-version: ["v2.1.1", "v2.1.2"] name: Run unit test SurrealDB ${{ matrix.surrealdb-version }} - Python Version ${{ matrix.python-version }} steps: - name: Checkout repository From 026c3dfc3dbea0830ef48e673489790b18ce8ba7 Mon Sep 17 00:00:00 2001 From: Remade Date: Wed, 27 Nov 2024 05:00:51 +0100 Subject: [PATCH 09/15] Updated unit test workflow --- Makefile | 7 +++ tests/scripts/runner.py | 105 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 Makefile create mode 100644 tests/scripts/runner.py diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..ddaa66fc --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: test test_versions + +test: + python -m unittest discover -s tests + +test_versions: + python tests/scripts/runner.py diff --git a/tests/scripts/runner.py b/tests/scripts/runner.py new file mode 100644 index 00000000..ef4e5790 --- /dev/null +++ b/tests/scripts/runner.py @@ -0,0 +1,105 @@ +""" +Testing script that runs all the tests and handles the Docker containers as well as the tests. +""" + +import os +import time +import unittest + +import docker + +TEST_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..") +ROOT_DIR = os.path.join(TEST_DIR, "..") +os.environ["PYTHONPATH"] = ROOT_DIR +DOCKER_CLIENT = docker.from_env() + + +class DbInstance: + """ + Handles the Docker container for the SurrealDB. + + Attributes: + version (str): The version of the SurrealDB to run. + port (int): The port to run the SurrealDB on. + container (docker.models.containers.Container): The Docker container instance. + id (str): The id of the Docker container. + """ + + def __init__(self, version: str, port: int = 8000) -> None: + """ + The constructor for the DbInstance class. + + :param version: The version of the SurrealDB to run. + :param port: The port to run the SurrealDB on. + """ + self.version: str = version + self.port: int = port + self.container = None + self.id = None + + def start(self) -> None: + """ + Starts the Docker container. + + :return: None + """ + self.container = DOCKER_CLIENT.containers.run( + image=f"surrealdb/surrealdb:{self.version}", + command="start", + environment={ + "SURREAL_USER": "root", + "SURREAL_PASS": "root", + "SURREAL_LOG": "trace", + }, + ports={"8000/tcp": self.port}, + detach=True, + ) + self.id = self.container.id + + def stop(self) -> None: + """ + Stops the Docker container. + + :return: None + """ + self.container.stop() + + def remove(self) -> None: + """ + Removes the Docker container. + + :return: None + """ + self.container.remove() + + +def run_tests(port: int, protocol: str) -> None: + os.environ["CONNECTION_PROTOCOL"] = f"{protocol}" + os.environ["CONNECTION_PORT"] = f"{port}" + test_loader = unittest.TestLoader() + test_suite = test_loader.discover(start_dir=TEST_DIR, pattern="test*.py") + test_runner = unittest.TextTestRunner(verbosity=2) + _ = test_runner.run(test_suite) + + +if __name__ == "__main__": + port = 8000 + for version in [ + "v2.0.0", + "v1.2.1", + "v1.2.0", + "v1.0.1", + "v1.1.1", + "v1.1.0", + "v1.0.1", + "1.0.0", + ]: + container = DbInstance(version=version, port=port) + container.start() + time.sleep(0.3) + print(f"Running tests for version {version} on port {container.port}") + run_tests(port=container.port, protocol="http") + run_tests(port=container.port, protocol="ws") + container.stop() + container.remove() + port += 1 \ No newline at end of file From 5164a48e9669f109b8d093fa420d730977daf9d9 Mon Sep 17 00:00:00 2001 From: Remade Date: Wed, 27 Nov 2024 14:19:03 +0100 Subject: [PATCH 10/15] Build WIP --- .github/workflows/cross_build.yml | 54 +++++++++++++++++++++++++++++++ .github/workflows/unit_tests.yml | 3 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cross_build.yml diff --git a/.github/workflows/cross_build.yml b/.github/workflows/cross_build.yml new file mode 100644 index 00000000..8ab34437 --- /dev/null +++ b/.github/workflows/cross_build.yml @@ -0,0 +1,54 @@ +name: cross-build + +on: + pull_request: + types: [closed] + branches: + - main + +jobs: + wait-for-other-workflow: + name: Wait for Other Workflow + runs-on: ubuntu-latest + steps: + - name: Wait for Other Workflow to Complete + run: "echo 'Waiting for other workflow to complete...'" + + build: +# if: github.event.pull_request.merged == true + name: build for ${{ matrix.os }} + strategy: + matrix: + os: + - name: ubuntu + lib: libsurrealdb_c.so + - name: macos + lib: libsurrealdb_c.dylib + - name: windows + lib: surrealdb_c.dll + runs-on: ${{ format('{0}-latest', matrix.os.name) }} + steps: + - name: Checkout Surreal C lib + uses: actions/checkout@v3 + with: + repository: https://github.com/surrealdb/surrealdb.c + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Build Rust library + run: cargo build --release + + - name: Archive library + run: | + mkdir -p dist/${{ matrix.os.name }} + cp target/release/${{ matrix.os.lib }} dist/${{ matrix.os.name }}/${{ matrix.os.lib }} + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.os.name }}-build + path: dist/${{ matrix.os.name }} \ No newline at end of file diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 0bacf758..e23427b7 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -12,9 +12,10 @@ jobs: run-unit-tests: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] - surrealdb-version: ["v2.1.1", "v2.1.2"] + surrealdb-version: ["v2.0.0", "v2.1.0", "v2.1.1", "v2.1.2"] name: Run unit test SurrealDB ${{ matrix.surrealdb-version }} - Python Version ${{ matrix.python-version }} steps: - name: Checkout repository From 043177b856a2972e2ce3022917254387111ce85a Mon Sep 17 00:00:00 2001 From: Remade Date: Wed, 27 Nov 2024 14:22:45 +0100 Subject: [PATCH 11/15] Build WIP --- .github/workflows/cross_build.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cross_build.yml b/.github/workflows/cross_build.yml index 8ab34437..370d580d 100644 --- a/.github/workflows/cross_build.yml +++ b/.github/workflows/cross_build.yml @@ -1,10 +1,13 @@ name: cross-build on: - pull_request: - types: [closed] + push: branches: - - main + - improve-and-fix-workflow +# pull_request: +# types: [closed] +# branches: +# - main jobs: wait-for-other-workflow: From 684888f2c4497af8a7dcf68f9d69003ae619d58c Mon Sep 17 00:00:00 2001 From: Remade Date: Wed, 27 Nov 2024 14:23:47 +0100 Subject: [PATCH 12/15] Build WIP --- .github/workflows/cross_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cross_build.yml b/.github/workflows/cross_build.yml index 370d580d..33a360a0 100644 --- a/.github/workflows/cross_build.yml +++ b/.github/workflows/cross_build.yml @@ -34,7 +34,7 @@ jobs: - name: Checkout Surreal C lib uses: actions/checkout@v3 with: - repository: https://github.com/surrealdb/surrealdb.c + repository: surrealdb/surrealdb.c - name: Set up Rust uses: actions-rs/toolchain@v1 From c38e60a079372e3fd3acf2092246f55f75cddbcc Mon Sep 17 00:00:00 2001 From: Remade Date: Thu, 28 Nov 2024 11:03:27 +0100 Subject: [PATCH 13/15] WIP --- .github/workflows/cross_build.yml | 17 +++++++++++++++-- .github/workflows/unit_tests.yml | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cross_build.yml b/.github/workflows/cross_build.yml index 33a360a0..f4f14402 100644 --- a/.github/workflows/cross_build.yml +++ b/.github/workflows/cross_build.yml @@ -19,7 +19,7 @@ jobs: build: # if: github.event.pull_request.merged == true - name: build for ${{ matrix.os }} + name: Build C release for ${{ matrix.os.name }} strategy: matrix: os: @@ -54,4 +54,17 @@ jobs: uses: actions/upload-artifact@v3 with: name: ${{ matrix.os.name }}-build - path: dist/${{ matrix.os.name }} \ No newline at end of file + path: dist/${{ matrix.os.name }} + + release: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: ubuntu-latest-build + path: dist/linux \ No newline at end of file diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index e23427b7..e9adc971 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] - surrealdb-version: ["v2.0.0", "v2.1.0", "v2.1.1", "v2.1.2"] + surrealdb-version: ["v2.0.0", "v2.1.1", "v2.1.2"] # Issue with v2.1.0 name: Run unit test SurrealDB ${{ matrix.surrealdb-version }} - Python Version ${{ matrix.python-version }} steps: - name: Checkout repository From c09eba8ad4d6fa2bbce4961fce8837429fb2a322 Mon Sep 17 00:00:00 2001 From: Remade Date: Fri, 29 Nov 2024 09:01:30 +0100 Subject: [PATCH 14/15] redacted release --- .github/workflows/cross_build.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/cross_build.yml b/.github/workflows/cross_build.yml index f4f14402..7961fd44 100644 --- a/.github/workflows/cross_build.yml +++ b/.github/workflows/cross_build.yml @@ -55,16 +55,3 @@ jobs: with: name: ${{ matrix.os.name }}-build path: dist/${{ matrix.os.name }} - - release: - needs: build - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download build artifacts - uses: actions/download-artifact@v3 - with: - name: ubuntu-latest-build - path: dist/linux \ No newline at end of file From 403ed18d0e63e26a837f93147644b55a057e18b1 Mon Sep 17 00:00:00 2001 From: Remade Date: Fri, 29 Nov 2024 09:13:26 +0100 Subject: [PATCH 15/15] redacted release --- .github/workflows/cross_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cross_build.yml b/.github/workflows/cross_build.yml index 7961fd44..c2103a1e 100644 --- a/.github/workflows/cross_build.yml +++ b/.github/workflows/cross_build.yml @@ -18,7 +18,7 @@ jobs: run: "echo 'Waiting for other workflow to complete...'" build: -# if: github.event.pull_request.merged == true + if: github.event.pull_request.merged == true name: Build C release for ${{ matrix.os.name }} strategy: matrix: