diff --git a/.circleci/config.yml b/.circleci/config.yml index 921a3bf7..a75aba3e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,164 +1,113 @@ version: 2.1 -parameters: - preview: - type: boolean - default: true - 3-10: - type: boolean - default: true - 3-11: - type: boolean - default: true +# orbs: +# coveralls: coveralls/coveralls@2.2.1 + +workflows: + ci: + jobs: + - lint + - test: + matrix: + parameters: + # TODO: Revisit why pyenv doesn't recognize 3.12 + python_version: ["3.8", "3.9", "3.10", "3.11"] # "3.12" + arangodb_config: ["single", "cluster"] + arangodb_license: ["community", "enterprise"] + arangodb_version: ["3.10.10", "3.11.4", "latest"] jobs: - run-tests: - resource_class: small + lint: + docker: + - image: python:latest + steps: + - checkout + - run: + name: Install Dependencies + command: pip install .[dev] + + - run: + name: Run black + command: black --check --verbose --diff --color --config=pyproject.toml ./arango ./tests/ + + - run: + name: Run flake8 + command: flake8 ./arango ./tests + + - run: + name: Run isort + command: isort --check ./arango ./tests + + - run: + name: Run mypy + command: mypy ./arango + + test: parameters: - python-version: + python_version: type: string - default: "latest" - arangodb-version: + arangodb_config: type: string - default: "arangodb:latest" - arangodb-config: + arangodb_license: type: string - default: "single.conf" - cluster: - type: boolean - default: false - enterprise: - type: boolean - default: false - docker: - - 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 + arangodb_version: + type: string + # TODO: Reconsider using a docker image instead of a machine + # i.e cimg/python:<< parameters.python_version >> + machine: + image: ubuntu-2204:current steps: - checkout + - run: - name: "Install Dependencies" + name: Set Up ArangoDB command: | - pip install -e .[dev] + chmod +x starter.sh + ./starter.sh << parameters.arangodb_config >> << parameters.arangodb_license >> << parameters.arangodb_version >> + + - restore_cache: + key: pip-and-local-cache + + # TODO: Revisit this bottleneck - run: - name: "Wait for ArangoDB starter" + name: Setup Python 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 + pyenv --version + pyenv install -f << parameters.python_version >> + pyenv global << parameters.python_version >> + + - run: + name: "Install Dependencies" + command: pip install -e .[dev] + + - run: docker ps -a + - run: name: "Run pytest" command: | mkdir test-results - args=("--junitxml=test-results/junit.xml" "--log-cli-level=DEBUG" "--host" "localhost") - if [ << parameters.cluster >> = true ]; then - args+=("--cluster" "--port=8529" "--port=8539" "--port=8549") - else - args+=("--port=8529") + + args=("--junitxml=test-results/junit.xml" "--log-cli-level=DEBUG" "--host" "localhost" "--port=8529") + if [ << parameters.arangodb_config >> = "cluster" ]; then + args+=("--cluster" "--port=8539" "--port=8549") fi - if [ << parameters.enterprise >> = true ]; then + + if [ << parameters.arangodb_license >> = "enterprise" ]; then args+=("--enterprise") fi - echo "Running py.test with args: ${args[@]}" - py.test "${args[@]}" + + echo "Running pytest with args: ${args[@]}" + pytest --cov=arango --cov-report=xml "${args[@]}" + - store_artifacts: path: test-results + - store_test_results: path: test-results -workflows: - 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: - - run-tests: - name: python-latest-enterprise-cluster-preview - python-version: "latest" - arangodb-version: "enterprise-preview:latest" - arangodb-config: "cluster.conf" - cluster: true - enterprise: true + # - run: + # name: Upload to Coveralls + # command: | + # if [ "<< parameters.python_version >>" = "3.11" && "<< parameters.arangodb_config >>" = "single" && "<< parameters.arangodb_license >>" = "community" && "<< parameters.arangodb_version >>" = "latest" ]; then + # coveralls/upload + # fi diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index a542f28b..00000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,52 +0,0 @@ -name: Build - -on: - pull_request: - branches: [main] - workflow_dispatch: - inputs: - debug_enabled: - type: boolean - description: Debug with tmate - required: false - default: false - -jobs: - docs: - runs-on: ubuntu-22.04 - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Fetch all tags and branches - run: git fetch --prune --unshallow - - - 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.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: '3.10' - - - name: Debug with tmate - uses: mxschmitt/action-tmate@v3 - if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} - - - name: Run pre-commit checks - uses: pre-commit/action@v3.0.0 - - - name: Install dependencies - run: pip install .[dev] - - - 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 diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 00000000..bc06e12e --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,102 @@ +name: Docs + +on: + pull_request: + workflow_dispatch: + inputs: + debug_enabled: + type: boolean + description: Debug with tmate + required: false + default: false + +jobs: + # This has been migrated to CircleCI + # test: + # runs-on: ubuntu-latest + + # strategy: + # fail-fast: false + # matrix: + # python_version: ["3.10"] #["3.8", "3.9", "3.10", "3.11", "3.12"] + # arangodb_config: ["single", "cluster"] + # arangodb_license: ["community", "enterprise"] + # arangodb_version: ["3.10.10", "3.11.4", "latest"] + + # name: Test (${{ matrix.python_version }}:${{ matrix.arangodb_config }}:${{ matrix.arangodb_license }}:${{ matrix.arangodb_version }}) + + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + + # - name: Set up Python + # uses: actions/setup-python@v4 + # with: + # python-version: ${{ matrix.python_version }} + + # - name: Setup ArangoDB + # run: | + # chmod +x starter.sh + # ./starter.sh ${{ matrix.arangodb_config }} ${{ matrix.arangodb_license }} ${{ matrix.arangodb_version }} + + # - name: Install Dependencies + # run: pip install -e .[dev] + + # - name: List Docker Containers + # run: docker ps -a + + # - name: Pytest + # run: | + # args=("--host" "localhost" "--port=8529") + + # if [ ${{ matrix.arangodb_config }} = "cluster" ]; then + # args+=("--cluster" "--port=8539" "--port=8549") + # fi + + # if [ ${{ matrix.arangodb_license }} = "enterprise" ]; then + # args+=("--enterprise") + # fi + + # echo "Running pytest with args: ${args[@]}" + # pytest --cov=arango --cov-report=xml "${args[@]}" + + docs: + runs-on: ubuntu-latest + + name: Docs + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Fetch all tags and branches + run: git fetch --prune --unshallow + + - 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:latest --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: '3.10' + + - name: Debug with tmate + uses: mxschmitt/action-tmate@v3 + if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} + + - name: Run pre-commit checks + uses: pre-commit/action@v3.0.0 + + - name: Install dependencies + run: pip install .[dev] + + - 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 diff --git a/starter.sh b/starter.sh index e69ce24b..b0374c58 100755 --- a/starter.sh +++ b/starter.sh @@ -9,74 +9,51 @@ # ./starter.sh cluster enterprise 3.11.4 setup="${1:-single}" -if [[ "$setup" != "single" && "$setup" != "cluster" ]]; then +license="${2:-community}" +version="${3:-latest}" + +extra_ports="" +if [ "$setup" == "single" ]; then + echo "" +elif [ "$setup" == "cluster" ]; then + extra_ports="-p 8539:8539 -p 8549:8549" +else echo "Invalid argument. Please provide either 'single' or 'cluster'." exit 1 fi -license="${2:-all}" -if [[ "$license" != "community" && "$license" != "enterprise" ]]; then +image_name="" +if [ "$license" == "community" ]; then + image_name="arangodb" +elif [ "$license" == "enterprise" ]; then + image_name="enterprise" +else echo "Invalid argument. Please provide either 'community' or 'enterprise'." exit 1 fi -version="${3:-3.11.4}" - -if [ "$setup" == "single" ]; then - if [ "$license" == "community" ]; then - echo "Starting community single server..." - docker run -d --rm \ - --name arango \ - -p 8528:8528 \ - -p 8529:8529 \ - -v "$(pwd)/tests/static/":/tests/static \ - -v /tmp:/tmp \ - arangodb/arangodb:"$version" \ - /bin/sh -c "arangodb --configuration=/tests/static/single.conf" - elif [ "$license" == "enterprise" ]; then - echo "Starting enterprise single server..." - docker run -d --rm \ - --name arango \ - -p 8528:8528 \ - -p 8529:8529 \ - -v "$(pwd)/tests/static/":/tests/static \ - -v /tmp:/tmp \ - arangodb/enterprise:"$version" \ - /bin/sh -c "arangodb --configuration=/tests/static/single.conf" - fi -elif [ "$setup" == "cluster" ]; then - if [ "$license" == "community" ]; then - echo "Starting community cluster..." - docker run -d --rm \ - --name arango \ - -p 8528:8528 \ - -p 8529:8529 \ - -p 8539:8539 \ - -p 8549:8549 \ - -v "$(pwd)/tests/static/":/tests/static \ - -v /tmp:/tmp \ - arangodb/arangodb:"$version" \ - /bin/sh -c "arangodb --configuration=/tests/static/cluster.conf" - elif [ "$license" == "enterprise" ]; then - echo "Starting enterprise cluster..." - docker run -d --rm \ - --name arango \ - -p 8528:8528 \ - -p 8529:8529 \ - -p 8539:8539 \ - -p 8549:8549 \ - -v "$(pwd)/tests/static/":/tests/static \ - -v /tmp:/tmp \ - arangodb/enterprise:"$version" \ - /bin/sh -c "arangodb --configuration=/tests/static/cluster.conf" - fi +conf_file="" +if [[ "${version%.*}" == "3.10" ]]; then + conf_file="${setup}-3.10" +else + conf_file="${setup}" fi +docker run -d --rm \ + --name arango \ + -p 8528:8528 \ + -p 8529:8529 \ + $extra_ports \ + -v "$(pwd)/tests/static/":/tests/static \ + -v /tmp:/tmp \ + "arangodb/$image_name:$version" \ + /bin/sh -c "arangodb --configuration=/tests/static/$conf_file.conf" + wget --quiet --waitretry=1 --tries=120 -O - http://localhost:8528/version | jq if [ $? -eq 0 ]; then - echo "OK starter ready" - exit 0 + echo "OK starter ready" + exit 0 else - echo "ERROR starter not ready, giving up" - exit 1 + echo "ERROR starter not ready, giving up" + exit 1 fi