Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing and updates #106

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
997e76e
Create base client using HTTP API (#5)
tsunyoku Sep 18, 2022
fbf9691
Ensure response error checking is done at correct time (#7)
tsunyoku Sep 18, 2022
a15662c
Add websocket implementation (#6)
tsunyoku Sep 18, 2022
c2e4ada
Implement full compatibility for Python 3.7 (#9)
tsunyoku Sep 18, 2022
422a5e5
Replace request-waiting logic to use asyncio.Future (#10)
tsunyoku Sep 18, 2022
562b7dc
Improve typing in some areas of the code (#11)
tsunyoku Sep 18, 2022
9e183e3
Refactor argument logic (#13)
tsunyoku Sep 18, 2022
aa94e2f
Add documentation to methods (#14)
CaedenPH Sep 18, 2022
f0f0324
Improve code quality & documentation (#15)
tsunyoku Sep 18, 2022
7a3ecf4
Add extra functions & small refactors (#16)
tsunyoku Sep 19, 2022
23b137e
Examples for using the HTTPClient (#8)
MaoMaoCake Sep 19, 2022
cd7cfb7
Set base version
tobiemh Sep 20, 2022
87284e4
Ignore project build dist folder
tobiemh Sep 20, 2022
0bd1f94
0.1.0
tobiemh Sep 20, 2022
393be12
Add readme to pyproject.toml (#18)
tsunyoku Sep 20, 2022
f1cec5e
Fix typo in query example (#19)
ilosamart Sep 24, 2022
226fb2e
Fix unsolvable pyproject.toml, drop support for EOL python versions (…
jyooru Sep 24, 2022
7d2e1ca
Fix authentication in HTTP connection (#26)
TudorAndrei Sep 27, 2022
fed3ba7
Improve formatting and linting (#20)
sam-kenney Sep 27, 2022
3c50fbd
Fix unhandled `KeyError` (#30)
TudorAndrei Oct 18, 2022
48c0611
Add image and some new badges to README (#28)
FrostyTheSouthernSnowman Oct 18, 2022
db93e25
Fix websocket exception handling (#33)
HakierGrzonzo Oct 25, 2022
3b123e7
0.2.0
tobiemh Oct 25, 2022
761d488
Using `ruff` for code formatting (#43)
Ce11an Mar 6, 2023
2f9042e
Make the python library ready for wide use along with documentation a…
AlexFrid Mar 27, 2023
6e582bb
0.3.0
tobiemh Mar 27, 2023
4d281c4
Adding templates (#42)
Ce11an Mar 31, 2023
22a7757
Updating dependencies to resolve a moderate severity Dependabot alert…
AlexFrid Mar 31, 2023
519ff0a
Refactor : API calling methods (#49)
HiteshGorana Apr 3, 2023
93c67f5
ci: Create a workflow that runs ruff (#52)
CaedenPH Apr 3, 2023
a67c797
Fix unicode error (#57)
AlexFrid Apr 20, 2023
37c6405
Bump to 0.3.1 (#58)
AlexFrid Apr 20, 2023
f0293e6
Implement `mypy` (#60)
Ce11an May 16, 2023
fe13477
docs: fix typo in ws.py (#62)
TudorAndrei-Pythia Jun 8, 2023
a2b7b56
sorting out conflicts
maxwellflitton Jan 27, 2024
027d11b
updating gitignore
maxwellflitton Feb 13, 2024
30d1c70
adding more tests and making the client more consistent with other SDKs
maxwellflitton Aug 1, 2024
6184887
adding delete
maxwellflitton Sep 9, 2024
af53592
signup is now working
maxwellflitton Sep 9, 2024
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
11 changes: 11 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]

[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
20 changes: 0 additions & 20 deletions .editorconfig

This file was deleted.

187 changes: 187 additions & 0 deletions .github/workflows/cross_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
name: cross-build

on:
pull_request:
types: [closed]
branches:
- main

env:
CARGO_TERM_COLOR: always

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: # Workflow credit to https://github.com/samuelcolvin/rtoml/blob/main/.github/workflows/ci.yml
if: github.event.pull_request.merged == true
name: >
build ${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
(${{ matrix.alt_arch_name || matrix.arch }})
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: ["cp310", "pp37", "pp38", "pp39"]
arch: [main, alt]
include:
- os: ubuntu
platform: linux
- os: windows
ls: dir
- os: macos
arch: alt
alt_arch_name: "arm64 universal2"
exclude:
- os: macos
python-version: "pp37"
arch: alt
- os: macos
python-version: "pp38"
arch: alt
- os: macos
python-version: "pp39"
arch: alt
runs-on: ${{ format('{0}-latest', matrix.os) }}
steps:
- uses: actions/checkout@v3

- name: set up python
uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: set up rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: update pip version
run: |
pip install requests
python get_latest_version.py

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.alt_arch_name }}

- run: rustup target add aarch64-apple-darwin
if: matrix.os == 'macos'

- run: rustup toolchain install stable-i686-pc-windows-msvc
if: matrix.os == 'windows'

- run: rustup target add i686-pc-windows-msvc
if: matrix.os == 'windows'

- name: Get pip cache dir
id: pip-cache
if: matrix.os != 'windows'
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

- name: Get pip cache dir
id: pip-cache-win
if: matrix.os == 'windows'
run: |
"dir=$(pip cache dir)" >> $env:GITHUB_OUTPUT

- name: Cache python dependencies
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir || steps.pip-cache-win.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}

- name: install python dependencies
run: pip install -U setuptools wheel twine cibuildwheel platformdirs

- name: Display cibuildwheel cache dir
id: cibuildwheel-cache
run: |
from platformdirs import user_cache_path
import os
with open(os.getenv('GITHUB_OUTPUT'), 'w') as f:
f.write(f"dir={str(user_cache_path(appname='cibuildwheel', appauthor='pypa'))}")
shell: python

- name: Cache cibuildwheel tools
uses: actions/cache@v3
with:
path: ${{ steps.cibuildwheel-cache.outputs.dir }}
key: ${{ runner.os }}-cibuildwheel-${{ matrix.python-version }}

- name: Install LLVM and Clang # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797
uses: KyleMayes/install-llvm-action@v1
if: runner.os == 'Windows'
with:
version: "11.0"
directory: ${{ runner.temp }}/llvm

- name: Set LIBCLANG_PATH
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
if: runner.os == 'Windows'

- name: build_sdist
if: matrix.os == 'ubuntu' && matrix.python-version == 'cp310'
run: |
pip install maturin build
python -m build --sdist -o wheelhouse
- name: build ${{ matrix.platform || matrix.os }} binaries
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "${{ matrix.python-version }}-*"
# rust doesn't seem to be available for musl linux on i686
CIBW_SKIP: "*-musllinux_i686"
# we build for "alt_arch_name" if it exists, else 'auto'
CIBW_ARCHS: ${{ matrix.alt_arch_name || 'auto' }}
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH" CARGO_TERM_COLOR="always"'
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
CIBW_BEFORE_BUILD: rustup show
CIBW_BEFORE_BUILD_LINUX: >
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y &&
rustup show
CIBW_BUILD_VERBOSITY: 1

- run: ${{ matrix.ls || 'ls -lh' }} wheelhouse/

- uses: actions/upload-artifact@v3
with:
name: wheels
path: wheelhouse

release:
if: github.event.pull_request.merged == true
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse

- name: Install twine
run: python -m pip install --upgrade twine

- name: Create pypirc file
run: |
echo "[distutils]" > ~/.pypirc
echo "index-servers =" >> ~/.pypirc
echo " pypi" >> ~/.pypirc
echo "" >> ~/.pypirc
echo "[pypi]" >> ~/.pypirc
echo "username: __token__" >> ~/.pypirc
echo "password: \${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

- name: Publish to PyPI
run: twine upload wheelhouse/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
22 changes: 21 additions & 1 deletion .github/workflows/stability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,32 @@ jobs:

- id: ruff
if: always()
<<<<<<< HEAD
run: poetry run ruff --format=github python_package/surrealdb/
=======
<<<<<<< HEAD
run: poetry run ruff --format=github python_package/surrealdb/

- id: Black
if: always()
run: poetry run black python_package/surrealdb/ --check --verbose --diff --color

- id: mypy
if: always()
run: poetry run mypy python_package/surrealdb/
=======
run: poetry run ruff check surrealdb/
>>>>>>> ffefd8a2354ff597f6f18115d18fa4eab45d6540

- id: Black
if: always()
run: poetry run black surrealdb/ --check --verbose --diff --color
run: poetry run black python_package/surrealdb/ --check --verbose --diff --color

- id: mypy
if: always()
<<<<<<< HEAD
run: poetry run mypy python_package/surrealdb/
=======
run: poetry run mypy surrealdb/
>>>>>>> 89bdd361d0a92f69deff137958279ab21161f00c
>>>>>>> ffefd8a2354ff597f6f18115d18fa4eab45d6540
47 changes: 47 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: unit-tests

on:
pull_request:
# push:
branches:
- "*"

jobs:
run-unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10" ]

steps:
- 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
# docker-compose build
# docker-compose up -d
# sleep 2

- name: Run Tests
run: sh scripts/run_tests.sh

run-rust-unit-tests:
needs: run-unit-tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Build and Run Unit Tests
run: cargo test
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,33 @@ cover/
.vscode/
__pycache__/
dist/
build/

# -----------------------------------
# IDE
# -----------------------------------
.idea/
<<<<<<< HEAD
Cargo.lock

=======
# -----------------------------------
# Rust
# -----------------------------------
/target/
Cargo.lock
# -----------------------------------
# Packaging
# -----------------------------------
*.egg-info/
*.egg
.eggs/
*.so
/build/
# -----------------------------------
# server tests
# -----------------------------------
integration_tests/flask/app/surreal.py/
integration_tests/package-lock.json
integration_tests/node_modules/
>>>>>>> ffefd8a2354ff597f6f18115d18fa4eab45d6540
9 changes: 3 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ repos:
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.245'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
- id: ruff-format
40 changes: 40 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
name = "surrealdb"
version = "0.1.0"
authors = ["Maxwell Flitton <[email protected]>"]
edition = "2018"

[dependencies]
surrealdb = { version = "1.5.4", features = ["protocol-ws", "protocol-http", "kv-mem"] }
serde = "1.0.210"
futures = { version = "0.3.30", features = ["executor"] }
once_cell = "1.19.0"
serde_json = "1.0.128"
crossbeam-channel = "0.5.13"
thiserror = "1.0.63"

[dev-dependencies]
tokio = { version = "1.40.0", features = ["full"] }
bollard = "*"
futures-util-preview = "0.2.2"
lazy_static = "1.5.0"

[lib]
name = "rust_surrealdb"
crate-type=["cdylib"]

[dependencies.pyo3]
version = "0.20.0"
features = ["extension-module"]

[dependencies.pyo3-asyncio]
version = "0.20"
features = ["unstable-streams", "attributes", "tokio-runtime"]

[dependencies.uuid]
version = "1.10.0"
features = [
"v4", # Lets you generate random UUIDs
"fast-rng", # Use a faster (but still sufficiently random) RNG
"macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
]
Loading