ci: fix SECRET_KEY in workflows and settings_ci_simple.py #213
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: CI Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| jobs: | |
| test-frontend: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install frontend dependencies | |
| run: npm install --legacy-peer-deps | |
| working-directory: ./frontend | |
| - name: Build frontend project | |
| run: | | |
| export CI=false | |
| npx next build --no-lint | |
| working-directory: ./frontend | |
| - name: Build frontend Docker image | |
| run: docker build -t nextjs-app . | |
| working-directory: ./frontend | |
| test-backend: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_DB: airbcar_db | |
| POSTGRES_USER: airbcar_user | |
| POSTGRES_PASSWORD: amineamine | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| redis: | |
| image: redis:7 | |
| ports: | |
| - 6379:6379 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.8' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| working-directory: ./backend | |
| - name: Run Django migrations | |
| run: | | |
| cd backend | |
| python manage.py migrate | |
| env: | |
| SECRET_KEY: django-insecure-ci-k8m2p9x4q7w5n3h6j1v8c0z2b5a4y7t1r9e3u6i8o0p2s4d6f8g | |
| DEBUG: "True" | |
| DATABASE_NAME: airbcar_db | |
| DATABASE_USER: airbcar_user | |
| DATABASE_PASSWORD: amineamine | |
| DATABASE_HOST: localhost | |
| DATABASE_PORT: 5432 | |
| DJANGO_SETTINGS_MODULE: config.settings_ci_simple | |
| GITHUB_ACTIONS: true | |
| - name: Run Django tests | |
| run: | | |
| cd backend | |
| export DJANGO_SETTINGS_MODULE=config.settings_ci_simple | |
| python manage.py test | |
| env: | |
| SECRET_KEY: django-insecure-ci-k8m2p9x4q7w5n3h6j1v8c0z2b5a4y7t1r9e3u6i8o0p2s4d6f8g | |
| DEBUG: "True" | |
| DATABASE_NAME: airbcar_db | |
| DATABASE_USER: airbcar_user | |
| DATABASE_PASSWORD: amineamine | |
| DATABASE_HOST: localhost | |
| DATABASE_PORT: 5432 | |
| DJANGO_SETTINGS_MODULE: config.settings_ci_simple | |
| GITHUB_ACTIONS: true | |
| - name: Build backend Docker image | |
| run: docker build -t django-app . | |
| working-directory: ./backend | |
| api-tests: | |
| runs-on: ubuntu-latest | |
| needs: test-backend | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_DB: airbcar_db | |
| POSTGRES_USER: airbcar_user | |
| POSTGRES_PASSWORD: amineamine | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.8' | |
| - name: Install backend dependencies | |
| run: | | |
| cd backend | |
| pip install -r requirements.txt | |
| - name: Debug Django settings | |
| run: | | |
| cd backend | |
| echo "=== Environment Debug ===" | |
| echo "DJANGO_SETTINGS_MODULE: $DJANGO_SETTINGS_MODULE" | |
| echo "GITHUB_ACTIONS: $GITHUB_ACTIONS" | |
| echo "Current directory: $(pwd)" | |
| echo "Files in current directory:" | |
| ls -la | |
| echo "Settings files:" | |
| find . -name "*settings*" -type f | |
| echo "=== Testing Django import ===" | |
| python -c " | |
| import os | |
| print('Environment DJANGO_SETTINGS_MODULE:', os.environ.get('DJANGO_SETTINGS_MODULE')) | |
| import django | |
| django.setup() | |
| from django.conf import settings | |
| print('Successfully loaded settings:', settings.SETTINGS_MODULE) | |
| print('Database HOST:', settings.DATABASES['default']['HOST']) | |
| " | |
| env: | |
| SECRET_KEY: django-insecure-ci-k8m2p9x4q7w5n3h6j1v8c0z2b5a4y7t1r9e3u6i8o0p2s4d6f8g | |
| DEBUG: "True" | |
| DATABASE_NAME: airbcar_db | |
| DATABASE_USER: airbcar_user | |
| DATABASE_PASSWORD: amineamine | |
| DATABASE_HOST: localhost | |
| DATABASE_PORT: 5432 | |
| DJANGO_SETTINGS_MODULE: config.settings_ci_simple | |
| GITHUB_ACTIONS: true | |
| - name: Run Django migrations | |
| run: | | |
| cd backend | |
| export DJANGO_SETTINGS_MODULE=config.settings_ci_simple | |
| python manage.py migrate | |
| env: | |
| SECRET_KEY: django-insecure-ci-k8m2p9x4q7w5n3h6j1v8c0z2b5a4y7t1r9e3u6i8o0p2s4d6f8g | |
| DEBUG: "True" | |
| DATABASE_URL: postgres://airbcar_user:amineamine@localhost:5432/airbcar_db | |
| DATABASE_NAME: airbcar_db | |
| DATABASE_USER: airbcar_user | |
| DATABASE_PASSWORD: amineamine | |
| DATABASE_HOST: localhost | |
| DATABASE_PORT: 5432 | |
| DJANGO_SETTINGS_MODULE: config.settings_ci_simple | |
| GITHUB_ACTIONS: true | |
| - name: Start backend server | |
| run: | | |
| cd backend | |
| export DJANGO_SETTINGS_MODULE=config.settings_ci_simple | |
| python manage.py runserver & | |
| echo $! > backend.pid | |
| env: | |
| SECRET_KEY: django-insecure-ci-k8m2p9x4q7w5n3h6j1v8c0z2b5a4y7t1r9e3u6i8o0p2s4d6f8g | |
| DEBUG: "True" | |
| DATABASE_URL: postgres://airbcar_user:amineamine@localhost:5432/airbcar_db | |
| DATABASE_NAME: airbcar_db | |
| DATABASE_USER: airbcar_user | |
| DATABASE_PASSWORD: amineamine | |
| DATABASE_HOST: localhost | |
| DATABASE_PORT: 5432 | |
| DJANGO_SETTINGS_MODULE: config.settings_ci_simple | |
| GITHUB_ACTIONS: true | |
| - name: Wait for backend to be ready | |
| run: | | |
| timeout 60 bash -c 'until curl -f http://localhost:8000/ 2>/dev/null; do sleep 2; done' || echo "Backend health check skipped" | |
| - name: Install Newman | |
| run: npm install -g newman | |
| - name: Run Newman API tests | |
| run: newman run ./tests/airbcar-api-collection.json -e ./tests/airbcar-test-environment.json --timeout-request 10000 | |
| continue-on-error: true | |
| - name: Stop backend server | |
| run: | | |
| if [ -f backend.pid ]; then | |
| kill $(cat backend.pid) || true | |
| rm backend.pid | |
| fi | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: [test-frontend, test-backend] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.8' | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install backend dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| working-directory: ./backend | |
| - name: Install frontend dependencies | |
| working-directory: ./frontend | |
| run: npm install --legacy-peer-deps | |
| - name: Build frontend | |
| run: | | |
| export CI=false | |
| npx next build --no-lint | |
| working-directory: ./frontend | |
| - name: Build Docker images | |
| run: | | |
| docker build -t airbcar-backend ./backend | |
| docker build -t airbcar-frontend ./frontend |