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 26d1a2f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
35 changes: 19 additions & 16 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,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 --reusedb --parallel $(nproc)
5 changes: 4 additions & 1 deletion 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 @@ -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"

0 comments on commit 26d1a2f

Please sign in to comment.