Skip to content

Commit

Permalink
Merge pull request #58 from cloudblue/LITE-26347-poetry-mkdocs
Browse files Browse the repository at this point in the history
LITE-26347: standarise with mkdocs and poetry
  • Loading branch information
Francesco Faraone authored Mar 15, 2023
2 parents ce3db56 + 672eac8 commit 75a89a7
Show file tree
Hide file tree
Showing 83 changed files with 3,023 additions and 1,461 deletions.
5 changes: 0 additions & 5 deletions .coveragerc

This file was deleted.

30 changes: 5 additions & 25 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
FROM python:3.8

# Update the VARIANT arg in devcontainer.json to pick a Python version: 3, 3.8, 3.7, 3.6
# To fully customize the contents of this image, use the following Dockerfile instead:
# https://github.com/microsoft/vscode-dev-containers/tree/v0.128.0/containers/python-3/.devcontainer/base.Dockerfile
ARG VARIANT="3"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

COPY ./requirements /app/requirements

RUN pip install -r /app/requirements/docs.txt

# [Optional] If your requirements rarely change, uncomment this section to add them to the image.
#
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp

# [Optional] Uncomment this section to install additional packages.
#
# RUN apt-get update \
# && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
COPY pyproject.toml pyproject.toml
RUN pip install --upgrade pip
RUN pip install poetry
#RUN poetry install

5 changes: 1 addition & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"build": {
"dockerfile": "Dockerfile",
"context": "..",
// Update 'VARIANT' to pick a Python version. Rebuild the container
// if it already exists to update. Available variants: 3, 3.6, 3.7, 3.8
"args": { "VARIANT": "3" }
},

// Set *default* container specific settings.json values on container create.
Expand All @@ -33,7 +30,7 @@
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",
// "postCreateCommand": "pip install --upgrade pip && pip install poetry && poetry install"

// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
Expand Down
42 changes: 29 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,66 @@ on:

jobs:
build:
name: Build and test on Python ${{ matrix.python-version }}
name: Build and test ${{ matrix.python-version }} - ${{ matrix.django-version }}
runs-on: ubuntu-latest
strategy:
matrix:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
django-version: ['3.2', '4.0', '4.1']
exclude:
- python-version: '3.7'
django-version: '4.0'
- python-version: '3.7'
django-version: '4.1'
steps:
- name: Checkout project
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Replace python version
if: ${{ matrix.python-version != '3.7' }}
run: sed -i "s/python = \">=3.7,<4\"/python = \">=3.8,<4\"/" ./pyproject.toml
- name: Install dependencies
run: |
pip install -r requirements/dev.txt
pip install -r requirements/test.txt
poetry install
- name: Force django version ${{ matrix.django-version }}
run: |
poetry add django==${{ matrix.django-version }}.*
- name: Linting
run: |
flake8
poetry run flake8
- name: Testing
run: |
python setup.py test
poetry run pytest
sonar:
name: Quality Analysis by sonar
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install -r requirements/dev.txt
pip install -r requirements/test.txt
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Testing
run: |
python setup.py test
poetry run pytest
- name: Fix coverage report for Sonar
run: |
sed -i 's/\/home\/runner\/work\/django-rql\/django-rql\//\/github\/workspace\//g' ./tests/reports/coverage.xml
Expand Down
35 changes: 21 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,26 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: '3.8'
- name: Install dependencies
run: |
pip install -r requirements/dev.txt
pip install -r requirements/test.txt
python -m pip install --upgrade pip
pip install poetry
poetry install
pip install twine
- name: Linting
run: |
flake8
poetry run flake8
- name: Testing
run: |
python setup.py test
poetry run pytest
- name: Fix coverage report for Sonar
run: |
sed -i 's/\/home\/runner\/work\/django-rql\/django-rql\//\/github\/workspace\//g' ./tests/reports/coverage.xml
Expand All @@ -47,10 +45,19 @@ jobs:
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Publish to PyPI
- name: Extract tag name
uses: actions/github-script@v6
id: tag
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
return context.payload.ref.replace(/refs\/tags\//, '')
- name: Build and publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
poetry version ${{ steps.tag.outputs.result }}
poetry build
poetry publish -u $TWINE_USERNAME -p $TWINE_PASSWORD
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ tests/reports/

docs/_build

_generated_filters*.py
_generated_filters*.py

.devcontainer/
poetry.toml
.vscode/
16 changes: 16 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Required
version: 2

build:
os: ubuntu-20.04
tools:
python: "3.9"

mkdocs:
configuration: mkdocs.yml

python:
install:
- requirements: requirements/docs.txt
- method: pip
path: .
45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2020 Ingram Micro Inc.
Copyright 2023 Ingram Micro Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ class PublisherFilters(RQLFilterClass):
Django Rest Framework Extensions
================================
1. Pagination (limit, offset)
0. Support for custom fields, inherited at any depth from basic model fields, like CharField().
0. Backend `DjangoFiltersRQLFilterBackend` with automatic conversion of [Django-Filters](https://django-filter.readthedocs.io/en/master/) query to RQL query.
0. OpenAPI docs are autogenerated for filter classes.
2. Support for custom fields, inherited at any depth from basic model fields, like CharField().
3. Backend `DjangoFiltersRQLFilterBackend` with automatic conversion of [Django-Filters](https://django-filter.readthedocs.io/en/master/) query to RQL query.
4. OpenAPI docs are autogenerated for filter classes.

Best Practices
==============
Expand All @@ -270,20 +270,22 @@ Best Practices
Development
===========

1. Python 3.6+
2. Install dependencies `requirements/dev.txt` and `requirements/extra.txt`
3. We use `isort` library to order and format our imports, and we check it using `flake8-isort` library (automatically on `flake8` run).
1. Python 3.7+
2. Install poetry: `pip install poetry`
3. Install dependencies: `poetry install`
4. We use `isort` library to order and format our imports, and we check it using `flake8-isort` library (automatically on `flake8` run).
For convenience you may run `isort .` to order imports.
5. Run flake8: `poetry run flake8`

Testing
=======

1. Python 3.6+
0. Install dependencies `requirements/test.txt`
0. `export PYTHONPATH=/your/path/to/django-rql/`
1. Python 3.7+
2. Install poetry: `pip install poetry`
3. Install dependencies: `poetry install`

Check code style: `flake8`
Run tests: `pytest`
Check code style: `poetry run flake8`
Run tests: `poetry run pytest`

Tests reports are generated in `tests/reports`.
* `out.xml` - JUnit test results
Expand Down
2 changes: 1 addition & 1 deletion dj_rql/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#
# Copyright © 2020 Ingram Micro Inc. All rights reserved.
# Copyright © 2023 Ingram Micro Inc. All rights reserved.
#
2 changes: 1 addition & 1 deletion dj_rql/_dataclasses.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright © 2022 Ingram Micro Inc. All rights reserved.
# Copyright © 2023 Ingram Micro Inc. All rights reserved.
#


Expand Down
2 changes: 1 addition & 1 deletion dj_rql/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright © 2022 Ingram Micro Inc. All rights reserved.
# Copyright © 2023 Ingram Micro Inc. All rights reserved.
#

from django.db import models
Expand Down
2 changes: 1 addition & 1 deletion dj_rql/drf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright © 2021 Ingram Micro Inc. All rights reserved.
# Copyright © 2023 Ingram Micro Inc. All rights reserved.
#

from dj_rql.drf._utils import get_query
Expand Down
2 changes: 1 addition & 1 deletion dj_rql/drf/_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright © 2020 Ingram Micro Inc. All rights reserved.
# Copyright © 2023 Ingram Micro Inc. All rights reserved.
#

from urllib.parse import unquote
Expand Down
Loading

0 comments on commit 75a89a7

Please sign in to comment.