Skip to content

Commit 5f93013

Browse files
authored
Run jobs on self-hosted runners (#94)
* experiment * enabling remote docker * using arangodb container * fix * fix * reverted starter.sh * added imports test * added imports test to the CI * simplified and added arangodb/ images * adding arangodb.log to artifacts
1 parent 00e8dd0 commit 5f93013

3 files changed

Lines changed: 163 additions & 46 deletions

File tree

.circleci/config.yml

Lines changed: 129 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,57 @@
11
version: 2.1
22

33
executors:
4-
python-container:
4+
python-container: # used by lint and import-test jobs
5+
parameters:
6+
python_version:
7+
type: string
8+
default: "3.14"
59
docker:
6-
- image: cimg/python:3.12
10+
- image: cimg/python:<< parameters.python_version >>
711
resource_class: arangodb/small-amd64
8-
python-vm:
9-
machine:
10-
image: ubuntu-2404:current
11-
resource_class: medium
12+
arangodb-container: # runs integration tests
13+
parameters:
14+
arangodb_image:
15+
type: string
16+
docker:
17+
- image: << parameters.arangodb_image >>
18+
entrypoint: /bin/sh
19+
command: -c "while true; do sleep 10; done"
20+
user: root
21+
resource_class: arangodb/medium-amd64
1222

1323
workflows:
1424
ci:
1525
jobs:
1626
- lint
17-
- test:
18-
name: Python (<< matrix.python_version >>) - ArangoDB (enterprise, << matrix.arangodb_version >> << matrix.arangodb_config >>)
27+
- import-test:
28+
name: Imports (Python << matrix.python_version >>)
1929
matrix:
2030
parameters:
21-
python_version: ["3.13"]
22-
arangodb_config: ["single", "cluster"]
23-
arangodb_license: ["enterprise"]
24-
arangodb_version: ["3.12"]
25-
- test:
26-
name: Python (<< matrix.python_version >>) - ArangoDB (enterprise-preview, << matrix.arangodb_version >> << matrix.arangodb_config >>)
31+
python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
32+
- integration-test:
33+
name: ArangoDB (enterprise, 3.12 << matrix.arangodb_config >>)
2734
matrix:
2835
parameters:
29-
python_version: ["3.13"]
3036
arangodb_config: ["single", "cluster"]
31-
arangodb_license: ["enterprise-preview"]
32-
arangodb_version: ["4.0-nightly"]
33-
- test:
34-
name: Python (<< matrix.python_version >>) - ArangoDB (enterprise, 3.12 cluster)
37+
arangodb_image: ["arangodb/enterprise:3.12"]
38+
arangodb_conf_version: ["3.12"]
39+
- integration-test:
40+
name: ArangoDB (enterprise-preview, 4.0-nightly << matrix.arangodb_config >>)
3541
matrix:
3642
parameters:
37-
python_version: ["3.10", "3.11", "3.12"]
38-
arangodb_config: ["cluster"]
39-
arangodb_license: ["enterprise"]
40-
arangodb_version: ["3.12"]
43+
arangodb_config: ["single", "cluster"]
44+
arangodb_image: ["arangodb/enterprise-preview:4.0-nightly"]
45+
arangodb_conf_version: ["4.0"]
4146

4247
jobs:
4348
lint:
4449
executor: python-container
45-
resource_class: arangodb/small-amd64
4650
steps:
4751
- checkout
4852
- run:
4953
name: Install Dependencies
50-
command: pip install .[dev]
54+
command: python -m pip install .[dev]
5155
- run:
5256
name: Run black
5357
command: black --check --verbose --diff --color --config=pyproject.toml ./arangoasync ./tests/
@@ -60,58 +64,137 @@ jobs:
6064
- run:
6165
name: Run mypy
6266
command: mypy ./arangoasync
63-
test:
67+
import-test:
68+
parameters:
69+
python_version:
70+
type: string
71+
executor:
72+
name: python-container
73+
python_version: << parameters.python_version >>
74+
steps:
75+
- checkout
76+
- run:
77+
name: Install Dependencies
78+
command: |
79+
python --version
80+
python -m pip install .[dev]
81+
- run:
82+
name: Run Import Tests
83+
command: python -m pytest tests/test_imports.py --skip-arango-setup --color=yes --code-highlight=yes
84+
integration-test:
6485
parameters:
65-
python_version:
66-
type: string
6786
arangodb_config:
6887
type: string
69-
arangodb_license:
88+
arangodb_image:
7089
type: string
71-
arangodb_version:
90+
arangodb_conf_version:
7291
type: string
73-
executor: python-vm
92+
executor:
93+
name: arangodb-container
94+
arangodb_image: << parameters.arangodb_image >>
7495
steps:
96+
- run:
97+
name: Bootstrap CI Tools
98+
command: |
99+
apk add --no-cache \
100+
bash \
101+
build-base \
102+
ca-certificates \
103+
curl \
104+
git \
105+
jq \
106+
openssh-client \
107+
openssl-dev \
108+
py3-pip \
109+
py3-virtualenv \
110+
python3 \
111+
python3-dev
75112
- checkout
76113
- run:
77114
name: Setup ArangoDB
78115
command: |
79-
chmod +x starter.sh
80-
./starter.sh << parameters.arangodb_config >> << parameters.arangodb_license >> << parameters.arangodb_version >>
81-
- restore_cache:
82-
key: pip-and-local-cache
116+
mkdir -p /tests
117+
if [ ! -e /tests/static ]; then
118+
ln -s "$PWD/tests/static" /tests/static
119+
fi
120+
121+
conf_file="/tests/static/<< parameters.arangodb_config >>-<< parameters.arangodb_conf_version >>.conf"
122+
if [ ! -f "$conf_file" ]; then
123+
echo "Missing configuration file: $conf_file"
124+
exit 1
125+
fi
126+
127+
arangodb --configuration="$conf_file" > arangodb.log 2>&1 &
128+
echo "$!" > arangodb.pid
129+
130+
ports="8529"
131+
if [ << parameters.arangodb_config >> = "cluster" ]; then
132+
ports="$ports 8539 8549"
133+
fi
134+
135+
for port in $ports; do
136+
echo "Waiting for ArangoDB at http://localhost:$port/_api/version"
137+
for attempt in $(seq 1 120); do
138+
if curl --fail --silent --show-error \
139+
--user root:passwd \
140+
"http://localhost:$port/_api/version" | jq; then
141+
break
142+
fi
143+
144+
if ! kill -0 "$(cat arangodb.pid)" 2>/dev/null; then
145+
echo "ArangoDB process exited before port $port became ready"
146+
exit 1
147+
fi
148+
149+
if [ "$attempt" -eq 120 ]; then
150+
echo "Timed out waiting for ArangoDB on port $port"
151+
exit 1
152+
fi
153+
154+
sleep 1
155+
done
156+
done
157+
- run:
158+
name: Show ArangoDB Logs
159+
command: tail -n 1000 arangodb.log
160+
when: always
83161
- run:
84162
name: Setup Python
163+
shell: /bin/bash -eo pipefail
85164
command: |
86-
pyenv --version
87-
pyenv install -f << parameters.python_version >>
88-
pyenv global << parameters.python_version >>
165+
python3 --version
166+
python3 -m virtualenv .venv
167+
source .venv/bin/activate
168+
python --version
169+
python -m pip --version
89170
- run:
90171
name: Install Dependencies
91-
command: pip install -e .[dev]
92-
- run: docker ps -a
93-
- run: docker logs arango
172+
shell: /bin/bash -eo pipefail
173+
command: |
174+
source .venv/bin/activate
175+
python -m pip install -e .[dev]
94176
- run:
95177
name: Run pytest
178+
shell: /bin/bash -eo pipefail
96179
command: |
97180
mkdir test-results
98181
mkdir htmlcov
99182
183+
source .venv/bin/activate
184+
100185
args=("--junitxml=test-results/junit.xml" "--log-cli-level=DEBUG" "--host" "localhost" "--port=8529")
101186
if [ << parameters.arangodb_config >> = "cluster" ]; then
102187
args+=("--cluster" "--port=8539" "--port=8549")
103188
fi
104189
105-
if [ << parameters.arangodb_license >> != "enterprise" ] && [ << parameters.arangodb_license >> != "enterprise-preview" ]; then
106-
args+=("--skip" "enterprise")
107-
fi
108-
109190
echo "Running pytest with args: ${args[@]}"
110-
pytest --cov=arangoasync --cov-report=html:htmlcov --color=yes --code-highlight=yes "${args[@]}"
191+
pytest tests --cov=arangoasync --cov-report=html:htmlcov --color=yes --code-highlight=yes "${args[@]}"
111192
- store_artifacts:
112193
path: htmlcov
113194
destination: coverage-report
114195
- store_artifacts:
115196
path: test-results
197+
- store_artifacts:
198+
path: arangodb.log
116199
- store_test_results:
117200
path: test-results

tests/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class GlobalData:
3131
foxx_path: str = None
3232
backup_path: str = None
3333
db_version: version.Version = version.parse("0.0.0")
34+
skip_arango_setup: bool = False
3435

3536

3637
global_data = GlobalData()
@@ -82,9 +83,18 @@ def pytest_addoption(parser):
8283
default=[],
8384
help="Skip specific tests",
8485
)
86+
parser.addoption(
87+
"--skip-arango-setup",
88+
action="store_true",
89+
help="Skip the ArangoDB connection check during pytest configuration",
90+
)
8591

8692

8793
def pytest_configure(config):
94+
if config.getoption("skip_arango_setup"):
95+
global_data.skip_arango_setup = True
96+
return
97+
8898
ports = config.getoption("port") or ["8529"]
8999
hosts = [f"http://{config.getoption('host')}:{p}" for p in ports]
90100
url = hosts[0]
@@ -286,6 +296,9 @@ def db_version():
286296
@pytest_asyncio.fixture(autouse=True)
287297
async def teardown():
288298
yield
299+
if global_data.skip_arango_setup:
300+
return
301+
289302
async with ArangoClient(hosts=global_data.url) as client:
290303
sys_db = await client.db(
291304
global_data.sys_db_name,

tests/test_imports.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import importlib
2+
import pkgutil
3+
4+
import pytest
5+
6+
import arangoasync
7+
8+
9+
def arangoasync_modules():
10+
yield arangoasync.__name__
11+
12+
for module_info in pkgutil.walk_packages(
13+
arangoasync.__path__,
14+
prefix=f"{arangoasync.__name__}.",
15+
):
16+
yield module_info.name
17+
18+
19+
@pytest.mark.parametrize("module_name", sorted(arangoasync_modules()))
20+
def test_import_module(module_name):
21+
importlib.import_module(module_name)

0 commit comments

Comments
 (0)