Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Add CI check for uncommitted migrations (#580)

sarayourfriendc995823eb079
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index 15a1a8cc3..671c21de7 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -141,6 +141,32 @@ jobs:
name: docs
path: api/build/html/
+ check-migrations:
+ name: Check for uncommited Django migrations
+ runs-on: ubuntu-latest
+ needs:
+ - build-images
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ - name: Setup just
+ uses: extractions/setup-just@v1
+
+ - name: Download all images
+ uses: actions/download-artifact@v2
+ with:
+ path: /tmp
+
+ - name: Load all images
+ run: |
+ docker load --input /tmp/api/api.tar
+ docker load --input /tmp/ingestion_server/ingestion_server.tar
+ docker load --input /tmp/analytics/analytics.tar
+
+ - name: Run makemigrations
+ run: just dj -T makemigrations --check --noinput
+
push:
name: Publish Docker images
runs-on: ubuntu-latest
diff --git a/justfile b/justfile
index 7a89759e7..b9953584b 100644
--- a/justfile
+++ b/justfile
@@ -164,18 +164,25 @@ _api-install:
'"$(just web-health)" != "200"' \
"Waiting for the API to be healthy..."
+@_api-up: up wait-for-es wait-for-ing wait-for-web
+ exit 0
+
# Run API tests inside Docker
-api-test docker_args="" tests="": up wait-for-es wait-for-ing wait-for-web
- docker-compose exec {{ docker_args }} web ./test/run_test.sh {{ tests }}
+@api-test docker_args="" tests="": _api-up
+ docker-compose exec {{ docker_args }} ./test/run_test.sh {{ tests }}
# Run API tests locally
api-testlocal args="":
cd api && pipenv run ./test/run_test.sh {{ args }}
-# Run Django administrative commands
-dj args="":
+# Run Django administrative commands locally
+dj-local +args:
cd api && pipenv run python manage.py {{ args }}
+# Run Django administrative commands in the docker container
+@dj docker_args="" +args="": _api-up
+ docker-compose exec {{ docker_args }} web python manage.py {{ args }}
+
# Make a test cURL request to the API
stats media="images":
curl "http://localhost:8000/v1/{{ media }}/stats/"