Run unit tests in CI

This commit is contained in:
Gabriel Augendre 2020-08-18 08:08:07 +02:00
parent 1af6e7cab6
commit 84b9788a55
2 changed files with 19 additions and 1 deletions

View file

@ -1,13 +1,23 @@
image: archlinux image: archlinux
packages: packages:
- docker - docker
- python-pip
- python-virtualenv
sources: sources:
- https://git.sr.ht/~crocmagnon/blog - https://git.sr.ht/~crocmagnon/blog
secrets: secrets:
- 2da6ddc6-3d12-4306-a1e4-8268c6194386 - 2da6ddc6-3d12-4306-a1e4-8268c6194386
- 29bc352f-0807-46e9-a4ef-2f869f94afa3 - 29bc352f-0807-46e9-a4ef-2f869f94afa3
- 5c948915-48c2-4542-8fc1-a5676f4d7126 - 5c948915-48c2-4542-8fc1-a5676f4d7126
environment:
TESTING: true
tasks: tasks:
- test: |
python --version
cd blog
virtualenv venv
venv/bin/python -m pip install -r requirements.txt -r requirements-dev.txt --progress-bar off
venv/bin/python -m pytest
- setup_docker: | - setup_docker: |
chmod +x ./blog/docker/setup-docker chmod +x ./blog/docker/setup-docker
./blog/docker/setup-docker ./blog/docker/setup-docker

View file

@ -26,6 +26,7 @@ SECRET_KEY = os.getenv(
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv("DEBUG", "true").lower() == "true" DEBUG = os.getenv("DEBUG", "true").lower() == "true"
TESTING = os.getenv("TESTING", "true").lower() == "true"
ALLOWED_HOSTS = [ ALLOWED_HOSTS = [
"localhost", "localhost",
@ -130,7 +131,14 @@ USE_TZ = True
STATIC_URL = "/static/" STATIC_URL = "/static/"
STATIC_ROOT = BASE_DIR / "static" STATIC_ROOT = BASE_DIR / "static"
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" if TESTING:
# ManifestStaticFilesStorage requires collectstatic to be run
# and collectstatic is not run for tests
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"
else:
STATICFILES_STORAGE = (
"django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
)
AUTH_USER_MODEL = "articles.User" AUTH_USER_MODEL = "articles.User"