From c993657cb7caffbfeded41209bfd1aefcfeb2455 Mon Sep 17 00:00:00 2001 From: ngovinh2k2 Date: Tue, 23 Dec 2025 16:46:09 +0700 Subject: [PATCH 1/2] feat: implement pull request template --- .github/pull_request_template.md | 26 ++++++++++++++++++++++++++ .github/workflows/ci-dev.yml | 28 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/ci-dev.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..2ae0a23 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,26 @@ +## What? +Explain the changes you've made +## Why? +The “why” tells us what business or engineering goal this change achieves +## How? + +## Testing? +[ ] Functional Testing + +[ ] Security + +[ ] Performance + +[ ] Error Handling + +[ ] Code Quality + +[ ] Documentation + +[ ] Database + +[ ] Deployment + +[ ] Final Review + +## Anything Else? diff --git a/.github/workflows/ci-dev.yml b/.github/workflows/ci-dev.yml new file mode 100644 index 0000000..1c0fd5a --- /dev/null +++ b/.github/workflows/ci-dev.yml @@ -0,0 +1,28 @@ +name: CI + +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install flake8==4.0.1 + pip install bandit==1.7.8 + - name: Run Flake8 + run: | + flake8 + - name: Run Bandit + run: | + bandit -r . From d5629f96c5c10d0d24bdc013fb87147f918e960b Mon Sep 17 00:00:00 2001 From: ngovinh2k2 Date: Tue, 23 Dec 2025 16:51:24 +0700 Subject: [PATCH 2/2] feat: add pre-commit file --- .pre-commit-config.yaml | 21 +++++++++++++++++++ .../management/commands/init_organization.py | 10 +++------ 2 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..32598d0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +repos: + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + name: isort (python) + - repo: https://github.com/psf/black + rev: 23.1.0 + hooks: + - id: black + language_version: python3.10 + - repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + - repo: https://github.com/PyCQA/bandit + rev: 1.7.8 + hooks: + - id: bandit + args: ["-r", ".", "-x", "**/venv/*"] + pass_filenames: false diff --git a/bootstrap_service/management/commands/init_organization.py b/bootstrap_service/management/commands/init_organization.py index 189b2dd..18b3cf2 100644 --- a/bootstrap_service/management/commands/init_organization.py +++ b/bootstrap_service/management/commands/init_organization.py @@ -34,9 +34,7 @@ def handle(self, *args, **kwargs): # noqa: C901 org_name = kwargs.get("org_name") or os.getenv("ORG_NAME") org_slug = kwargs.get("org_slug") or os.getenv("ORG_SLUG") owner_email = kwargs.get("owner_email") or os.getenv("OWNER_EMAIL") - owner_password = kwargs.get("owner_password") or os.getenv( - "OWNER_PASSWORD" - ) + owner_password = kwargs.get("owner_password") or os.getenv("OWNER_PASSWORD") org_id = str(uuid.uuid4()) self.stdout.write( @@ -57,9 +55,7 @@ def handle(self, *args, **kwargs): # noqa: C901 result = existing else: self.stdout.write( - self.style.SUCCESS( - f"Provisioning organization '{org_slug}'..." - ) + self.style.SUCCESS(f"Provisioning organization '{org_slug}'...") ) result = provisioner.provision_tenant(org_id, org_slug, 1112) @@ -89,7 +85,7 @@ def handle(self, *args, **kwargs): # noqa: C901 celery_app = import_string(settings.CELERY_APP) encrypted_password = make_password(owner_password) - + celery_app.send_task( name="spacedf.tasks.new_organization", exchange=Exchange("new_organization", type="fanout"),