diff --git a/.circleci/config.yml b/.circleci/config.yml index 4175da6c..e918028d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,26 +1,64 @@ -# 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 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: + parameters: + python-version: + type: string + default: "latest" + arangodb-version: + type: string + default: "arangodb:latest" + arangodb-config: + type: string + default: "single.conf" docker: - - image: cimg/base:stable - # Add steps to the job - # See: https://circleci.com/docs/configuration-reference/#steps + - image: python:<< parameters.python-version >> + name: driver + - image: arangodb/<< parameters.arangodb-version >> + name: db steps: - checkout + - remote_setup_docker - run: - name: "Say hello" - command: "echo Hello, World!" + name: "Copy data to DB container" + command: | + docker cp tests/static db:/tests/static + - run: + name: "Run ArangoDB with custom configuration" + command: | + docker exec db arangodb --configuration=/tests/static/<< parameters.arangodb-config >> + - run: + name: "Wait for DB" + environment: + ARANGO_HOST: "http://db:8529" + command: | + for i in {1..30} + do + python tests/utils/ping.py + if [[ $? -eq 0 ]]; then + echo "DB is up and running" + exit 0 + else + echo "Attempt $i failed, retrying..." + sleep 1 + fi + done + echo "Failed to connect to DB after 30 seconds" + exit 1 + - run: + name: "Install Dependencies" + command: | + pip install -e .[dev] + - run: + name: "Run Tests" + command: | + py.test --host db --complete --cov=arango --cov-report=html -# Orchestrate jobs using workflows -# See: https://circleci.com/docs/configuration-reference/#workflows workflows: - say-hello-workflow: + test-single-python-3.10-community-3.10: jobs: - - say-hello + - run-tests: + python-version: "3.10.6" + arangodb-version: "arangodb:3.10.10" + arangodb-config: "single.conf" diff --git a/tests/utils/ping.py b/tests/utils/ping.py new file mode 100644 index 00000000..5cfed82a --- /dev/null +++ b/tests/utils/ping.py @@ -0,0 +1,16 @@ +import os + +from arango import ArangoClient + + +def main(): + host = os.environ.get("ARANGO_HOST", "http://127.0.0.1:8529") + username = os.environ.get("ARANGO_USERNAME", "root") + password = os.environ.get("ARANGO_PASSWORD", "passwd") + + client = ArangoClient(hosts=host) + client.db("_system", username=username, password=password, verify=True) + + +if __name__ == "__main__": + main()