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 an in-memory DB for to satisfy Django's need for a "database".
- 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:

- Fill out README. Full documentation has been ticketed in
  #3 and linked
  from the README.
- Removed PyPI badge as this is an IDA and won't be published as a
  package.
- Update catalog-info.yaml from defaults
- Tweaks to PR template

Build:

- Suppress code coverage checks for gunicorn config file

Finally:

- Run `make upgrade`
  • Loading branch information
timmc-edx committed Jan 28, 2025
1 parent e0e1193 commit e75614f
Show file tree
Hide file tree
Showing 51 changed files with 1,787 additions and 1,082 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
27 changes: 0 additions & 27 deletions .github/workflows/check-reserved-keywords.yml

This file was deleted.

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
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

Loading

0 comments on commit e75614f

Please sign in to comment.