From f2b186703fb8a682eeea3bd83376598040d151cd Mon Sep 17 00:00:00 2001 From: MEHRSHAD MIRSHEKARY Date: Fri, 8 Nov 2024 15:25:27 +0330 Subject: [PATCH 1/3] ci(dependabot): add Dependabot configuration for automated dependency updates - Added `.github/dependabot.yaml` to enable automated dependency updates - Configured Dependabot to check `pip` dependencies in `/packages` - Scheduled weekly updates targeting the `main` branch for consistent maintenance --- .github/dependabot.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d4493e0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/packages" # Location of the requirements.txt and requirements-dev.txt file + schedule: + interval: "weekly" + + target-branch: "main" From 8899065be5e23d83570918fa45b2b6085ab3f7a6 Mon Sep 17 00:00:00 2001 From: MEHRSHAD MIRSHEKARY Date: Fri, 8 Nov 2024 15:30:10 +0330 Subject: [PATCH 2/3] ci(tests): Add CI workflow for testing Python & Django versions & coverage - Introduced a GitHub Actions CI workflow to automate testing across multiple Python versions (3.9, 3.10, 3.11, 3.12, 3.13). - The workflow includes the following steps: - Checkout the code repository. - Set up the specified Python version. - Install dependencies including coverage, codecov, pytest, and poetry. - Run tests with coverage reporting. - Execute Tox tests for additional environment checks. - Run pre-commit hooks to ensure code quality. - Upload coverage reports to Codecov. This CI setup helps ensure code quality and compatibility across different Python versions. --- .github/workflows/ci.yml | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..758dc80 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI + +on: [push, pull_request] + +jobs: + test: + name: Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: + - '3.9' + - '3.10' + - '3.11' + - '3.12' + - '3.13' + + 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 coverage codecov pytest poetry + pip install -r packages/requirements-dev.txt + + - name: Run tests with coverage + run: pytest --cov=data_generator --cov-report=xml + + - name: Run Tox tests + run: tox + + - name: Run pre-commit hooks + run: pre-commit run --all-files --config=.pre-commit-config-ci.yaml + + - name: Upload coverage to Codecov + run: codecov + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 0e8777ea0943bc7453d3649712a366995de5f77e Mon Sep 17 00:00:00 2001 From: MEHRSHAD MIRSHEKARY Date: Fri, 8 Nov 2024 15:31:52 +0330 Subject: [PATCH 3/3] ci(release): Add release workflow for automated package publishing to PyPI - Introduced a GitHub Actions workflow for automated releases triggered by version tag pushes (e.g., 'v*.*.*'). - The workflow includes the following steps: - Checkout the code repository. - Set up Python environment using the latest version of Python 3. - Install dependencies, including Poetry for package management. - Build the package using Poetry. - Publish the built package to PyPI using a secure token for authentication. This setup streamlines the release process, ensuring that new versions are automatically built and published upon tagging. Closes #3 --- .github/workflows/release.yml | 35 +++++++++++++++++++ .pre-commit-config-ci.yaml | 2 +- .../management/commands/generate_data.py | 6 ++-- 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5bbb84c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + +jobs: + release: + name: Build and Release + runs-on: ubuntu-latest + + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install poetry + + - name: Build package + run: | + poetry build + + - name: Publish to PyPI + run: | + poetry publish --username __token__ --password ${{ secrets.PYPI_TOKEN }} + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} diff --git a/.pre-commit-config-ci.yaml b/.pre-commit-config-ci.yaml index 50124d2..a466996 100644 --- a/.pre-commit-config-ci.yaml +++ b/.pre-commit-config-ci.yaml @@ -19,7 +19,7 @@ repos: exclude: (migrations/|tests/|docs/).* - repo: https://github.com/tox-dev/pyproject-fmt - rev: 2.5.0 + rev: v2.5.0 hooks: - id: pyproject-fmt diff --git a/data_generator/management/commands/generate_data.py b/data_generator/management/commands/generate_data.py index 542f856..b3f38c7 100644 --- a/data_generator/management/commands/generate_data.py +++ b/data_generator/management/commands/generate_data.py @@ -1,6 +1,6 @@ import sys from random import choice -from typing import Any, Dict, List, Optional, TextIO, Union +from typing import Any, Dict, List, Optional, TextIO from django.apps import apps from django.core.management.base import BaseCommand @@ -24,8 +24,8 @@ class Command(BaseCommand): def __init__( self, - stdout: TextIO | None = None, - stderr: TextIO | None = None, + stdout: Optional[TextIO] = None, + stderr: Optional[TextIO] = None, no_color: bool = False, force_color: bool = False, ):