From 5a757307f7f9d46d5f0c59a848d4df6163fdddfb Mon Sep 17 00:00:00 2001 From: Restioson Date: Tue, 22 Oct 2024 14:05:45 +0200 Subject: [PATCH] fixup! chore(ci): set up Lighthouse auditing in CI --- .github/workflows/testing.yml | 34 +++++++++++++++++++++++++--------- app/lighthouserc.js | 1 + 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 45a1ba6..4fcbe51 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -16,15 +16,11 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - - uses: actions/setup-node@v3 - with: - node-version: 18 - name: Install Dependencies run: | python -m pip install --upgrade pip pip install -r requirements-test.txt sudo apt-get install -y gettext - npm install -g @lhci/cli@0.14.x - name: Run linting tools run: | cd app/ @@ -59,9 +55,29 @@ jobs: run: | cd app/ python manage.py check - - name: Run Lighthouse + lighthouse: + runs-on: ubuntu-latest # operating system your code will run on + services: + postgres: + image: postgres:16 + env: + POSTGRES_USER: sadilar + POSTGRES_PASSWORD: sadilar + POSTGRES_DB: test_db_1 + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install Dependencies run: | - cd app/ - DB_NAME=test_db_1 DB_USER=sadilar DB_PASSWORD=sadilar python manage.py migrate - echo done migrations - lhci autorun + python -m pip install --upgrade pip + pip install -r requirements-test.txt + sudo apt-get install -y gettext + npm install -g @lhci/cli@0.14.x + - name: Migrate database + run: cd app && DB_NAME=test_db_1 DB_USER=sadilar DB_PASSWORD=sadilar python manage.py migrate + - name: Run Lighthouse + run: cd app && lhci autorun diff --git a/app/lighthouserc.js b/app/lighthouserc.js index 834f035..1f61d71 100644 --- a/app/lighthouserc.js +++ b/app/lighthouserc.js @@ -3,6 +3,7 @@ let env = process.env; module.exports = { ci: { collect: { + numberOfRuns: 1, // We don't care about variable page performance metrics in CI - just static asserts startServerCommand: `DB_NAME=test_db_1 DB_USER=sadilar DB_PASSWORD=sadilar ` + "python manage.py runserver localhost:3000", url: [