From 78ad6a724e4086dee88e94aabfcac26775789889 Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Fri, 15 Apr 2022 13:15:37 +0400 Subject: [PATCH 1/8] Add spaces inside `{` - `}` --- justfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index fc1f584d7..3e3f953bc 100644 --- a/justfile +++ b/justfile @@ -28,8 +28,8 @@ default: 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 From 434e948db99edef58d2dd11b0a99e890f1ac82f2 Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Fri, 15 Apr 2022 13:16:09 +0400 Subject: [PATCH 2/8] Create an exec recipe that automatically uses `-T` --- justfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/justfile b/justfile index 3e3f953bc..00fc4ff22 100644 --- a/justfile +++ b/justfile @@ -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 # From 4378fbdce74a4f68d3b539e2b402ff655d2004f8 Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Fri, 15 Apr 2022 13:17:01 +0400 Subject: [PATCH 3/8] Replace `docker-compose exec` with `exec` recipe --- justfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/justfile b/justfile index 00fc4ff22..603f97e5d 100644 --- a/justfile +++ b/justfile @@ -184,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="": @@ -196,8 +196,8 @@ 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": @@ -213,12 +213,12 @@ ipython: ########## # 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 service="web": up wait-for-es wait-for-ing wait-for-web + just exec {{ service }} 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/ + just exec {{ service }} 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": From 252c20ae87d7717f3231fde907d8004266a451df Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Fri, 15 Apr 2022 13:17:29 +0400 Subject: [PATCH 4/8] Replace IPython with Django shell --- justfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index 603f97e5d..897f544fd 100644 --- a/justfile +++ b/justfile @@ -203,9 +203,9 @@ dj-local +args: 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 ########## From dd37f55524f06f02c68ddceaaea15de01b305cd9 Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Fri, 15 Apr 2022 13:18:16 +0400 Subject: [PATCH 5/8] Remove redundant `-T` --- .github/workflows/ci_cd.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 6f5564d47..fe4e43abf 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -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() @@ -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' @@ -192,7 +192,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 From 5bfc256742bcc787aa46fef91e89557ae6ac2688 Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Fri, 15 Apr 2022 13:19:18 +0400 Subject: [PATCH 6/8] Add a "Django check" check --- .github/workflows/ci_cd.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index fe4e43abf..e2b862c4e 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -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 From a8f3ca555926aef8032d6ece6a7a8aacfdb33045 Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Fri, 15 Apr 2022 13:23:28 +0400 Subject: [PATCH 7/8] Remove redundant argument since only `web` has Sphinx --- justfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/justfile b/justfile index 897f544fd..2cab9bdc0 100644 --- a/justfile +++ b/justfile @@ -213,12 +213,12 @@ ipython: ########## # Compile Sphinx documentation into HTML output -sphinx-make service="web": up wait-for-es wait-for-ing wait-for-web - just exec {{ 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 - just 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": From bc124df619b6047d56608f0c8dddb2028955953a Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Fri, 15 Apr 2022 19:02:08 +0400 Subject: [PATCH 8/8] Change env var `IS_PROD` to `PROD` --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index 2cab9bdc0..aaf39c134 100644 --- a/justfile +++ b/justfile @@ -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 @@ -26,7 +27,6 @@ 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" }