From 62dcd25da4fc4fdb840cbe54cde5e3e612df46dd Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Thu, 17 Sep 2020 12:03:01 -0400 Subject: [PATCH 01/15] Create lighthouse-ci.yml --- .github/workflows/lighthouse-ci.yml | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/lighthouse-ci.yml diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml new file mode 100644 index 0000000..94a5b64 --- /dev/null +++ b/.github/workflows/lighthouse-ci.yml @@ -0,0 +1,46 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + pull_request: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "lhci" + lhci: + # The type of runner that the job will run on + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.6, 3.7, 3.8] + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Setup Python + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + # Install project dependencies and collect the static files + - name: Setup Live + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + python manage.py makemigrations --noinput + python manage.py migrate --noinput + python manage.py collectstatic --noinput + + # Runs Lighthouse CI + - name: Run Lighthouse CI + run: | + npm install -g @lhci/cli@0.5.0 + lhci autorun From 5d41ba8f3a0422cdfd00276373f65fe58da58aaa Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Thu, 17 Sep 2020 14:39:28 -0400 Subject: [PATCH 02/15] Create lighthouserc.js --- lighthouserc.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lighthouserc.js diff --git a/lighthouserc.js b/lighthouserc.js new file mode 100644 index 0000000..00330b7 --- /dev/null +++ b/lighthouserc.js @@ -0,0 +1,11 @@ +module.exports = { + ci: { + collect: { + url: ['http://localhost:8000/'], + startServerCommand: 'DEBUG=FALSE SECRET_KEY=bad_secret gunicorn --config ./compose/django/gunicorn.conf.py --bind localhost:8000 hacktj_live.asgi:application', + }, + upload: { + target: 'temporary-public-storage', + }, + }, +}; From 240eee7285776f8f55a96d48e5ec81c8fdc962ed Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Tue, 1 Dec 2020 17:26:06 -0500 Subject: [PATCH 03/15] Clean up workflow file and use Poetry --- .github/workflows/lighthouse-ci.yml | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 94a5b64..3883783 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -1,46 +1,34 @@ -# This is a basic workflow to help you get started with Actions +name: Lighthouse CI -name: CI - -# Controls when the action will run. Triggers the workflow on push or pull request -# events but only for the master branch on: push: pull_request: + workflow_dispatch: -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "lhci" lhci: - # The type of runner that the job will run on runs-on: ubuntu-latest strategy: max-parallel: 4 matrix: - python-version: [3.6, 3.7, 3.8] + python-version: [3.7, 3.8, 3.9] - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - # Setup Python - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - # Install project dependencies and collect the static files - name: Setup Live run: | python -m pip install --upgrade pip - python -m pip install -r requirements.txt - python manage.py makemigrations --noinput - python manage.py migrate --noinput - python manage.py collectstatic --noinput + python -m pip install poetry + poetry install + poetry run python manage.py collectstatic --noinput - # Runs Lighthouse CI - name: Run Lighthouse CI run: | - npm install -g @lhci/cli@0.5.0 + npm install -g @lhci/cli@0.6.1 lhci autorun From 86f6eef1bbc384b978314b57547e0b5f86e0bdb2 Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Tue, 1 Dec 2020 17:27:49 -0500 Subject: [PATCH 04/15] Use docker-compose to start server --- lighthouserc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthouserc.js b/lighthouserc.js index 00330b7..0c41a95 100644 --- a/lighthouserc.js +++ b/lighthouserc.js @@ -2,7 +2,7 @@ module.exports = { ci: { collect: { url: ['http://localhost:8000/'], - startServerCommand: 'DEBUG=FALSE SECRET_KEY=bad_secret gunicorn --config ./compose/django/gunicorn.conf.py --bind localhost:8000 hacktj_live.asgi:application', + startServerCommand: 'docker-compose -f docker-compose.yml -f docker-compose.prod.yml up', }, upload: { target: 'temporary-public-storage', From ed14716300a06ac1a79680ee6313b7dbe84448ca Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Tue, 1 Dec 2020 17:29:22 -0500 Subject: [PATCH 05/15] Remove unnecessary workflow steps --- .github/workflows/lighthouse-ci.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 3883783..ba2c5f1 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -10,24 +10,10 @@ jobs: runs-on: ubuntu-latest strategy: max-parallel: 4 - matrix: - python-version: [3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Setup Live - run: | - python -m pip install --upgrade pip - python -m pip install poetry - poetry install - poetry run python manage.py collectstatic --noinput - - name: Run Lighthouse CI run: | npm install -g @lhci/cli@0.6.1 From 9f3b3875d9fa8f34d3f233d8c23f2f91a87777d7 Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Tue, 1 Dec 2020 17:33:01 -0500 Subject: [PATCH 06/15] Set up node in workflow --- .github/workflows/lighthouse-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index ba2c5f1..ccc1a02 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -13,6 +13,11 @@ jobs: steps: - uses: actions/checkout@v2 + + - name: Use Node.js + uses: actions/setup-node@v2-beta + with: + node-version: '14' - name: Run Lighthouse CI run: | From 2d3d8d3acd96242f145873528a2c09135297804b Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Tue, 1 Dec 2020 17:35:02 -0500 Subject: [PATCH 07/15] Fix port in LHCI config --- lighthouserc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthouserc.js b/lighthouserc.js index 0c41a95..e181cc7 100644 --- a/lighthouserc.js +++ b/lighthouserc.js @@ -1,7 +1,7 @@ module.exports = { ci: { collect: { - url: ['http://localhost:8000/'], + url: ['http://localhost:1379/'], startServerCommand: 'docker-compose -f docker-compose.yml -f docker-compose.prod.yml up', }, upload: { From 21978b91ba35179737005faca1cdbdb538f55c1d Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Tue, 1 Dec 2020 17:43:04 -0500 Subject: [PATCH 08/15] Add "Prepare secrets" step --- .github/workflows/lighthouse-ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index ccc1a02..c1f527f 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -18,6 +18,15 @@ jobs: uses: actions/setup-node@v2-beta with: node-version: '14' + + - name: Prepare secrets + # we could use poetry run python manage.py createsecrets -o .env + # but this would require us to: + # 1. set up Python + # 2. install Poetry + # 3. install dependencies + # instead, we copy the example debug config file to save CI resources + run: cp .env.local .env - name: Run Lighthouse CI run: | From ec0b647d701118812b782e55cf318e630e6bffc2 Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Tue, 1 Dec 2020 17:50:54 -0500 Subject: [PATCH 09/15] [compose] Build images before running lhci --- .github/workflows/lighthouse-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index c1f527f..293b1fe 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -26,7 +26,9 @@ jobs: # 2. install Poetry # 3. install dependencies # instead, we copy the example debug config file to save CI resources - run: cp .env.local .env + run: | + cp .env.local .env + docker-compose -f docker-compose.yml -f docker-compose.dev.yml build --parallel - name: Run Lighthouse CI run: | From 60b404280b1f9f87e138c724f543d0faa7302d49 Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Tue, 1 Dec 2020 18:45:02 -0500 Subject: [PATCH 10/15] Move docker-compose build to its own step --- .github/workflows/lighthouse-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 293b1fe..99f9ad5 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -26,9 +26,10 @@ jobs: # 2. install Poetry # 3. install dependencies # instead, we copy the example debug config file to save CI resources - run: | - cp .env.local .env - docker-compose -f docker-compose.yml -f docker-compose.dev.yml build --parallel + run: cp .env.local .env + + - name: Build Docker images + run: docker-compose -f docker-compose.yml -f docker-compose.dev.yml build --parallel - name: Run Lighthouse CI run: | From 609feba72b7f1415754a17c8164273883b8f39ed Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Tue, 1 Dec 2020 18:58:45 -0500 Subject: [PATCH 11/15] Increase startServerReadyTimeout --- lighthouserc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lighthouserc.js b/lighthouserc.js index e181cc7..d055f3a 100644 --- a/lighthouserc.js +++ b/lighthouserc.js @@ -3,6 +3,7 @@ module.exports = { collect: { url: ['http://localhost:1379/'], startServerCommand: 'docker-compose -f docker-compose.yml -f docker-compose.prod.yml up', + startServerReadyTimeout: 60000, }, upload: { target: 'temporary-public-storage', From db29e4ef50d2206171b0fc7246a0ec680ebbb16e Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Tue, 1 Dec 2020 19:16:49 -0500 Subject: [PATCH 12/15] Run LHCI diagnostics --- .github/workflows/lighthouse-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 99f9ad5..1ae1405 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -34,4 +34,5 @@ jobs: - name: Run Lighthouse CI run: | npm install -g @lhci/cli@0.6.1 + lhci healthcheck lhci autorun From fac0d5d456a306f67867281f857efc0d32408fb7 Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Tue, 1 Dec 2020 19:26:43 -0500 Subject: [PATCH 13/15] Revert "Run LHCI diagnostics" Diagnostics are already run with `lhci autorun`. This reverts commit 8308d9d1ef38e23244c38811f6145047876acc67. --- .github/workflows/lighthouse-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 1ae1405..99f9ad5 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -34,5 +34,4 @@ jobs: - name: Run Lighthouse CI run: | npm install -g @lhci/cli@0.6.1 - lhci healthcheck lhci autorun From ac564e8a5b31d344e525eada43aacb4caf58fadb Mon Sep 17 00:00:00 2001 From: Sumanth Ratna Date: Wed, 13 Jan 2021 09:18:08 -0500 Subject: [PATCH 14/15] Start Compose before running LHCI --- .github/workflows/lighthouse-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 99f9ad5..c9d76df 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v2 with: node-version: '14' @@ -33,5 +33,6 @@ jobs: - name: Run Lighthouse CI run: | + docker-compose -f docker-compose.yml -f docker-compose.dev.yml up npm install -g @lhci/cli@0.6.1 lhci autorun From 432897cfc35b19fafad5422140158c4142d42096 Mon Sep 17 00:00:00 2001 From: Sumanth Ratna <2022sratna@tjhsst.edu> Date: Wed, 13 Jan 2021 09:31:00 -0500 Subject: [PATCH 15/15] Fix port --- .github/workflows/lighthouse-ci.yml | 7 +++---- lighthouserc.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index c9d76df..631ac4f 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -13,12 +13,12 @@ jobs: steps: - uses: actions/checkout@v2 - + - name: Use Node.js uses: actions/setup-node@v2 with: node-version: '14' - + - name: Prepare secrets # we could use poetry run python manage.py createsecrets -o .env # but this would require us to: @@ -27,12 +27,11 @@ jobs: # 3. install dependencies # instead, we copy the example debug config file to save CI resources run: cp .env.local .env - + - name: Build Docker images run: docker-compose -f docker-compose.yml -f docker-compose.dev.yml build --parallel - name: Run Lighthouse CI run: | - docker-compose -f docker-compose.yml -f docker-compose.dev.yml up npm install -g @lhci/cli@0.6.1 lhci autorun diff --git a/lighthouserc.js b/lighthouserc.js index d055f3a..17e3588 100644 --- a/lighthouserc.js +++ b/lighthouserc.js @@ -1,7 +1,7 @@ module.exports = { ci: { collect: { - url: ['http://localhost:1379/'], + url: ['http://localhost:8000/'], startServerCommand: 'docker-compose -f docker-compose.yml -f docker-compose.prod.yml up', startServerReadyTimeout: 60000, },