Repository navigation
ci cd setup #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
ci cd setup #1
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7af704b
ci cd setup
dev-muhammad c957692
reformatted with black
dev-muhammad ceee157
isort fixed
dev-muhammad cbae42e
flake8 aligned
dev-muhammad e11ac18
linter fix
dev-muhammad de252bc
security check fix
dev-muhammad 99660db
build fix
dev-muhammad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') }} | ||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.