From fc68469c09970f916a585926f79ed2723bc89745 Mon Sep 17 00:00:00 2001 From: Restioson Date: Tue, 22 Oct 2024 18:55:15 +0200 Subject: [PATCH] fixup! chore(ci): set up Lighthouse auditing in CI --- .env.lhci | 12 ++++++++++++ .github/workflows/testing.yml | 4 +--- app/lighthouserc.js | 11 ++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 .env.lhci diff --git a/.env.lhci b/.env.lhci new file mode 100644 index 0000000..c184f01 --- /dev/null +++ b/.env.lhci @@ -0,0 +1,12 @@ +SECRET_KEY='django-insecure-w!h85bp^$$e8gm%c23r!0%9i7yzd=6w$$s&ic+6!%306&kj8@k*5' +DEBUG=False +DB_HOST=localhost +DB_PORT=5432 +DB_NAME=term_db +DB_USER=sadilar +DB_PASSWORD=sadilar +LOGGING_FILE=debug.log +LOGGING_HANDLERS_LEVEL=INFO +LOGGING_LOGGERS_LEVEL=INFO +LOGGING_LOGGERS_DJANGO_LEVEL=INFO +TESTING_DIR=/home/runner/work/term_platform/term_platform/app/general/tests/files/ diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2a34d95..4697acd 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -93,9 +93,7 @@ jobs: npm install -g @lhci/cli@0.14.x - name: Create folders run: | - sudo mkdir -p /logging app/static_files - sudo chown runner:runner /logging app/static_files - cp .env.testing app/.env + cp .env.lhci app/.env cp entrypoint.sh app/ sudo chmod +x app/entrypoint.sh - name: Run Lighthouse diff --git a/app/lighthouserc.js b/app/lighthouserc.js index e7353c6..6e40862 100644 --- a/app/lighthouserc.js +++ b/app/lighthouserc.js @@ -7,8 +7,10 @@ module.exports = { // If we don't set PYTHONUNBUFFERED=1, then the ready message is never detected by lhci // We also need to set DEBUG='' to disable the debug toolbar and make the page more like what we run in // production. This, in turn, necessitates setting ALLOWED_HOSTS - startServerCommand: "./entrypoint.sh", - // startServerReadyPattern: "Starting development server at", + + // The sleep + wget warms up Django to prevent any major performance issues + startServerCommand: "./entrypoint.sh & sleep 3 && wget http://localhost:8000 > /dev/null && echo 'LHCI ready'", + startServerReadyPattern: "LHCI ready", url: [ "http://localhost:8000", "http://localhost:8000/search/", @@ -18,10 +20,13 @@ module.exports = { "http://localhost:8000/languages/", "http://localhost:8000/subjects/" ] - }, + }, // TODO DEBUG=True now disable this !!! should not use .env.testing assert: { "preset": "lighthouse:recommended", "assertions": { + // Gunicorn doesn't do this + "use-text-compression": false, + // We don't think these are worth worrying about for now "unminified-javascript": false, "unused-css-rules": false,