diff --git a/.github/workflows/example-test.yml b/.github/workflows/example-test.yml index 15fd567..3ecbc68 100644 --- a/.github/workflows/example-test.yml +++ b/.github/workflows/example-test.yml @@ -6,6 +6,13 @@ name: Example test on: push: branches: [ "main" ] + pull_request: + branches: [ "main" ] + +defaults: + run: + shell: bash + working-directory: ./example jobs: build: @@ -14,18 +21,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11"] - - services: - postgres: - image: postgres - env: - POSTGRES_PASSWORD: postgres - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 @@ -37,16 +33,23 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install -r example/requirements.txt - python -m pip install . + python -m pip install -r requirements.txt + python -m pip install .. - name: Migrate database run: | - cd example + ./manage.py migrateci -v3 --parallel $(nproc) + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} + - name: Migrate database again to reuse cache + run: | ./manage.py migrateci -v3 --parallel $(nproc) env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} - name: Test with Django run: | - cd example ./manage.py test --keepdb + - name: Test with pytest-django + run: | + pytest --migrateci --reuse-db -n $(nproc) diff --git a/example/example/settings.py b/example/example/settings.py index 0788a5d..eea00f1 100644 --- a/example/example/settings.py +++ b/example/example/settings.py @@ -1,3 +1,4 @@ +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / "subdir". @@ -31,4 +32,6 @@ AWS_STORAGE_BUCKET_NAME = "example-migrateci-cache" AWS_S3_REGION_NAME = "us-east-2" -MIGRATECI_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" +# Use S3 only if github action provided secrets for that. +if os.getenv("AWS_ACCESS_KEY_ID"): + MIGRATECI_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" diff --git a/example/requirements.txt b/example/requirements.txt index 84fcd1b..0f15202 100644 --- a/example/requirements.txt +++ b/example/requirements.txt @@ -1,2 +1,6 @@ django django-storages[boto3] +pytest +pytest-cov +pytest-django +pytest-xdist