Skip to content

Commit 0a6d2a8

Browse files
authored
Merge pull request #604 from FlorentinD/ci-build-script
Add CI script to run client against AuraDS
2 parents 4f1068e + 19e2a5c commit 0a6d2a8

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

requirements/dev/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ black[jupyter] == 23.12.1
33
flake8 == 6.1.0
44
isort == 5.12.0
55
mypy == 1.8.0
6-
nbconvert == 7.6.0
6+
nbconvert == 7.11.0
77
pandas-stubs == 2.0.3.230814
88
pytest-annotate == 1.0.5
99
tox == 4.11.3

scripts/ci/run_targeting_aura

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import logging
2+
import os
3+
import random as rd
4+
import sys
5+
6+
from ...graphdatascience.session.aura_api import AuraApi
7+
8+
logging.basicConfig(level=logging.INFO)
9+
10+
11+
def run_tests(uri, username, password):
12+
cmd = f'NEO4J_URI={uri} NEO4J_USER={username} NEO4J_PASSWORD={password} tox -e \$(tox -l | grep aura | grep main | paste -sd \',\' -)'
13+
14+
if os.system(cmd) != 0:
15+
raise Exception('Failed to run tests')
16+
17+
18+
def run_notebooks(uri, username, password):
19+
cmd = f'NEO4J_URI={uri} NEO4J_USER={username} NEO4J_PASSWORD={password} tox -e jupyter-notebook-ci'
20+
21+
if os.system(cmd) != 0:
22+
raise Exception('Failed to run notebooks')
23+
24+
25+
def main():
26+
aura_api = AuraApi(
27+
os.environ.get('AURA_API_CLIENT_ID'),
28+
os.environ.get('AURA_API_CLIENT_SECRET')
29+
)
30+
MAX_INT = 2**31
31+
32+
create_result = aura_api.create_instance(
33+
name='ci-instance-' + str(rd.randint(0, MAX_INT)),
34+
memory='8GB',
35+
cloud_provider='gcp',
36+
region='europe-west1'
37+
)
38+
instance_id = create_result.id
39+
logging.info('Creation of database accepted')
40+
41+
try:
42+
aura_api.wait_for_instance_running(instance_id)
43+
logging.info('Database %s up and running', instance_id)
44+
45+
if sys.argv[1] == 'tests':
46+
run_tests(
47+
create_result['connection_url'],
48+
create_result['username'],
49+
create_result['password'],
50+
)
51+
logging.info('Tests ran successfully')
52+
elif sys.argv[1] == 'notebooks':
53+
run_notebooks(
54+
create_result['connection_url'],
55+
create_result['username'],
56+
create_result['password'],
57+
)
58+
logging.info('Notebooks ran successfully')
59+
else:
60+
logging.error(f'Invalid target: {sys.argv[1]}')
61+
finally:
62+
logging.info('Teardown of instance %s', instance_id)
63+
aura_api.delete_instance(instance_id)
64+
65+
66+
if __name__ == '__main__':
67+
main()

0 commit comments

Comments
 (0)