Skip to content

Commit

Permalink
Run example without S3 when there is no secrets on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
iurisilvio committed Feb 7, 2024
1 parent bc19219 commit a6775de
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
41 changes: 19 additions & 22 deletions .github/workflows/example-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ name: Example test
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

defaults:
run:
shell: bash
working-directory: ./example

jobs:
build:
Expand All @@ -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
Expand All @@ -37,16 +33,17 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r example/requirements.txt
python -m pip install .
- name: Migrate database
python -m pip install -r requirements.txt
python -m pip install ..
- name: Django migrate
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 }}
./manage.py migrateci -v3 --parallel 2
- name: Django migrate again to reuse cache
run: |
./manage.py migrateci -v3 --parallel 2
- name: Test with Django
run: |
cd example
./manage.py test --keepdb
./manage.py test -v3 --keepdb
- name: Test with pytest-django
run: |
pytest -vvv --migrateci --reuse-db -n 2
8 changes: 1 addition & 7 deletions example/example/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / "subdir".
Expand Down Expand Up @@ -25,10 +26,3 @@
},
}
}

# AWS credentials (AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY) are defined
# in .github/workflows/example-test.yml as environment variables.
AWS_STORAGE_BUCKET_NAME = "example-migrateci-cache"
AWS_S3_REGION_NAME = "us-east-2"

MIGRATECI_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
3 changes: 3 additions & 0 deletions example/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
DJANGO_SETTINGS_MODULE=example.settings
python_files = tests.py
5 changes: 4 additions & 1 deletion example/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
django
django-storages[boto3]
django-storages
pytest
pytest-django<4.7
pytest-xdist

0 comments on commit a6775de

Please sign in to comment.