Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨(lti) add base Django app service #30

Merged
merged 8 commits into from
Jul 18, 2023
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
129 changes: 124 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
- checkout
- restore_cache:
keys:
- v1-dependencies-<< parameters.python-image >>-{{ .Revision }}
- v1-backend-dependencies-<< parameters.python-image >>-{{ .Revision }}
- run:
name: Install development dependencies
command: |
Expand All @@ -149,7 +149,7 @@ jobs:
- save_cache:
paths:
- ~/.local
key: v1-dependencies-<< parameters.python-image >>-{{ .Revision }}
key: v1-backend-dependencies-<< parameters.python-image >>-{{ .Revision }}

lint-backend:
docker:
Expand All @@ -162,7 +162,7 @@ jobs:
- checkout
- restore_cache:
keys:
- v1-dependencies-python:3.11-{{ .Revision }}
- v1-backend-dependencies-python:3.11-{{ .Revision }}
- run:
name: Lint code with black
command: ~/.local/bin/black --check --config core/pyproject.toml core plugins
Expand All @@ -189,12 +189,104 @@ jobs:
- checkout
- restore_cache:
keys:
- v1-dependencies-<< parameters.python-image >>-{{ .Revision }}
- v1-backend-dependencies-<< parameters.python-image >>-{{ .Revision }}
- run:
name: Run tests
command: ~/.local/bin/pytest -c core/pyproject.toml
working_directory: src/backend

# ---- App jobs ----
# Build app development environment

build-app:
parameters:
python-image:
type: string
docker:
- image: cimg/<< parameters.python-image >>
auth:
username: $DOCKER_HUB_USER
password: $DOCKER_HUB_PASSWORD
working_directory: ~/fun
steps:
- checkout
- restore_cache:
keys:
- v1-app-dependencies-<< parameters.python-image >>-{{ .Revision }}
- run:
name: Install development dependencies
command: pip install --user .[dev];
working_directory: src/app
- save_cache:
paths:
- ~/.local
key: v1-app-dependencies-<< parameters.python-image >>-{{ .Revision }}

lint-app:
docker:
- image: cimg/python:3.11
auth:
username: $DOCKER_HUB_USER
password: $DOCKER_HUB_PASSWORD
working_directory: ~/fun
steps:
- checkout
- restore_cache:
keys:
- v1-app-dependencies-python:3.11-{{ .Revision }}
- run:
name: Lint code with black
command: ~/.local/bin/black --check --config ./pyproject.toml apps warren manage.py
working_directory: src/app
- run:
name: Lint code with ruff
command: ~/.local/bin/ruff --config ./pyproject.toml apps warren manage.py
working_directory: src/app

test-app:
parameters:
python-image:
type: string
docker:
- image: cimg/<< parameters.python-image >>
auth:
username: $DOCKER_HUB_USER
password: $DOCKER_HUB_PASSWORD
environment:
DJANGO_SETTINGS_MODULE: warren.settings
DJANGO_CONFIGURATION: Test
DJANGO_SECRET_KEY: ThisIsAnExampleKeyForTestPurposeOnly
DB_NAME: lti
DB_USER: fun
DB_PASSWORD: pass
DB_PORT: 5432
POSTGRES_HOST: localhost
POSTGRES_DB: lti
POSTGRES_USER: fun
POSTGRES_PASSWORD: pass
- image: cimg/postgres:12.14
auth:
username: $DOCKER_HUB_USER
password: $DOCKER_HUB_PASS
environment:
POSTGRES_DB: lti
POSTGRES_USER: fun
POSTGRES_PASSWORD: pass
working_directory: ~/fun
steps:
- checkout
- restore_cache:
keys:
- v1-app-dependencies-<< parameters.python-image >>-{{ .Revision }}
- run:
name: Run tests
command: |
dockerize \
-wait tcp://localhost:5432 \
-timeout 60s \
~/.local/bin/pytest -c ./pyproject.toml
working_directory: src/app

# ---- Frontend jobs ----
lint-frontend:
docker:
Expand Down Expand Up @@ -248,7 +340,7 @@ jobs:
- checkout
- restore_cache:
keys:
- v1-dependencies-python:3.11-{{ .Revision }}
- v1-backend-dependencies-python:3.11-{{ .Revision }}
- attach_workspace:
at: ~/fun
- run:
Expand Down Expand Up @@ -367,6 +459,33 @@ workflows:
tags:
only: /.*/

# App jobs
#
# Build, lint and test production and development Docker images
# (debian-based)
- build-app:
matrix:
parameters:
python-image: [python:3.8, python:3.9, python:3.10, python:3.11]
filters:
tags:
only: /.*/
- lint-app:
requires:
- build-app
filters:
tags:
only: /.*/
- test-app:
matrix:
parameters:
python-image: [python:3.8, python:3.9, python:3.10, python:3.11]
requires:
- build-app
filters:
tags:
only: /.*/

# Frontend jobs
#
# Build, lint and test frontend sources
Expand Down
23 changes: 21 additions & 2 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
# Define development environment variables here.
# Warren API
WARREN_BACKEND_SERVER_PORT=8100
WARREN_LRS_HOSTS=http://ralph:8200
WARREN_LRS_AUTH_BASIC_USERNAME=ralph
WARREN_LRS_AUTH_BASIC_PASSWORD=secret

# Warren App
DJANGO_SETTINGS_MODULE=warren.settings
DJANGO_CONFIGURATION=Development
DJANGO_SECRET_KEY=ThisIsAnExampleKeyForDevPurposeOnly
DB_HOST=postgresql
DB_NAME=lti
DB_USER=fun
DB_PASSWORD=pass
DB_PORT=5432

# Python
PYTHONPATH=/app

# Postgresql configuration
POSTGRES_DB=lti
POSTGRES_USER=fun
POSTGRES_PASSWORD=pass

# Ralph LRS
RALPH_AUTH_FILE=/app/.ralph/auth.json
RALPH_BACKENDS__DATABASE__ES__HOSTS=http://elasticsearch:9200
RALPH_BACKENDS__DATABASE__ES__INDEX=statements
RALPH_RUNSERVER_PORT=8200
RALPH_AUTH_FILE=/app/.ralph/auth.json
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ and this project adheres to
- Add the LRS backend
- Switch the video view plugin from an elasticsearch to a LRS backend
- Remove the elasticsearch backend
- Add the LTI django application

[unreleased]: https://github.com/openfun/warren
Loading