chore: Refactor docker-compose.yml for improved service configuration… #42
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
| name: Django CI | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| jobs: | |
| lint: | |
| name: Lint Code | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install linting tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install flake8 | |
| - name: Run flake8 | |
| run: | | |
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
| # TODO: Uncomment when tests are written | |
| # test: | |
| # name: Run Tests | |
| # runs-on: ubuntu-latest | |
| # needs: lint | |
| # services: | |
| # postgres: | |
| # image: postgres:15 | |
| # env: | |
| # POSTGRES_DB: bizbuch_test | |
| # POSTGRES_USER: postgres | |
| # POSTGRES_PASSWORD: postgres | |
| # ports: | |
| # - 5432:5432 | |
| # options: >- | |
| # --health-cmd pg_isready | |
| # --health-interval 10s | |
| # --health-timeout 5s | |
| # --health-retries 5 | |
| # redis: | |
| # image: redis:7-alpine | |
| # ports: | |
| # - 6379:6379 | |
| # options: >- | |
| # --health-cmd "redis-cli ping" | |
| # --health-interval 10s | |
| # --health-timeout 5s | |
| # --health-retries 5 | |
| # env: | |
| # SECRET_KEY: test-secret-key-for-ci-only | |
| # DEBUG: "True" | |
| # ALLOWED_HOSTS: localhost,127.0.0.1 | |
| # POSTGRES_DB: bizbuch_test | |
| # POSTGRES_USER: postgres | |
| # POSTGRES_PASSWORD: postgres | |
| # DB_HOST: localhost | |
| # DB_PORT: 5432 | |
| # REDIS_HOST: localhost | |
| # REDIS_PORT: 6379 | |
| # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| # AWS_REGION: ap-south-1 | |
| # AWS_S3_BUCKET: bizbuch-media | |
| # steps: | |
| # - uses: actions/checkout@v4 | |
| # - name: Set up Python 3.10 | |
| # uses: actions/setup-python@v5 | |
| # with: | |
| # python-version: "3.10" | |
| # - name: Cache pip packages | |
| # uses: actions/cache@v4 | |
| # with: | |
| # path: ~/.cache/pip | |
| # key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| # restore-keys: | | |
| # ${{ runner.os }}-pip- | |
| # - name: Install Dependencies | |
| # run: | | |
| # python -m pip install --upgrade pip | |
| # pip install -r requirements.txt | |
| # - name: Run Migrations | |
| # run: | | |
| # python manage.py migrate --noinput | |
| # - name: Run Tests | |
| # run: | | |
| # python manage.py test --verbosity=2 | |
| build: | |
| name: Build Docker Image | |
| runs-on: ubuntu-latest | |
| needs: lint # Changed from 'test' to 'lint' since tests are commented out | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| tags: bizbuch-backend:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |