Skip to content

Commit

Permalink
feat: Trim cookiecutter output and get a basic working skeleton
Browse files Browse the repository at this point in the history
Major changes:

- Trim dependencies, settings, and application code to remove anything
  relating to having a database (auth, models, pii-annotations,
  reserved-keywords) or being exposed to the outside world (cors, csrf).
  Add a blank DB for tests.
- Remove unneeded requirements files. We're going to deploy the base
  layer instead of the production layer, and requirements.txt is
  just not needed at all as far as I can tell.
- Install gunicorn in the base layer. It's not clear if we'll want to
  use it from devstack (or just use runserver) but it should be
  available when we want to use it.
- Don't hardcode gunicorn's bind address; we'll pass it as `--bind`
  from the Dockerfile.
- Remove Dockerfile and devstack.py as these will be provided elsewhere.

Fixes:

- Use Python 3.12 for tox invocation (to match tox.ini and others)

Docs:

- Update catalog-info.yaml from defaults
- Tweaks to PR template

TODO:

- Re-enable various edx-django-utils middleware as soon as I can
  determine how to get them working without a DB. (Some of them
  use waffle flags.)

Finally:

- Run `make upgrade`
  • Loading branch information
timmc-edx committed Jan 24, 2025
1 parent 391a786 commit eba090b
Show file tree
Hide file tree
Showing 47 changed files with 1,772 additions and 1,019 deletions.
37 changes: 0 additions & 37 deletions .annotation_safe_list.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

**Merge checklist:**
Check off if complete *or* not applicable:
- [ ] Version bumped
- [ ] Changelog record added
- [ ] Documentation updated (not only docstrings)
- [ ] Fixup commits are squashed away
- [ ] Unit tests added/updated
- [ ] Manual testing instructions provided
- [ ] Noted any: Concerns, dependencies, migration issues, deadlines, tickets
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
os: [ubuntu-latest]
python-version: ["3.12"]
toxenv: ["py311", "quality", "docs", "pii_check"]
toxenv: ["py312", "quality", "docs"]
steps:
- uses: actions/checkout@v4
- name: setup python
Expand Down
35 changes: 0 additions & 35 deletions .pii_annotations.yml

This file was deleted.

86 changes: 0 additions & 86 deletions Dockerfile

This file was deleted.

70 changes: 4 additions & 66 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
.DEFAULT_GOAL := help

.PHONY: help clean clean_tox docs requirements ci_requirements dev_requirements \
validation_requirements doc_requirements production-requirements static shell \
test coverage isort_check isort style lint quality pii_check validate \
validation_requirements doc_requirements static shell \
test coverage isort_check isort style lint qualityvalidate \
migrate html_coverage upgrade extract_translation dummy_translations \
compile_translations fake_translations pull_translations \
start-devstack open-devstack pkg-devstack \
detect_changed_source_translations validate_translations check_keywords \
detect_changed_source_translations validate_translations \
install_transifex_client

# For opening files in a browser. Use like: $(BROWSER)relative/path/to/file.html
Expand All @@ -21,7 +20,6 @@ clean: ## delete generated byte code and coverage reports
find . -name '*.pyc' -delete
coverage erase
rm -rf assets
rm -rf pii_report

clean_tox: ## clear tox requirements cache
rm -fr .tox
Expand All @@ -47,9 +45,6 @@ validation_requirements: piptools ## sync to requirements for testing & code qua
doc_requirements: piptools
pip-sync -q requirements/doc.txt

production-requirements: piptools ## install requirements for production
pip-sync -q requirements/production.txt

static: ## generate static files
python manage.py collectstatic --noinput

Expand Down Expand Up @@ -79,14 +74,7 @@ lint: ## run Python code linting
quality:
tox -e quality

pii_check: ## check for PII annotations on all Django models
DJANGO_SETTINGS_MODULE=codejail_service.settings.test \
code_annotations django_find_annotations --config_file .pii_annotations.yml --lint --report --coverage

check_keywords: ## Scan the Django models in all installed apps in this project for restricted field names
python manage.py check_reserved_keywords --override_file db_keyword_overrides.yml

validate: test quality pii_check check_keywords ## run tests, quality, and PII annotation checks
validate: test quality ## run tests, quality

migrate: ## apply database migrations
python manage.py migrate
Expand All @@ -112,7 +100,6 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy
$(PIP_COMPILE) -o requirements/validation.txt requirements/validation.in
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
$(PIP_COMPILE) -o requirements/production.txt requirements/production.in
# Let tox control the Django version for tests
grep -e "^django==" requirements/base.txt > requirements/django.txt
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
Expand Down Expand Up @@ -142,60 +129,11 @@ pull_translations:
@echo "Translations have been pulled via Atlas and compiled."
endif

start-devstack: ## run a local development copy of the server
docker-compose --x-networking up

open-devstack: ## open a shell on the server started by start-devstack
docker exec -it codejail-service /edx/app/codejail-service/devstack.sh open

pkg-devstack: ## build the codejail-service image from the latest configuration and code
docker build -t codejail-service:latest -f docker/build/codejail-service/Dockerfile git://github.com/openedx/configuration

detect_changed_source_translations: ## check if translation files are up-to-date
cd codejail_service && i18n_tool changed

validate_translations: fake_translations detect_changed_source_translations ## install fake translations and check if translation files are up-to-date

docker_build:
docker build . -f Dockerfile -t openedx/codejail-service

# devstack-themed shortcuts
dev.up: # Starts all containers
docker-compose up -d

dev.up.build:
docker-compose up -d --build

dev.down: # Kills containers and all of their data that isn't in volumes
docker-compose down

dev.stop: # Stops containers so they can be restarted
docker-compose stop

app-shell: # Run the app shell as root
docker exec -u 0 -it codejail_service.app bash

db-shell: # Run the app shell as root, enter the app's database
docker exec -u 0 -it codejail_service.db mysql -u root codejail_service

%-logs: # View the logs of the specified service container
docker-compose logs -f --tail=500 $*

%-restart: # Restart the specified service container
docker-compose restart $*

%-attach:
docker attach codejail_service.$*

docker_auth:
echo "$$DOCKERHUB_PASSWORD" | docker login -u "$$DOCKERHUB_USERNAME" --password-stdin

docker_tag_build_push: docker_auth
docker buildx build -t openedx/codejail-service:latest -t openedx/codejail-service:${GITHUB_SHA} --platform linux/amd64,linux/arm64 --target prod --push .

docker_tag_build_push_dev: docker_auth
docker buildx build -t openedx/codejail-service-dev:latest -t openedx/codejail-service-dev:${GITHUB_SHA} --platform linux/amd64,linux/arm64 --target dev --push .

selfcheck: ## check that the Makefile is well-formed
@echo "The Makefile is well-formed."

Expand Down
19 changes: 5 additions & 14 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,28 @@
# https://open-edx-proposals.readthedocs.io/en/latest/processes/oep-0055-proc-project-maintainers.html

apiVersion: backstage.io/v1alpha1
kind: ""
kind: Component
metadata:
name: 'codejail-service'
description: "Run codejail (sandboxed Python execution) as a service"
annotations:
# The openedx.org/release key is described in OEP-10:
# https://open-edx-proposals.readthedocs.io/en/latest/oep-0010-proc-openedx-releases.html
# The FAQ might also be helpful: https://openedx.atlassian.net/wiki/spaces/COMM/pages/1331268879/Open+edX+Release+FAQ
# Note: This will only work if the repo is in the `openedx` org in github. Repos in other orgs that have this
# setting will still be treated as if they don't want to be part of the Open edX releases.
openedx.org/release: null
# (Optional) Annotation keys and values can be whatever you want.
# We use it in Open edX repos to have a comma-separated list of GitHub user
# names that might be interested in changes to the architecture of this
# component.
openedx.org/arch-interest-groups: ""
openedx.org/release: "main"
spec:

# (Required) This can be a group(`group:<group_name>` or a user(`user:<github_username>`)
owner: ""

# (Required) Acceptable Type Values: service, website, library
type: ''
type: service

# (Required) Acceptable Lifecycle Values: experimental, production, deprecated
lifecycle: 'experimental'

# (Optional) The value can be the name of any known component.
subcomponentOf: '<name_of_a_component>'
subcomponentOf: edx-platform

# (Optional) An array of different components or resources.
dependsOn:
- '<component_or_resource>'
- '<another_component_or_resource>'
dependsOn: []
4 changes: 0 additions & 4 deletions codejail_service/apps/api/models.py

This file was deleted.

4 changes: 0 additions & 4 deletions codejail_service/apps/api/serializers.py

This file was deleted.

22 changes: 0 additions & 22 deletions codejail_service/apps/core/admin.py

This file was deleted.

7 changes: 0 additions & 7 deletions codejail_service/apps/core/constants.py

This file was deleted.

9 changes: 0 additions & 9 deletions codejail_service/apps/core/context_processors.py

This file was deleted.

Empty file.
Loading

0 comments on commit eba090b

Please sign in to comment.