Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# This workflow will upload the django-odata Python Package to PyPI when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

name: Publish Django-OData to PyPI

on:
release:
types: [published]

permissions:
contents: read

jobs:
tests:
runs-on: ubuntu-latest
env:
DJANGO_SETTINGS_MODULE: tests.settings
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
django-version: ["4.2", "5.0", "5.1", "5.2"]
exclude:
# Django 5.0+ requires Python 3.10+
- python-version: "3.8"
django-version: "5.0"
- python-version: "3.8"
django-version: "5.1"
- python-version: "3.8"
django-version: "5.2"
- python-version: "3.9"
django-version: "5.0"
- python-version: "3.9"
django-version: "5.1"
- python-version: "3.9"
django-version: "5.2"

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install Django==${{ matrix.django-version }}
pip install -e .[dev]

- name: Run tests
env:
DJANGO_SETTINGS_MODULE: tests.settings
run: |
pytest --cov=django_odata --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.python-version == '3.11' && matrix.django-version == '4.2'
with:
file: ./coverage.xml
fail_ci_if_error: false

release-build:
runs-on: ubuntu-latest
needs: tests

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine

- name: Build release distributions
run: |
python -m build

- name: Check distribution
run: |
python -m twine check dist/*

- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/

pypi-publish:
runs-on: ubuntu-latest
needs:
- release-build
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

# Dedicated environments with protections for publishing are strongly recommended.
environment:
name: pypi
url: https://pypi.org/project/django-odata/${{ github.event.release.tag_name }}

steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/

- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
112 changes: 112 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# This workflow will run tests for django-odata on push and pull requests

name: Tests

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
env:
DJANGO_SETTINGS_MODULE: tests.settings
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
django-version: ["4.2", "5.0", "5.1", "5.2"]
exclude:
# Django 5.0+ requires Python 3.10+
- python-version: "3.8"
django-version: "5.0"
- python-version: "3.8"
django-version: "5.1"
- python-version: "3.8"
django-version: "5.2"
- python-version: "3.9"
django-version: "5.0"
- python-version: "3.9"
django-version: "5.1"
- python-version: "3.9"
django-version: "5.2"

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}-${{ hashFiles('**/setup.py') }}
Comment thread
dev-muhammad marked this conversation as resolved.
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install Django==${{ matrix.django-version }}
pip install -e .[dev]

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 django_odata --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 django_odata --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Format check with black
run: |
black --check django_odata tests

- name: Import sort check with isort
run: |
isort --profile black --check-only django_odata tests

- name: Run tests
env:
DJANGO_SETTINGS_MODULE: tests.settings
run: |
pytest --cov=django_odata --cov-report=xml --cov-report=term-missing

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.python-version == '3.11' && matrix.django-version == '4.2'
with:
file: ./coverage.xml
fail_ci_if_error: false

security-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]

- name: Run security audit
run: |
# Use pip-audit as a more reliable alternative to safety
pip install pip-audit
pip-audit --desc || echo "Security audit completed with findings"

- name: Run bandit security check
run: |
bandit -r django_odata -f json -o bandit-report.json || true
bandit -r django_odata
6 changes: 3 additions & 3 deletions django_odata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
__version__ = "0.1.0"
__author__ = "Your Name"

from .serializers import ODataModelSerializer, ODataSerializer
from .viewsets import ODataModelViewSet, ODataViewSet
from .mixins import ODataMixin, ODataSerializerMixin
from .serializers import ODataModelSerializer, ODataSerializer
from .utils import apply_odata_query_params, parse_odata_query
from .viewsets import ODataModelViewSet, ODataViewSet

__all__ = [
"ODataModelSerializer",
"ODataSerializer",
"ODataSerializer",
"ODataModelViewSet",
"ODataViewSet",
"ODataMixin",
Expand Down
Loading