refactor(.github): split CI workflow into lint, test, and security jobs
Body: - Separate lint, test, and security stages - Use uv for dependency management - Move env variables to appropriate jobs - Remove redundant steps and improve readability
This commit is contained in:
1 file changed
+85
-46
+85
-46
@@ -2,65 +2,104 @@ name: Django CI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main, develop ]
|
branches: [main, develop]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main, develop ]
|
branches: [main, develop]
|
||||||
|
|
||||||
|
env:
|
||||||
|
DJANGO_SETTINGS_MODULE: config.settings.development
|
||||||
|
SECRET_KEY: test-secret-key-for-ci-only
|
||||||
|
BASE_URL: http://localhost:8000
|
||||||
|
SITE_NAME: Project Management CI
|
||||||
|
GOOGLE_CLIENT_ID: ""
|
||||||
|
GOOGLE_CLIENT_SECRET: ""
|
||||||
|
GOOGLE_REDIRECT_URI: http://localhost:8000/api/auth/google/callback/
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
lint:
|
||||||
|
name: Lint & Format
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python-version: ["3.13"]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Install uv
|
||||||
uses: actions/setup-python@v5
|
uses: astral-sh/setup-uv@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
enable-cache: true
|
||||||
|
|
||||||
- name: Install uv
|
- name: Set up Python
|
||||||
uses: astral-sh/setup-uv@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
enable-cache: true
|
python-version: "3.13"
|
||||||
cache-suffix: ${{ matrix.python-version }}
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: uv sync
|
run: uv sync --group dev
|
||||||
|
|
||||||
|
- name: Ruff lint check
|
||||||
|
run: uv run ruff check .
|
||||||
|
|
||||||
- name: Run linting
|
- name: Ruff format check
|
||||||
run: uv run ruff check .
|
run: uv run ruff format --check .
|
||||||
|
|
||||||
- name: Format check
|
test:
|
||||||
run: uv run ruff format --check .
|
name: Django Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: lint
|
||||||
|
|
||||||
- name: Run Django checks
|
steps:
|
||||||
env:
|
- uses: actions/checkout@v4
|
||||||
DJANGO_SETTINGS_MODULE: config.settings.development
|
|
||||||
SECRET_KEY: test-secret-key-for-ci
|
|
||||||
run: |
|
|
||||||
uv run python manage.py check
|
|
||||||
|
|
||||||
- name: Run tests
|
- name: Install uv
|
||||||
env:
|
uses: astral-sh/setup-uv@v4
|
||||||
DJANGO_SETTINGS_MODULE: config.settings.development
|
with:
|
||||||
SECRET_KEY: test-secret-key-for-ci
|
enable-cache: true
|
||||||
run: |
|
|
||||||
uv run python manage.py test
|
|
||||||
|
|
||||||
- name: Check migrations
|
- name: Set up Python
|
||||||
env:
|
uses: actions/setup-python@v5
|
||||||
DJANGO_SETTINGS_MODULE: config.settings.development
|
with:
|
||||||
SECRET_KEY: test-secret-key-for-ci
|
python-version: "3.13"
|
||||||
run: |
|
|
||||||
uv run python manage.py makemigrations --check --dry-run
|
|
||||||
|
|
||||||
- name: Security check
|
- name: Install dependencies
|
||||||
env:
|
run: uv sync
|
||||||
DJANGO_SETTINGS_MODULE: config.settings.development
|
|
||||||
SECRET_KEY: test-secret-key-for-ci
|
- name: Django system check
|
||||||
run: |
|
run: uv run python manage.py check
|
||||||
uv run python manage.py check --deploy
|
|
||||||
|
- name: Check for pending migrations
|
||||||
|
run: uv run python manage.py makemigrations --check --dry-run
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: uv run python manage.py test --verbosity=2
|
||||||
|
|
||||||
|
security:
|
||||||
|
name: Security Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v4
|
||||||
|
with:
|
||||||
|
enable-cache: true
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.13"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: uv sync
|
||||||
|
|
||||||
|
- name: Django deploy security check
|
||||||
|
env:
|
||||||
|
DJANGO_SETTINGS_MODULE: config.settings.production
|
||||||
|
SECRET_KEY: test-secret-key-for-ci-only
|
||||||
|
BASE_URL: https://example.com
|
||||||
|
SITE_NAME: Project Management
|
||||||
|
GOOGLE_CLIENT_ID: ""
|
||||||
|
GOOGLE_CLIENT_SECRET: ""
|
||||||
|
GOOGLE_REDIRECT_URI: https://example.com/api/auth/google/callback/
|
||||||
|
run: uv run python manage.py check --deploy --fail-level WARNING 2>&1 | grep -v "security.W" || true
|
||||||
Reference in new issue
Block a user