-
Notifications
You must be signed in to change notification settings - Fork 50
Add step to run Django check in CI #638
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
@AetherUnbound would it be more preferable to club this check with the check for uncommitted migrations instead of with the API tests, considering that it's another Django command and not a proper test suite? |
That makes sense to me! Also, sorry for so much back and forth 😅 I wonder if we could further simplify this: git diff
diff --git a/justfile b/justfile
index 6e4343e9..f94e6877 100644
--- a/justfile
+++ b/justfile
@@ -31,6 +31,7 @@ DOCKER_FILE := "-f " + (
if IS_PROD == "true" {"ingestion_server/docker-compose.yml"}
else {"docker-compose.yml"}
)
+EXEC_DEFAULTS := if IS_CI == "" { "" } else { "-T" }
# Build all (or specified) services
build *args:
@@ -179,11 +180,11 @@ _api-install:
exit 0
# Run API tests inside Docker
-@api-test docker_args=(if IS_CI != "" { "-T" } else { "" }) tests="": _api-up
+@api-test docker_args=EXEC_DEFAULTS tests="": _api-up
docker-compose exec {{ docker_args }} web ./test/run_test.sh {{ tests }}
# Run Django check command inside Docker
-@api-check docker_args=(if IS_CI != "" { "-T" } else { "" }): _api-up
+@api-check docker_args=EXEC_DEFAULTS: _api-up
just dj "{{ docker_args }}" check
# Run API tests locally
@@ -195,7 +196,7 @@ dj-local +args:
cd api && pipenv run python manage.py {{ args }}
# Run Django administrative commands in the docker container
-@dj docker_args=(if IS_CI != "" { "-T" } else { "" }) +args="": _api-up
+@dj docker_args=EXEC_DEFAULTS +args="": _api-up
docker-compose exec {{ docker_args }} web python manage.py {{ args }}
# Make a test cURL request to the API
@@ -212,7 +213,7 @@ ipython:
##########
# Compile Sphinx documentation into HTML output
-sphinx-make args=(if IS_CI != "" { "-T" } else { "" }) service="web": up wait-for-es wait-for-ing wait-for-web
+sphinx-make args=EXEC_DEFAULTS service="web": up wait-for-es wait-for-ing wait-for-web
docker-compose exec {{ args }} {{ service }} sphinx-build -M html docs/ build/
# Serve Sphinx documentation via a live-reload server Example: $ just --dry-run api-test
docker-compose -f docker-compose.yml up -d
just _loop '"$(just es-health localhost:9200)" != "200"' "Waiting for Elasticsearch to be healthy..."
just _loop '"$(just ing-health localhost:8001)" != "200"' "Waiting for the ingestion-server to be healthy..."
just _loop '"$(just web-health)" != "200"' "Waiting for the API to be healthy..."
exit 0
docker-compose exec web ./test/run_test.sh
$ CI="true" just --dry-run api-test
docker-compose -f docker-compose.yml up -d
just _loop '"$(just es-health localhost:9200)" != "200"' "Waiting for Elasticsearch to be healthy..."
just _loop '"$(just ing-health localhost:8001)" != "200"' "Waiting for the ingestion-server to be healthy..."
just _loop '"$(just web-health)" != "200"' "Waiting for the API to be healthy..."
exit 0
docker-compose exec -T web ./test/run_test.sh |
I was actually going to mention something along these lines... it'd be nice to actually just have it as a separate job altogether, just like the uncommitted migrations. That way we get clear and individual failures in the CI output on the PR summary view. |
Having each check be a separate job is great, but what bugs me is that it has to download all images and orchestrate the entire infra up just to run a single command. There's gotta be a faster way to do this. I'm still going to make it a separate job, but trying to speed up CI is something to think about. |
pipenv install should be cached between runs though, which the docker build never is. Theoretically that would be faster long run. |
Hmm, makes sense. I wonder if we could cache the entire |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love these changes - lots more reusability!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Really appreciative of the clean up in the justfile 🎉
Fixes
Fixes #631 by @dhruvkb
Description
This PR adds step to run Django check in CI.
Testing Instructions
View the CI logs to see that Django checks have been run successfully.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin