Skip to content

Commit 52c7469

Browse files
apetencheaCryptoNinjaGeekaMahanna
authored
Circleci project setup (#291)
* Add .circleci/config.yml * adding circleci configuration * uploading test results * emitting warning instead of failing * disabling log * activate venv * running without venv * Update config.yml * Update build.yaml * Update starter.sh * remove `pytest -k` flag * include all arangodb variations * cleanup * update job names * Update build.yaml * Update config.yml * Update config.yml * Update config.yml * Update config.yml * Update config.yml * fix --port flag * fail test on purpose * remove test failure * Update config.yml * rename `build.yaml` to `docs.yaml` * use all python versions * Update config.yml * Update config.yml * Update config.yml * Update config.yml * Update config.yml * Update config.yml * Update config.yml * Update config.yml --------- Co-authored-by: CryptoNinjaGeek <[email protected]> Co-authored-by: Anthony Mahanna <[email protected]>
1 parent 8e35379 commit 52c7469

22 files changed

+465
-225
lines changed

.circleci/config.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
version: 2.1
2+
3+
# orbs:
4+
# coveralls: coveralls/[email protected]
5+
6+
workflows:
7+
ci:
8+
jobs:
9+
- lint
10+
- test:
11+
matrix:
12+
parameters:
13+
# TODO: Revisit why pyenv doesn't recognize 3.12
14+
python_version: ["3.8", "3.9", "3.10", "3.11"] # "3.12"
15+
arangodb_config: ["single", "cluster"]
16+
arangodb_license: ["community", "enterprise"]
17+
arangodb_version: ["3.10.10", "3.11.4", "latest"]
18+
19+
jobs:
20+
lint:
21+
docker:
22+
- image: python:latest
23+
steps:
24+
- checkout
25+
- run:
26+
name: Install Dependencies
27+
command: pip install .[dev]
28+
29+
- run:
30+
name: Run black
31+
command: black --check --verbose --diff --color --config=pyproject.toml ./arango ./tests/
32+
33+
- run:
34+
name: Run flake8
35+
command: flake8 ./arango ./tests
36+
37+
- run:
38+
name: Run isort
39+
command: isort --check ./arango ./tests
40+
41+
- run:
42+
name: Run mypy
43+
command: mypy ./arango
44+
45+
test:
46+
parameters:
47+
python_version:
48+
type: string
49+
arangodb_config:
50+
type: string
51+
arangodb_license:
52+
type: string
53+
arangodb_version:
54+
type: string
55+
# TODO: Reconsider using a docker image instead of a machine
56+
# i.e cimg/python:<< parameters.python_version >>
57+
machine:
58+
image: ubuntu-2204:current
59+
steps:
60+
- checkout
61+
62+
- run:
63+
name: Set Up ArangoDB
64+
command: |
65+
chmod +x starter.sh
66+
./starter.sh << parameters.arangodb_config >> << parameters.arangodb_license >> << parameters.arangodb_version >>
67+
68+
- restore_cache:
69+
key: pip-and-local-cache
70+
71+
# TODO: Revisit this bottleneck
72+
- run:
73+
name: Setup Python
74+
command: |
75+
pyenv --version
76+
pyenv install -f << parameters.python_version >>
77+
pyenv global << parameters.python_version >>
78+
79+
- run:
80+
name: "Install Dependencies"
81+
command: pip install -e .[dev]
82+
83+
- run: docker ps -a
84+
85+
- run:
86+
name: "Run pytest"
87+
command: |
88+
mkdir test-results
89+
90+
args=("--junitxml=test-results/junit.xml" "--log-cli-level=DEBUG" "--host" "localhost" "--port=8529")
91+
if [ << parameters.arangodb_config >> = "cluster" ]; then
92+
args+=("--cluster" "--port=8539" "--port=8549")
93+
fi
94+
95+
if [ << parameters.arangodb_license >> = "enterprise" ]; then
96+
args+=("--enterprise")
97+
fi
98+
99+
echo "Running pytest with args: ${args[@]}"
100+
pytest --cov=arango --cov-report=xml "${args[@]}"
101+
102+
- store_artifacts:
103+
path: test-results
104+
105+
- store_test_results:
106+
path: test-results
107+
108+
# - run:
109+
# name: Upload to Coveralls
110+
# command: |
111+
# if [ "<< parameters.python_version >>" = "3.11" && "<< parameters.arangodb_config >>" = "single" && "<< parameters.arangodb_license >>" = "community" && "<< parameters.arangodb_version >>" = "latest" ]; then
112+
# coveralls/upload
113+
# fi

.github/workflows/build.yaml

Lines changed: 0 additions & 66 deletions
This file was deleted.

.github/workflows/codeql.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CodeQL
22

33
on:
44
pull_request:
5-
branches: [main, dev]
5+
branches: [main]
66
schedule:
77
- cron: '21 2 * * 3'
88

.github/workflows/docs.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Docs
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
debug_enabled:
8+
type: boolean
9+
description: Debug with tmate
10+
required: false
11+
default: false
12+
13+
jobs:
14+
# This has been migrated to CircleCI
15+
# test:
16+
# runs-on: ubuntu-latest
17+
18+
# strategy:
19+
# fail-fast: false
20+
# matrix:
21+
# python_version: ["3.10"] #["3.8", "3.9", "3.10", "3.11", "3.12"]
22+
# arangodb_config: ["single", "cluster"]
23+
# arangodb_license: ["community", "enterprise"]
24+
# arangodb_version: ["3.10.10", "3.11.4", "latest"]
25+
26+
# name: Test (${{ matrix.python_version }}:${{ matrix.arangodb_config }}:${{ matrix.arangodb_license }}:${{ matrix.arangodb_version }})
27+
28+
# steps:
29+
# - name: Checkout code
30+
# uses: actions/checkout@v4
31+
32+
# - name: Set up Python
33+
# uses: actions/setup-python@v4
34+
# with:
35+
# python-version: ${{ matrix.python_version }}
36+
37+
# - name: Setup ArangoDB
38+
# run: |
39+
# chmod +x starter.sh
40+
# ./starter.sh ${{ matrix.arangodb_config }} ${{ matrix.arangodb_license }} ${{ matrix.arangodb_version }}
41+
42+
# - name: Install Dependencies
43+
# run: pip install -e .[dev]
44+
45+
# - name: List Docker Containers
46+
# run: docker ps -a
47+
48+
# - name: Pytest
49+
# run: |
50+
# args=("--host" "localhost" "--port=8529")
51+
52+
# if [ ${{ matrix.arangodb_config }} = "cluster" ]; then
53+
# args+=("--cluster" "--port=8539" "--port=8549")
54+
# fi
55+
56+
# if [ ${{ matrix.arangodb_license }} = "enterprise" ]; then
57+
# args+=("--enterprise")
58+
# fi
59+
60+
# echo "Running pytest with args: ${args[@]}"
61+
# pytest --cov=arango --cov-report=xml "${args[@]}"
62+
63+
docs:
64+
runs-on: ubuntu-latest
65+
66+
name: Docs
67+
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@v4
71+
72+
- name: Fetch all tags and branches
73+
run: git fetch --prune --unshallow
74+
75+
- name: Create ArangoDB Docker container
76+
run: >
77+
docker create --name arango -p 8529:8529 -e ARANGO_ROOT_PASSWORD=passwd -v "$(pwd)/tests/static/":/tests/static
78+
arangodb/arangodb:latest --server.jwt-secret-keyfile=/tests/static/keyfile
79+
80+
- name: Start ArangoDB Docker container
81+
run: docker start arango
82+
83+
- name: Set up Python
84+
uses: actions/setup-python@v4
85+
with:
86+
python-version: '3.10'
87+
88+
- name: Debug with tmate
89+
uses: mxschmitt/action-tmate@v3
90+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
91+
92+
- name: Run pre-commit checks
93+
uses: pre-commit/[email protected]
94+
95+
- name: Install dependencies
96+
run: pip install .[dev]
97+
98+
- name: Run Sphinx doctest
99+
run: python -m sphinx -b doctest docs docs/_build
100+
101+
- name: Generate Sphinx HTML
102+
run: python -m sphinx -b html -W docs docs/_build

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Run unit tests with coverage:
1313
py.test --cov=arango --cov-report=html # Open htmlcov/index.html in your browser
1414
```
1515

16-
For a more comprehensive test suite, run:
16+
To start and ArangoDB instance locally, run:
1717

1818
```shell
19-
./tester.sh # Requires docker
19+
./starter.sh # Requires docker
2020
```
2121

2222
Build and test documentation:

arango/client.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
from arango.exceptions import ServerConnectionError
1616
from arango.http import DEFAULT_REQUEST_TIMEOUT, DefaultHTTPClient, HTTPClient
1717
from arango.resolver import (
18+
FallbackHostResolver,
1819
HostResolver,
20+
PeriodicHostResolver,
1921
RandomHostResolver,
2022
RoundRobinHostResolver,
2123
SingleHostResolver,
@@ -52,9 +54,9 @@ class ArangoClient:
5254
:param hosts: Host URL or list of URLs (coordinators in a cluster).
5355
:type hosts: str | [str]
5456
:param host_resolver: Host resolver. This parameter used for clusters (when
55-
multiple host URLs are provided). Accepted values are "roundrobin" and
56-
"random". Any other value defaults to round robin.
57-
:type host_resolver: str
57+
multiple host URLs are provided). Accepted values are "fallback",
58+
"roundrobin", "random" and "periodic". The default value is "fallback".
59+
:type host_resolver: str | arango.resolver.HostResolver
5860
:param resolver_max_tries: Number of attempts to process an HTTP request
5961
before throwing a ConnectionAbortedError. Must not be lower than the
6062
number of hosts.
@@ -88,7 +90,7 @@ class ArangoClient:
8890
def __init__(
8991
self,
9092
hosts: Union[str, Sequence[str]] = "http://127.0.0.1:8529",
91-
host_resolver: str = "roundrobin",
93+
host_resolver: Union[str, HostResolver] = "fallback",
9294
resolver_max_tries: Optional[int] = None,
9395
http_client: Optional[HTTPClient] = None,
9496
serializer: Callable[..., str] = default_serializer,
@@ -106,10 +108,18 @@ def __init__(
106108

107109
if host_count == 1:
108110
self._host_resolver = SingleHostResolver(1, resolver_max_tries)
111+
elif host_resolver == "fallback":
112+
self._host_resolver = FallbackHostResolver(host_count, resolver_max_tries)
109113
elif host_resolver == "random":
110114
self._host_resolver = RandomHostResolver(host_count, resolver_max_tries)
111-
else:
115+
elif host_resolver == "roundrobin":
112116
self._host_resolver = RoundRobinHostResolver(host_count, resolver_max_tries)
117+
elif host_resolver == "periodic":
118+
self._host_resolver = PeriodicHostResolver(host_count, resolver_max_tries)
119+
else:
120+
if not isinstance(host_resolver, HostResolver):
121+
raise ValueError("Invalid host resolver")
122+
self._host_resolver = host_resolver
113123

114124
# Initializes the http client
115125
self._http = http_client or DefaultHTTPClient(request_timeout=request_timeout)

arango/formatter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,12 @@ def format_pregel_job_data(body: Json) -> Json:
11941194
if "useMemoryMaps" in body:
11951195
result["use_memory_maps"] = body["useMemoryMaps"]
11961196

1197+
# Introduced in 3.11
1198+
if "user" in body:
1199+
result["user"] = body["user"]
1200+
if "graphLoaded" in body:
1201+
result["graph_loaded"] = body["graphLoaded"]
1202+
11971203
return verify_format(body, result)
11981204

11991205

0 commit comments

Comments
 (0)