Skip to content

Commit

Permalink
Merge pull request #62 from pennlabs/aag/predeploy-backend-fixes
Browse files Browse the repository at this point in the history
Aag/predeploy backend fixes
  • Loading branch information
AaDalal authored Apr 2, 2024
2 parents 640d5d3 + 829a075 commit 505f1a8
Show file tree
Hide file tree
Showing 96 changed files with 338 additions and 3,333 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM --platform=linux/amd64 ubuntu:22.04
ARG IMAGE_NAME=pennlabs/courses-devcontainer
RUN apt-get update && apt-get install -y wget curl gcc python3-dev libpq-dev
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "Penn Courses",
"build": { "dockerfile": "Dockerfile" },
"containerUser": "otis",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.11"
},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/common-utils:2": {
"configureZshAsDefaultShell": true,
"username": "otis"
},
"git-lfs": "latest",
"terraform": {
"version": "latest",
"tflint": "latest",
"terragrunt": "latest"
}
},
"customizations": {
"vscode": {
"extensions": ["esbenp.prettier-vscode"]
}
}
}
3 changes: 2 additions & 1 deletion .github/workflows/shared-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
path: backend
flake: true
black: true
pythonVersion: 3.10-buster
pythonVersion: 3.11-buster

publish-backend:
uses: pennlabs/shared-actions/.github/workflows/docker-publish.yaml@v0.1
Expand Down Expand Up @@ -55,6 +55,7 @@ jobs:
product: [review, plan, alert]
with:
path: frontend/${{ matrix.product }}
nodeVersion: 18.19.0

publish-frontend:
uses: pennlabs/shared-actions/.github/workflows/docker-publish.yaml@v0.1
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
.env*
.yarn/build-state.yml
.yarn/unplugged
.yarn/install-state.gz
.vscode
.idea/
.DS_Store
Expand All @@ -26,4 +23,4 @@ pcr-backup*
./Pipfile
./Pipfile.lock
./package.json
./yarn.lock
./yarn.lock
11 changes: 0 additions & 11 deletions Pipfile

This file was deleted.

23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Penn Courses with Penn Degree Plan
# Penn Courses
![Workflow](https://github.com/pennlabs/penn-courses/workflows/Workflow/badge.svg)
[![Coverage Status](https://codecov.io/gh/pennlabs/penn-courses/branch/master/graph/badge.svg)](https://codecov.io/gh/pennlabs/penn-courses)

Expand All @@ -10,6 +10,27 @@ This is the unified home of all [Penn Courses](https://penncourses.org) products

Note that you need the backend to run the frontend.

### Using Dev Containers

This repository has a built-in dev container that you can use to develop the project. To use it, you need to have [Docker](https://www.docker.com/products/docker-desktop) and [VSCode](https://code.visualstudio.com/) installed.

Press the remote container button in the bottom left of the window and select "Reopen in Container". This will build the dev container and open the project in a new window.

This container is designed to work with both backend and frontend development. Some additional steps are required, like installing `pipenv` dependencies and setting up the database and running the frontend server. Please read and follow the instructions in the backend and frontend READMEs.

For more information, visit dev container [documentation](https://code.visualstudio.com/docs/remote/containers).

#### Pushing Code

You can use `ssh-add` to make your SSH keys available to the dev container. This will allow you to push code to GitHub.

```
ssh-add ~/.ssh/id_rsa
```




## API Documentation
API Docs can be found at `/api/documentation` on the back-end server. Also check out the code for more explanations
and documentation! We've tried to keep it up-to-date.
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM pennlabs/django-base:9c4f31bf1af44219d0f9019271a0033a222291c2-3.10.1
FROM pennlabs/django-base:b269ea1613686b1ac6370154debbb741b012de1a-3.11

LABEL maintainer="Penn Labs"

Expand Down
8 changes: 2 additions & 6 deletions backend/PennCourses/docs_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,7 @@ def update_tag(old_tag, new_tag):
all_list = all([("list" in v["operationId"].lower()) for v in tag_to_dicts[tag]])
if all_list: # if all views in tag are lists, pluralize tag name
tag = update_tag(
tag,
" ".join(tag.split(" ")[:-1] + [pluralize_word(tag.split(" ")[-1])]),
tag, " ".join(tag.split(" ")[:-1] + [pluralize_word(tag.split(" ")[-1])])
)
if tag in custom_tag_names.keys(): # rename custom tags
tag = update_tag(tag, custom_tag_names[tag])
Expand Down Expand Up @@ -852,10 +851,7 @@ def fail(param, hint):
fail(param_name, f"The {param_name} kwarg must be a dict.")
for dictionary in param_dict.values():
if not isinstance(dictionary, dict):
fail(
param_name,
f"All values of the {param_name} dict must be dicts.",
)
fail(param_name, f"All values of the {param_name} dict must be dicts.")
for nested_dictionary in dictionary.values():
if param_name == "custom_parameters":
if not isinstance(nested_dictionary, list):
Expand Down
6 changes: 0 additions & 6 deletions backend/PennCourses/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"options.apps.OptionsConfig",
"django.contrib.admindocs",
"django_extensions",
"django_filters",
"alert",
"courses",
"plan",
Expand Down Expand Up @@ -201,11 +200,6 @@
"rest_framework.authentication.BasicAuthentication",
"accounts.authentication.PlatformAuthentication",
],
"DEFAULT_PARSER_CLASSES": (
"rest_framework.parsers.JSONParser",
"rest_framework.parsers.FormParser",
"rest_framework.parsers.MultiPartParser",
),
}

STATS_WEBHOOK = os.environ.get("STATS_WEBHOOK", None)
Expand Down
3 changes: 3 additions & 0 deletions backend/PennCourses/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"LOCATION": REDIS_URL,
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"IGNORE_EXCEPTIONS": True, # ignore Redis connection errors
"SOCKET_CONNECT_TIMEOUT": 1,
"SOCKET_TIMEOUT": 1,
},
}
}
Expand Down
5 changes: 1 addition & 4 deletions backend/PennCourses/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

from alert.views import accept_webhook
from courses.views import UserView
from PennCourses.docs_settings import (
JSONOpenAPICustomTagGroupsRenderer,
openapi_description,
)
from PennCourses.docs_settings import JSONOpenAPICustomTagGroupsRenderer, openapi_description


api_urlpatterns = [
Expand Down
10 changes: 4 additions & 6 deletions backend/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ pytest = "*"
pytest-django = "*"
django-debug-toolbar = "*"
black = "==22.3.0"
colorama = {version = "*", sys_platform = "== 'win32'"}
selenium = "*"

[packages]
click = "==8.0.4"
django = ">=3.2"
django = "==5.0.2"
psycopg2 = "*"
requests = "*"
twilio = "*"
channels = "<3"
channels = "*"
channels-redis = "*"
phonenumbers = "*"
celery = "<5"
celery = "*"
redis = ">=3.4.1"
sentry-sdk = "*"
dj-database-url = "*"
Expand Down Expand Up @@ -67,4 +65,4 @@ ics = "*"
drf-nested-routers = "*"

[requires]
python_full_version = "3.10"
python_full_version = "3.11"
Loading

0 comments on commit 505f1a8

Please sign in to comment.