Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Add step to run Django check in CI #638

Merged
merged 8 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
run: just init

- name: Run API tests
run: just api-test -T
run: just api-test

- name: Print API test logs
if: always()
Expand All @@ -160,7 +160,7 @@ jobs:

- name: Make developer docs
if: github.event_name == 'push' && github.repository == 'WordPress/openverse-api'
run: just sphinx-make -T
run: just sphinx-make

- name: Upload developer docs
if: github.event_name == 'push' && github.repository == 'WordPress/openverse-api'
Expand All @@ -169,6 +169,31 @@ jobs:
name: docs
path: api/build/html/

django-check:
name: Run Django check
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

- name: Run check
run: just dj check

check-migrations:
name: Check for uncommited Django migrations
runs-on: ubuntu-latest
Expand All @@ -192,7 +217,7 @@ jobs:
docker load --input /tmp/ingestion_server/ingestion_server.tar

- name: Run makemigrations
run: just dj -T makemigrations --check --noinput
run: just dj makemigrations --check --noinput

push:
name: Publish Docker images
Expand Down
31 changes: 18 additions & 13 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set dotenv-load := false

IS_PROD := env_var_or_default("PROD", "")
IS_CI := env_var_or_default("CI", "")

# Show all available recipes
Expand All @@ -26,10 +27,9 @@ default:
# Docker #
##########

IS_PROD := env_var_or_default("IS_PROD", "")
DOCKER_FILE := "-f " + (
if IS_PROD == "true" {"ingestion_server/docker-compose.yml"}
else {"docker-compose.yml"}
if IS_PROD == "true" { "ingestion_server/docker-compose.yml" }
else { "docker-compose.yml" }
)

# Build all (or specified) services
Expand All @@ -53,6 +53,11 @@ recreate:
logs services="" args=(if IS_CI != "" { "" } else { "-f" }):
docker-compose {{ DOCKER_FILE }} logs {{ args }} {{ services }}

EXEC_DEFAULTS := if IS_CI == "" { "" } else { "-T" }

# Execute statement in service containers using Docker Compose
exec +args:
docker-compose exec {{ EXEC_DEFAULTS }} {{ args }}

########
# Init #
Expand Down Expand Up @@ -179,8 +184,8 @@ _api-install:
exit 0

# Run API tests inside Docker
@api-test docker_args="" tests="": _api-up
docker-compose exec {{ docker_args }} web ./test/run_test.sh {{ tests }}
@api-test tests="": _api-up
just exec web ./test/run_test.sh {{ tests }}

# Run API tests locally
api-testlocal args="":
Expand All @@ -191,29 +196,29 @@ 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 }}
@dj +args="": _api-up
just exec web python manage.py {{ args }}

# Make a test cURL request to the API
stats media="images":
curl "http://localhost:8000/v1/{{ media }}/stats/"

# Attach to ipython
# Get Django shell with IPython
ipython:
docker-compose exec web ipython
just dj shell
dhruvkb marked this conversation as resolved.
Show resolved Hide resolved


##########
# Sphinx #
##########

# Compile Sphinx documentation into HTML output
sphinx-make args="" service="web": up wait-for-es wait-for-ing wait-for-web
docker-compose exec {{ args }} {{ service }} sphinx-build -M html docs/ build/
sphinx-make: up wait-for-es wait-for-ing wait-for-web
just exec web sphinx-build -M html docs/ build/

# Serve Sphinx documentation via a live-reload server
sphinx-live service="web" port="3000": up wait-for-es wait-for-ing wait-for-web
docker-compose exec {{ service }} sphinx-autobuild --host 0.0.0.0 --port {{ port }} docs/ build/html/
sphinx-live port="3000": up wait-for-es wait-for-ing wait-for-web
just exec web sphinx-autobuild --host 0.0.0.0 --port {{ port }} docs/ build/html/

# Serve the Sphinx documentation from the HTML output directory
sphinx-serve dir="api" port="3001":
Expand Down