From d311bf35b341025dc7d19e37a70886e2f9aca034 Mon Sep 17 00:00:00 2001 From: dev-muhammad Date: Mon, 17 Nov 2025 13:44:11 +0500 Subject: [PATCH 1/2] FIX: publish pipeline fixed --- .github/workflows/publish-to-pypi.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 045115f..4786772 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -13,8 +13,6 @@ permissions: 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"] @@ -49,8 +47,6 @@ jobs: pip install -e .[dev] - name: Run tests - env: - DJANGO_SETTINGS_MODULE: tests.settings run: | pytest --cov=django_odata --cov-report=xml From eaef691108665859d2724309929c62465bc0b37d Mon Sep 17 00:00:00 2001 From: dev-muhammad Date: Mon, 17 Nov 2025 13:51:31 +0500 Subject: [PATCH 2/2] pipelines improvement --- .github/workflows/ci-tests.yml | 53 ++++++++++++ .github/workflows/pr-quality.yml | 52 +++++++++++ .github/workflows/pr-tests.yml | 11 +++ .github/workflows/publish-to-pypi.yml | 45 +--------- .github/workflows/test.yml | 120 -------------------------- 5 files changed, 117 insertions(+), 164 deletions(-) create mode 100644 .github/workflows/ci-tests.yml create mode 100644 .github/workflows/pr-quality.yml create mode 100644 .github/workflows/pr-tests.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml new file mode 100644 index 0000000..14844ef --- /dev/null +++ b/.github/workflows/ci-tests.yml @@ -0,0 +1,53 @@ +name: CI Tests + +on: + workflow_call: + +jobs: + tests: + runs-on: ubuntu-latest + 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 + 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 + + diff --git a/.github/workflows/pr-quality.yml b/.github/workflows/pr-quality.yml new file mode 100644 index 0000000..16e5c2f --- /dev/null +++ b/.github/workflows/pr-quality.yml @@ -0,0 +1,52 @@ +name: Pull Request Quality + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + quality: + 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] + pip install Django==5.2 + + - name: Lint with flake8 + run: | + flake8 django_odata --count --select=E9,F63,F7,F82 --show-source --statistics + 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: Check Django setup and run migrations + run: | + python -m django check --settings=tests.integration.support.settings + python -m django showmigrations --settings=tests.integration.support.settings + + - name: Run security audit (pip-audit) + run: | + 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 + + diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml new file mode 100644 index 0000000..5246171 --- /dev/null +++ b/.github/workflows/pr-tests.yml @@ -0,0 +1,11 @@ +name: Pull Request CI + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + tests: + uses: ./.github/workflows/ci-tests.yml + + diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 4786772..627219f 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -12,50 +12,7 @@ permissions: jobs: tests: - runs-on: ubuntu-latest - 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 - 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 + uses: ./.github/workflows/ci-tests.yml release-build: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index e0d2dff..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,120 +0,0 @@ -# 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.integration.support.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') }} - 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: Check Django setup and run migrations - env: - DJANGO_SETTINGS_MODULE: tests.integration.support.settings - run: | - # Verify Django can detect our test apps and migrations - python -m django check --settings=tests.integration.support.settings - python -m django showmigrations --settings=tests.integration.support.settings - - - name: Run tests - env: - DJANGO_SETTINGS_MODULE: tests.integration.support.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