Skip to content

Commit

Permalink
build: Use memcached (#318)
Browse files Browse the repository at this point in the history
* build: Use memcached

Fixes #284

* ci: Add `--no-input` test commands

* ci: Add memcached to test workflow
  • Loading branch information
kesara authored Aug 14, 2023
1 parent 23dbd19 commit c1b4895
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ jobs:
- name: Start database
run: docker run --name=database -e POSTGRES_DB=app -e POSTGRES_PASSWORD=password -d postgres:14.6

- name: Start memcached
run: docker run --name=memcached -d memcached:latest

- name: Run tests
run: docker run -i --rm --name=app-test -u root --link=database -e DATABASE_URL="postgres://postgres:password@database/app" -e APP_SECRET_KEY=xxxx -e ENVIRONMENT=test app-test
run: docker run -i --rm --name=app-test -u root --link=database --link=memcached -e DATABASE_URL="postgres://postgres:password@database/app" -e APP_SECRET_KEY=xxxx -e ENVIRONMENT=test app-test
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
- docker/dev.env
depends_on:
- database
- memcached

frontend:
restart: on-failure
Expand All @@ -34,3 +35,7 @@ services:
POSTGRES_DB: "app"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "password"

memcached:
image: memcached:latest
hostname: memcached
4 changes: 2 additions & 2 deletions docker/init-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

python /app/manage.py migrate --no-input
python /app/manage.py createcachetable
python /app/manage.py collectstatic
python /app/manage.py test
python /app/manage.py collectstatic --no-input
python /app/manage.py test --no-input
python /app/manage.py makemigrations --check --dry-run --no-input
10 changes: 7 additions & 3 deletions ietf/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,12 @@

CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.db.DatabaseCache",
"LOCATION": "cache_table",
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
"LOCATION": "memcached:11211",
},
"sessions": {
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
"LOCATION": "memcached:11211",
},
"dummy": {"BACKEND": "django.core.cache.backends.dummy.DummyCache"},
}
Expand Down Expand Up @@ -244,4 +248,4 @@
"home.IABHomePage",
]

NOTE_WELL_REPO = "https://raw.githubusercontent.com/ietf/note-well/main/note-well.md"
NOTE_WELL_REPO = "https://raw.githubusercontent.com/ietf/note-well/main/note-well.md"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tqdm>=3.7.0
wagtail-markdown
Pygments
wagtail-orderable
pymemcache

# env var configuration
typed-environment-configuration>=0.1.3,<0.2
Expand Down

0 comments on commit c1b4895

Please sign in to comment.