Skip to content

Commit

Permalink
adding circleci configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
apetenchea committed Oct 17, 2023
1 parent 23b96bb commit 505e085
Show file tree
Hide file tree
Showing 21 changed files with 435 additions and 193 deletions.
170 changes: 154 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,164 @@
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/configuration-reference
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/configuration-reference/#jobs
parameters:
preview:
type: boolean
default: true
3-10:
type: boolean
default: true
3-11:
type: boolean
default: true

jobs:
say-hello:
# Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/configuration-reference/#executor-job
run-tests:
resource_class: small
parameters:
python-version:
type: string
default: "latest"
arangodb-version:
type: string
default: "arangodb:latest"
arangodb-config:
type: string
default: "single.conf"
cluster:
type: boolean
default: false
enterprise:
type: boolean
default: false
docker:
- image: cimg/base:stable
# Add steps to the job
# See: https://circleci.com/docs/configuration-reference/#steps
- image: python:<< parameters.python-version >>
command: ["/bin/sh", "-c", "python -m http.server"]
- image: arangodb/<< parameters.arangodb-version >>
environment:
ARANGODB_CONF: << parameters.arangodb-config >>
PROJECT: /root/project
command:
- "/bin/sh"
- "-c"
- >
while ! wget -q -O /dev/null http://localhost:8000/$PROJECT/tests/static/setup.sh; do sleep 1; done &&
wget -O - http://localhost:8000/$PROJECT/tests/static/setup.sh |
/bin/sh
steps:
- checkout
- run:
name: "Say hello"
command: "echo Hello, World!"
name: "Install Dependencies"
command: |
pip install -e .[dev]
- run:
name: "Wait for ArangoDB starter"
command: |
wget --quiet --waitretry=1 --tries=120 -O - http://localhost:8528/version
if [ $? -eq 0 ]; then
echo "starter ready"
exit 0
else
echo "starter not ready, giving up"
exit 1
fi
- run:
name: "Run pytest"
command: |
mkdir test-results
args=("--log-cli-level=DEBUG" "--host" "localhost" "--junitxml=./test-results/junit.xml")
if [ << parameters.cluster >> = true ]; then
args+=("--cluster" "--port=8529" "--port=8539" "--port=8549")
else
args+=("--port=8529")
fi
if [ << parameters.enterprise >> = true ]; then
args+=("--enterprise")
fi
echo "Running py.test with args: ${args[@]}"
py.test "${args[@]}"
- store_test_results:
path: ./test-results/junit.xml
- store_artifacts:
path: ./test-results

# Orchestrate jobs using workflows
# See: https://circleci.com/docs/configuration-reference/#workflows
workflows:
say-hello-workflow:
python-3.8-community-single-3.10:
when: << pipeline.parameters.3-10 >>
jobs:
- run-tests:
name: python-3.8-community-single-3.10
python-version: "3.8.2"
arangodb-version: "arangodb:3.10.10"
arangodb-config: "single-3.10.conf"
cluster: false
enterprise: false
python-3.8-enterprise-cluster-3.10:
when: << pipeline.parameters.3-10 >>
jobs:
- run-tests:
name: python-3.8-enterprise-cluster-3.10
python-version: "3.8.2"
arangodb-version: "enterprise:3.10.10"
arangodb-config: "cluster-3.10.conf"
cluster: true
enterprise: true
python-3.10-community-single-3.11:
when: << pipeline.parameters.3-11 >>
jobs:
- run-tests:
name: python-3.10-community-single-3.11
python-version: "3.10.6"
arangodb-version: "arangodb:3.11.4"
arangodb-config: "single.conf"
cluster: false
enterprise: false
python-3.10-community-cluster-3.11:
when: << pipeline.parameters.3-11 >>
jobs:
- run-tests:
name: python-3.10-community-cluster-3.11
python-version: "3.10.6"
arangodb-version: "arangodb:3.11.4"
arangodb-config: "cluster.conf"
cluster: true
enterprise: false
python-3.10-enterprise-single-3.11:
when: << pipeline.parameters.3-11 >>
jobs:
- run-tests:
name: python-3.10-enterprise-single-3.11
python-version: "3.10.6"
arangodb-version: "enterprise:3.11.4"
arangodb-config: "single.conf"
cluster: false
enterprise: true
python-3.10-enterprise-cluster-3.11:
when: << pipeline.parameters.3-11 >>
jobs:
- run-tests:
name: python-3.10-enterprise-cluster-3.11
python-version: "3.10.6"
arangodb-version: "enterprise:3.11.4"
arangodb-config: "cluster.conf"
cluster: true
enterprise: true
python-latest-enterprise-single-preview:
when: << pipeline.parameters.preview >>
jobs:
- run-tests:
name: python-latest-enterprise-single-preview
python-version: "latest"
arangodb-version: "enterprise-preview:latest"
arangodb-config: "single.conf"
cluster: false
enterprise: true
python-latest-enterprise-cluster-preview:
when: << pipeline.parameters.preview >>
jobs:
- say-hello
- run-tests:
name: python-latest-enterprise-cluster-preview
python-version: "latest"
arangodb-version: "enterprise-preview:latest"
arangodb-config: "cluster.conf"
cluster: true
enterprise: true
22 changes: 4 additions & 18 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build

on:
pull_request:
branches: [main, dev]
branches: [main]
workflow_dispatch:
inputs:
debug_enabled:
Expand All @@ -12,13 +12,9 @@ on:
default: false

jobs:
build:
docs:
runs-on: ubuntu-22.04

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -29,15 +25,15 @@ jobs:
- name: Create ArangoDB Docker container
run: >
docker create --name arango -p 8529:8529 -e ARANGO_ROOT_PASSWORD=passwd -v "$(pwd)/tests/static/":/tests/static
arangodb/arangodb:3.10.9 --server.jwt-secret-keyfile=/tests/static/keyfile
arangodb/arangodb:3.11.4 --server.jwt-secret-keyfile=/tests/static/keyfile
- name: Start ArangoDB Docker container
run: docker start arango

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: '3.10'

- name: Debug with tmate
uses: mxschmitt/action-tmate@v3
Expand All @@ -49,18 +45,8 @@ jobs:
- name: Install dependencies
run: pip install .[dev]

- name: Run unit tests
run: py.test --complete --cov=arango --cov-report=xml

- name: Run Sphinx doctest
run: python -m sphinx -b doctest docs docs/_build

- name: Generate Sphinx HTML
run: python -m sphinx -b html -W docs docs/_build

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.python-version == '3.10'
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CodeQL

on:
pull_request:
branches: [main, dev]
branches: [main]
schedule:
- cron: '21 2 * * 3'

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Run unit tests with coverage:
py.test --cov=arango --cov-report=html # Open htmlcov/index.html in your browser
```

For a more comprehensive test suite, run:
To start and ArangoDB instance locally, run:

```shell
./tester.sh # Requires docker
./starter.sh # Requires docker
```

Build and test documentation:
Expand Down
20 changes: 15 additions & 5 deletions arango/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
from arango.exceptions import ServerConnectionError
from arango.http import DEFAULT_REQUEST_TIMEOUT, DefaultHTTPClient, HTTPClient
from arango.resolver import (
FallbackHostResolver,
HostResolver,
PeriodicHostResolver,
RandomHostResolver,
RoundRobinHostResolver,
SingleHostResolver,
Expand Down Expand Up @@ -52,9 +54,9 @@ class ArangoClient:
:param hosts: Host URL or list of URLs (coordinators in a cluster).
:type hosts: str | [str]
:param host_resolver: Host resolver. This parameter used for clusters (when
multiple host URLs are provided). Accepted values are "roundrobin" and
"random". Any other value defaults to round robin.
:type host_resolver: str
multiple host URLs are provided). Accepted values are "fallback",
"roundrobin", "random" and "periodic". The default value is "fallback".
:type host_resolver: str | arango.resolver.HostResolver
:param resolver_max_tries: Number of attempts to process an HTTP request
before throwing a ConnectionAbortedError. Must not be lower than the
number of hosts.
Expand Down Expand Up @@ -88,7 +90,7 @@ class ArangoClient:
def __init__(
self,
hosts: Union[str, Sequence[str]] = "http://127.0.0.1:8529",
host_resolver: str = "roundrobin",
host_resolver: Union[str, HostResolver] = "fallback",
resolver_max_tries: Optional[int] = None,
http_client: Optional[HTTPClient] = None,
serializer: Callable[..., str] = default_serializer,
Expand All @@ -106,10 +108,18 @@ def __init__(

if host_count == 1:
self._host_resolver = SingleHostResolver(1, resolver_max_tries)
elif host_resolver == "fallback":
self._host_resolver = FallbackHostResolver(host_count, resolver_max_tries)
elif host_resolver == "random":
self._host_resolver = RandomHostResolver(host_count, resolver_max_tries)
else:
elif host_resolver == "roundrobin":
self._host_resolver = RoundRobinHostResolver(host_count, resolver_max_tries)
elif host_resolver == "periodic":
self._host_resolver = PeriodicHostResolver(host_count, resolver_max_tries)
else:
if not isinstance(host_resolver, HostResolver):
raise ValueError("Invalid host resolver")
self._host_resolver = host_resolver

# Initializes the http client
self._http = http_client or DefaultHTTPClient(request_timeout=request_timeout)
Expand Down
6 changes: 6 additions & 0 deletions arango/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,12 @@ def format_pregel_job_data(body: Json) -> Json:
if "useMemoryMaps" in body:
result["use_memory_maps"] = body["useMemoryMaps"]

# Introduced in 3.11
if "user" in body:
result["user"] = body["user"]
if "graphLoaded" in body:
result["graph_loaded"] = body["graphLoaded"]

return verify_format(body, result)


Expand Down
Loading

0 comments on commit 505e085

Please sign in to comment.