Skip to content

Commit d168d6f

Browse files
committed
Add GitHub Action workflows, strict type checking and other improvements
1 parent 0e82788 commit d168d6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+7715
-7933
lines changed

.github/workflows/build.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches: [ main, dev ]
6+
pull_request:
7+
branches: [ main, dev ]
8+
jobs:
9+
build:
10+
name: Test
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [ 3.6, 3.7, 3.8, 3.9 ]
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Create ArangoDB Docker container
18+
run: >
19+
docker create --name arango -p 8529:8529 -e ARANGO_ROOT_PASSWORD=passwd
20+
arangodb/arangodb:3.7.7 --server.jwt-secret-keyfile=/tmp/keyfile
21+
- name: Copy Foxx service zip into ArangoDB Docker container
22+
run: docker cp tests/static/service.zip arango:/tmp/service.zip
23+
- name: Copy keyfile into ArangoDB Docker container
24+
run: docker cp tests/static/keyfile arango:/tmp/keyfile
25+
- name: Start ArangoDB Docker container
26+
run: docker start arango
27+
- name: Fetch complete history for all tags and branches
28+
run: git fetch --prune --unshallow
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v2
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
- name: Setup pip
34+
run: python -m pip install --upgrade pip setuptools wheel
35+
- name: Install packages
36+
run: pip install .[dev]
37+
- name: Run black
38+
run: black --check .
39+
- name: Run flake8
40+
run: flake8 .
41+
- name: Run isort
42+
run: isort --check --profile=black .
43+
- name: Run mypy
44+
run: mypy arango
45+
- name: Run pytest
46+
run: py.test --complete --cov=arango --cov-report=xml
47+
- name: Run Sphinx doctest
48+
run: python -m sphinx -b doctest docs docs/_build
49+
- name: Run Sphinx HTML
50+
run: python -m sphinx -b html -W docs docs/_build
51+
- name: Upload coverge to Codecov
52+
uses: codecov/codecov-action@v1
53+
if: matrix.python-version == '3.8'
54+
with:
55+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/codeql.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CodeQL
2+
on:
3+
push:
4+
branches: [ main, dev ]
5+
pull_request:
6+
branches: [ main, dev ]
7+
schedule:
8+
- cron: '21 2 * * 3'
9+
10+
jobs:
11+
analyze:
12+
name: Analyze
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v2
17+
- name: Initialize CodeQL
18+
uses: github/codeql-action/init@v1
19+
with:
20+
languages: 'python'
21+
- name: Perform CodeQL Analysis
22+
uses: github/codeql-action/analyze@v1

.github/workflows/pypi.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Upload to PyPI
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
upload:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Fetch complete history for all tags and branches
11+
run: git fetch --prune --unshallow
12+
- name: Set up Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: '3.x'
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install setuptools wheel twine setuptools-scm[toml]
20+
- name: Build distribution
21+
run: python setup.py sdist bdist_wheel
22+
- name: Publish to PyPI Test
23+
env:
24+
TWINE_USERNAME: __token__
25+
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
26+
run: twine upload --repository testpypi dist/*
27+
- name: Publish to PyPI
28+
env:
29+
TWINE_USERNAME: __token__
30+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
31+
run: twine upload --repository pypi dist/*

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,6 @@ localdata/
114114

115115
# Node Modules
116116
node_modules/
117+
118+
# setuptools_scm
119+
arango/version.py

.pre-commit-config.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.4.0
4+
hooks:
5+
- id: check-case-conflict
6+
- id: check-executables-have-shebangs
7+
- id: check-json
8+
- id: check-merge-conflict
9+
- id: check-symlinks
10+
- id: check-toml
11+
- id: check-yaml
12+
- id: end-of-file-fixer
13+
- id: mixed-line-ending
14+
- repo: https://github.com/psf/black
15+
rev: 20.8b1
16+
hooks:
17+
- id: black
18+
- repo: https://github.com/timothycrosley/isort
19+
rev: 5.7.0
20+
hooks:
21+
- id: isort
22+
args: [ --profile, black ]
23+
- repo: https://github.com/pre-commit/mirrors-mypy
24+
rev: v0.790
25+
hooks:
26+
- id: mypy
27+
args: [ arango ]
28+
- repo: https://gitlab.com/pycqa/flake8
29+
rev: 3.8.4
30+
hooks:
31+
- id: flake8

.travis.yml

-29
This file was deleted.

CONTRIBUTING.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Contributing
2+
3+
Set up dev environment:
4+
```shell
5+
cd ~/your/repository/fork # Activate venv if you have one (recommended)
6+
pip install -e .[dev] # Install dev dependencies (e.g. black, mypy, pre-commit)
7+
pre-commit install # Install git pre-commit hooks
8+
```
9+
10+
Run unit tests with coverage:
11+
12+
```shell
13+
py.test --cov=./ --cov-report=html # Open htmlcov/index.html in your browser
14+
```
15+
16+
Build and test documentation:
17+
18+
```shell
19+
python -m sphinx docs docs/_build # Open docs/_build/index.html in your browser
20+
```
21+
22+
Thank you for your contribution!

LICENSE

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The MIT License (MIT)
1+
MIT License
22

3-
Copyright (c) 2016 Joohwan Oh
3+
Copyright (c) 2016-2021 Joohwan Oh
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -19,5 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-
23-

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
include README.rst LICENSE
1+
include README.md LICENSE
22
prune tests

README.md

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# python-arango
2+
3+
Python driver for [ArangoDB](https://www.arangodb.com).
4+
5+
## Requirements
6+
7+
Python 3.6+ and ArangoDB 3.7+
8+
9+
## Installation
10+
11+
```shell
12+
pip install python-arango
13+
```
14+
15+
## Getting Started
16+
17+
Here is a simple usage example:
18+
19+
```python
20+
from arango import ArangoClient
21+
22+
# Initialize the client for ArangoDB.
23+
client = ArangoClient(hosts="http://localhost:8529")
24+
25+
# Connect to "_system" database as root user.
26+
sys_db = client.db("_system", username="root", password="passwd")
27+
28+
# Create a new database named "test".
29+
sys_db.create_database("test")
30+
31+
# Connect to "test" database as root user.
32+
db = client.db("test", username="root", password="passwd")
33+
34+
# Create a new collection named "students".
35+
students = db.create_collection("students")
36+
37+
# Add a hash index to the collection.
38+
students.add_hash_index(fields=["name"], unique=True)
39+
40+
# Insert new documents into the collection.
41+
students.insert({"name": "jane", "age": 39})
42+
students.insert({"name": "josh", "age": 18})
43+
students.insert({"name": "judy", "age": 21})
44+
45+
# Execute an AQL query and iterate through the result cursor.
46+
cursor = db.aql.execute("FOR doc IN students RETURN doc")
47+
student_names = [document["name"] for document in cursor]
48+
```
49+
50+
Here is another example with graphs:
51+
52+
```python
53+
from arango import ArangoClient
54+
55+
# Initialize the client for ArangoDB.
56+
client = ArangoClient(hosts="http://localhost:8529")
57+
58+
# Connect to "test" database as root user.
59+
db = client.db("test", username="root", password="passwd")
60+
61+
# Create a new graph named "school".
62+
graph = db.create_graph("school")
63+
64+
# Create vertex collections for the graph.
65+
students = graph.create_vertex_collection("students")
66+
lectures = graph.create_vertex_collection("lectures")
67+
68+
# Create an edge definition (relation) for the graph.
69+
register = graph.create_edge_definition(
70+
edge_collection="register",
71+
from_vertex_collections=["students"],
72+
to_vertex_collections=["lectures"]
73+
)
74+
75+
# Insert vertex documents into "students" (from) vertex collection.
76+
students.insert({"_key": "01", "full_name": "Anna Smith"})
77+
students.insert({"_key": "02", "full_name": "Jake Clark"})
78+
students.insert({"_key": "03", "full_name": "Lisa Jones"})
79+
80+
# Insert vertex documents into "lectures" (to) vertex collection.
81+
lectures.insert({"_key": "MAT101", "title": "Calculus"})
82+
lectures.insert({"_key": "STA101", "title": "Statistics"})
83+
lectures.insert({"_key": "CSC101", "title": "Algorithms"})
84+
85+
# Insert edge documents into "register" edge collection.
86+
register.insert({"_from": "students/01", "_to": "lectures/MAT101"})
87+
register.insert({"_from": "students/01", "_to": "lectures/STA101"})
88+
register.insert({"_from": "students/01", "_to": "lectures/CSC101"})
89+
register.insert({"_from": "students/02", "_to": "lectures/MAT101"})
90+
register.insert({"_from": "students/02", "_to": "lectures/STA101"})
91+
register.insert({"_from": "students/03", "_to": "lectures/CSC101"})
92+
93+
# Traverse the graph in outbound direction, breadth-first.
94+
result = graph.traverse(
95+
start_vertex="students/01",
96+
direction="outbound",
97+
strategy="breadthfirst"
98+
)
99+
```
100+
101+
Please see [documentation](http://python-driver-for-arangodb.readthedocs.io/en/master/index.html)
102+
for more details.

0 commit comments

Comments
 (0)