Skip to content

Commit

Permalink
fixup! chore(ci): set up Lighthouse auditing in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Restioson committed Oct 22, 2024
1 parent 06e69c9 commit fc68469
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
12 changes: 12 additions & 0 deletions .env.lhci
Original file line number Diff line number Diff line change
@@ -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/
4 changes: 1 addition & 3 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ jobs:
npm install -g @lhci/[email protected]
- 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
Expand Down
11 changes: 8 additions & 3 deletions app/lighthouserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand All @@ -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,
Expand Down

0 comments on commit fc68469

Please sign in to comment.