Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
fix: Clean autoconfig (#1698)
Browse files Browse the repository at this point in the history
* fix: Clean up autoconfig

* Update lockfile and add --clear

* Try commenting out admin creation

* Clean aimmo runner
  • Loading branch information
faucomte97 authored Sep 5, 2022
1 parent 1c18fa9 commit dac77fe
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 118 deletions.
1 change: 0 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ ignore:
- "aimmo_runner/**/*"
- "test_utils/*"
- "setup.py"
- "aimmo/csp_config.py"

comment:
layout: "reach, diff, flags, files"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ db.sqlite3
*.iml

# static folder
example_project/example_project/static/
static/

# Created during minikube testing
test-bin/
Expand Down
76 changes: 38 additions & 38 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions aimmo/csp_config.py

This file was deleted.

49 changes: 10 additions & 39 deletions aimmo_runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

import logging
import os
import sys
import time

import django
import sys
from django.conf import settings

from .shell_api import log, run_command, run_command_async

ROOT_DIR_LOCATION = os.path.abspath(os.path.dirname((os.path.dirname(__file__))))

_MANAGE_PY = os.path.join(ROOT_DIR_LOCATION, "example_project", "manage.py")
_FRONTEND_BUNDLER_JS = os.path.join(
ROOT_DIR_LOCATION, "game_frontend", "djangoBundler.js"
)
_FRONTEND_BUNDLER_JS = os.path.join(ROOT_DIR_LOCATION, "game_frontend", "djangoBundler.js")

PROCESSES = []

Expand All @@ -27,25 +24,18 @@ def create_superuser_if_missing(username, password):
User.objects.get_by_natural_key(username)
except User.DoesNotExist:
log("Creating superuser %s with password %s" % (username, password))
User.objects.create_superuser(
username=username, email="admin@admin.com", password=password
)
User.objects.create_superuser(username=username, email="admin@admin.com", password=password)


def build_worker_package():
run_command(
[os.path.join(ROOT_DIR_LOCATION, "aimmo_runner", "build_worker_wheel.sh")],
capture_output=True,
)
run_command([os.path.join(ROOT_DIR_LOCATION, "aimmo_runner", "build_worker_wheel.sh")], capture_output=True)


def build_frontend(using_cypress, capture_output):
if using_cypress:
run_command(["node", _FRONTEND_BUNDLER_JS], capture_output=capture_output)
else:
frontend_bundler = run_command_async(
["node", _FRONTEND_BUNDLER_JS], capture_output=capture_output
)
frontend_bundler = run_command_async(["node", _FRONTEND_BUNDLER_JS], capture_output=capture_output)
PROCESSES.append(frontend_bundler)


Expand All @@ -63,13 +53,7 @@ def start_game_servers(build_target, server_args):
os.environ["AIMMO_MODE"] = "minikube"


def run(
server_wait=True,
using_cypress=False,
capture_output=False,
test_env=False,
build_target=None,
):
def run(server_wait=True, using_cypress=False, capture_output=False, test_env=False, build_target=None):
logging.basicConfig()

build_worker_package()
Expand All @@ -90,31 +74,18 @@ def run(

build_frontend(using_cypress, capture_output)

run_command(
["pip", "install", "-e", ROOT_DIR_LOCATION], capture_output=capture_output
)
run_command(["pip", "install", "-e", ROOT_DIR_LOCATION], capture_output=capture_output)

if not test_env:
run_command(
["python", _MANAGE_PY, "migrate", "--noinput"],
capture_output=capture_output,
)
run_command(
["python", _MANAGE_PY, "collectstatic", "--noinput"],
capture_output=capture_output,
)

create_superuser_if_missing(username="admin", password="admin")
run_command(["python", _MANAGE_PY, "migrate", "--noinput"], capture_output=capture_output)
run_command(["python", _MANAGE_PY, "collectstatic", "--noinput", "--clear"], capture_output=capture_output)

server_args = []
if not using_cypress:
start_game_servers(build_target, server_args)

os.environ["SERVER_ENV"] = "local"
server = run_command_async(
["python", _MANAGE_PY, "runserver"] + server_args,
capture_output=capture_output,
)
server = run_command_async(["python", _MANAGE_PY, "runserver"] + server_args, capture_output=capture_output)
PROCESSES.append(server)

if server_wait:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example_project/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from kubernetes.config import load_kube_config

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_project.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

from django.core.management import execute_from_command_line

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Django settings for example_project project."""
import os
import mimetypes
import os

from django.http import Http404
from kubernetes.client.api.custom_objects_api import CustomObjectsApi
from kubernetes.client.api_client import ApiClient

from aimmo.csp_config import * # Still keeping the config file, seems cleaner?
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

ALLOWED_HOSTS = ["*"]

Expand All @@ -29,36 +29,37 @@

TIME_ZONE = "Europe/London"
LANGUAGE_CODE = "en-gb"
STATIC_ROOT = os.path.join(os.path.dirname(__file__), "static")
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = "/static/"
SECRET_KEY = "not-a-secret"
STATICFILES_DIRS = [os.path.join(BASE_DIR, "aimmo/static")]

mimetypes.add_type("application/wasm", ".wasm", True)

ROOT_URLCONF = "example_project.urls"
SECRET_KEY = "not-a-secret"
ROOT_URLCONF = "urls"

WSGI_APPLICATION = "example_project.wsgi.application"

DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

INSTALLED_APPS = [
"game",
"pipeline",
"portal",
"aimmo",
"common",
"django.contrib.admin",
"django.contrib.admindocs",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.sites",
"django.contrib.staticfiles",
"aimmo",
"game",
"portal",
"common",
"django_js_reverse",
"rest_framework",
"django_otp",
"django_otp.plugins.otp_static",
"django_otp.plugins.otp_totp",
"rest_framework",
"sekizai", # for javascript and css management
]

Expand Down Expand Up @@ -99,6 +100,37 @@
"django.contrib.messages.middleware.MessageMiddleware",
]

PIPELINE = {
"SASS_ARGUMENTS": "--quiet",
"COMPILERS": ("game.pipeline_compilers.LibSassCompiler",),
"STYLESHEETS": {
"css": {
"source_filenames": (
os.path.join(BASE_DIR, "static/portal/sass/bootstrap.scss"),
os.path.join(BASE_DIR, "static/portal/sass/colorbox.scss"),
os.path.join(BASE_DIR, "static/portal/sass/styles.scss"),
),
"output_filename": "portal.css",
},
"popup": {
"source_filenames": (os.path.join(BASE_DIR, "static/portal/sass/partials/_popup.scss"),),
"output_filename": "popup.css",
},
"game-scss": {
"source_filenames": (os.path.join(BASE_DIR, "static/game/sass/game.scss"),),
"output_filename": "game.css",
},
},
"CSS_COMPRESSOR": None,
}

STATICFILES_FINDERS = [
"pipeline.finders.PipelineFinder",
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
STATICFILES_STORAGE = "pipeline.storage.PipelineStorage"

# This is used in common to enable/disable the OneTrust cookie management script
COOKIE_MANAGEMENT_ENABLED = False

Expand Down Expand Up @@ -138,3 +170,5 @@ def get_game_url_base_and_path(game_id: int) -> str:
from example_project.local_settings import * # pylint: disable=E0611
except ImportError:
pass

from common.csp_config import *
Loading

0 comments on commit dac77fe

Please sign in to comment.