Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Question 8 of 10 · Django Deployment & DevOps
Interview question

How do you set up a CI/CD pipeline for a Django project (testing, linting, and automated deployment)? Django प्रोजेक्ट के लिए CI/CD पाइपलाइन कैसे सेट करें (टेस्टिंग, लिंटिंग और स्वचालित डिप्लॉयमेंट)?

Answer

A CI/CD pipeline (using GitHub Actions, GitLab CI, or Jenkins) automatically runs on every push or pull request, catching problems before they reach production instead of relying on manual review alone. A typical Django pipeline runs linting (flake8, black --check) and static analysis first since they're fast and catch style/syntax issues cheaply, then runs the full test suite against a real database service container, and finally checks test coverage against a minimum threshold.

On a successful merge to the main branch, the CD (continuous deployment) stage builds a new Docker image, pushes it to a registry, and triggers a deployment — often using a rolling or blue-green strategy so the new version is gradually shifted into traffic while the old version keeps serving requests until the new one is confirmed healthy, minimizing risk if the new deploy has a bug.

jobs:
  test:
    services:
      postgres:
        image: postgres:16
    steps:
      - run: pip install -r requirements.txt
      - run: flake8 .
      - run: python manage.py test
      - run: coverage run manage.py test && coverage report --fail-under=80

CI/CD पाइपलाइन (GitHub Actions, GitLab CI, या Jenkins का उपयोग करके) हर push या pull request पर स्वचालित रूप से चलता है, समस्याओं को प्रोडक्शन तक पहुँचने से पहले पकड़ता है।

मुख्य ब्रांच में सफल मर्ज होने पर, CD चरण एक नई Docker इमेज बनाता है, इसे रजिस्ट्री में पुश करता है, और एक डिप्लॉयमेंट ट्रिगर करता है — अक्सर रोलिंग या ब्लू-ग्रीन रणनीति का उपयोग करके।

jobs:
  test:
    services:
      postgres:
        image: postgres:16
    steps:
      - run: pip install -r requirements.txt
      - run: flake8 .
      - run: python manage.py test

Was this answer clear?