Skip to content

Commit

Permalink
[FMWK-73] Add poetry instructions in CONTRIBUTING.md (#12)
Browse files Browse the repository at this point in the history
* Support Python client 8.0.0
* poetry.lock: update all dependencies
* python-package.yml: clean up
* Add flake8 config
* CONTRIBUTING.md: update build instructions
* README.md: update compatibility notes
  • Loading branch information
juliannguyen4 committed Nov 22, 2022
1 parent 9408d37 commit bad3a77
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 111 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 127
38 changes: 19 additions & 19 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,39 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9"]
python-version: [
"3.7",
"3.8",
"3.9"
]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Setup Poetry
run: |
# Install poetry
curl -sSL https://install.python-poetry.org | python3 -
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install developer dependencies and documentapi
run: poetry install
- name: Lint with flake8
run: |
# The GitHub editor is 127 chars wide
poetry run flake8 --count --max-complexity=10 --show-source --max-line-length=127 documentapi/ docs/cookbook-ex.py tests/
# The GitHub editor is 127 chars wide
run: poetry run flake8 --count --show-source
- name: Build documentation
run: |
cd docs/
poetry run sphinx-build -b spelling . build -W
poetry run sphinx-build -b html . htmldir -W
run: poetry run sphinx-build -b spelling . build -W
working-directory: docs/
- name: Check spelling in docs
run: poetry run sphinx-build -b html . htmldir -W
working-directory: docs/
- name: Set up Aerospike Database
uses: reugn/github-action-aerospike@v1
- name: Wait for database to start
run: sleep 3
- name: Test cookbook example
run: |
# Wait for server to finish startup
sleep 3
cd docs/
poetry run python3 cookbook-ex.py
run: poetry run python3 cookbook-ex.py
working-directory: docs/
- name: Run unit tests
run: |
poetry run coverage run -m unittest tests/test.py
run: poetry run coverage run -m unittest tests/test.py
- name: Run coverage test
run: poetry run coverage report --fail-under=100 --include=documentapi/api.py
41 changes: 22 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@

## Setup

Create a new virtual environment to test the code (recommended):
```bash session
python3 -m venv .venv
. .venv/bin/activate
```
Please use the supported Python versions of this project for development.

1. Install [Poetry](https://python-poetry.org/docs/#installation).
2. Create a virtual environment in Poetry and activate it in a new shell:

To install dependencies for development:
```bash session
pip install -r requirements.txt
```
poetry shell
```

## Unit testing
3. Install the project and its dependencies in editable mode:

The tests use a locally built and installed module for this code:
```bash session
# Build current code and install package
pip install --editable .
```
poetry install
```

Editable mode allows you to make changes to the project and test those changes without recompiling the code.

## Unit testing

For now, unit tests rely on an Aerospike server to work.
Run a local Aerospike server on a Docker container:

```bash session
# Get the server image if not already downloaded
docker pull aerospike/aerospike-server
Expand All @@ -33,19 +34,22 @@ docker run --name aerospike -d -p 3000:3000 aerospike/aerospike-server

Wait a few seconds for Aerospike server to fully start.
Then run the tests:

```bash session
python3 tests/test.py
```

## Documentation

To build documentation:

```bash session
cd docs/
sphinx-build -b html . htmldir -W
```

Spelling errors must be corrected using:

```bash session
sphinx-build -b spelling . build -W
```
Expand All @@ -54,10 +58,10 @@ sphinx-build -b spelling . build -W

This code uses [flake8](https://github.com/pycqa/flake8) for codestyle checking.

To run codestyle tests:
To run codestyle tests (already configured in `.flake8` for this project):

```bash session
cd documentapi/
flake8 . --count --max-complexity=10 --show-source --max-line-length=127
flake8
```

## Adding features
Expand All @@ -73,7 +77,6 @@ This project depends on a [fork](https://github.com/aerospike-community/jsonpath
docker container stop aerospike
docker container rm aerospike

# Quit and delete virtual environment
deactivate
rm -r .venv
# Deactivate the virtual environment and exit the shell
exit
```
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ This is currently in beta, so there may be bugs or features that aren't supporte
- [PyPI Package](https://pypi.org/project/document-lib-python/)

## Compatibility
- Python 3.7 - 3.9
- Aerospike Python Client 7.0.2
- All supported Python versions from the Python client
- Aerospike Python Client 6.x - 8.x

## Features

Expand Down

0 comments on commit bad3a77

Please sign in to comment.