From e475c5443165621583ad3b6434afed5067b7bac1 Mon Sep 17 00:00:00 2001 From: Barry Date: Sat, 31 Oct 2020 09:22:43 +0000 Subject: [PATCH 01/59] Add Lighthouse-ci Action --- .github/lighthouse/lighthouse-assertions.json | 13 +++++ .github/lighthouse/lighthouse-budget.json | 17 ++++++ .github/workflows/test_website.yml | 57 +++++++++++-------- 3 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 .github/lighthouse/lighthouse-assertions.json create mode 100644 .github/lighthouse/lighthouse-budget.json diff --git a/.github/lighthouse/lighthouse-assertions.json b/.github/lighthouse/lighthouse-assertions.json new file mode 100644 index 00000000000..712f67f6623 --- /dev/null +++ b/.github/lighthouse/lighthouse-assertions.json @@ -0,0 +1,13 @@ +{ + "ci": { + "assert": { + "assertions": { + "categories:performance": ["warn", {"minScore": 0.9}], + "categories:accessibility": ["error", {"minScore": 1}], + "categories:best-practice": ["error", {"minScore": 1}], + "categories:seo": ["error", {"minScore": 1}], + "categories:pwa": ["error", {"minScore": 1}] + } + } + } +} diff --git a/.github/lighthouse/lighthouse-budget.json b/.github/lighthouse/lighthouse-budget.json new file mode 100644 index 00000000000..02f3b0b685d --- /dev/null +++ b/.github/lighthouse/lighthouse-budget.json @@ -0,0 +1,17 @@ +[ + { + "path": "/*", + "resourceSizes": [ + { + "resourceType": "total", + "budget": 200 + } + ], + "resourceCounts": [ + { + "resourceType": "third-party", + "budget": 10 + } + ] + } +] diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index e7fc4ffcb0d..c5bd6ff256d 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -15,26 +15,37 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'HTTPArchive/almanac.httparchive.org' steps: - - name: Checkout branch - uses: actions/checkout@v2.3.3 - with: - # Full git history is needed to get a proper list of changed files within `super-linter` - fetch-depth: 0 - - name: Setup Node.js for use with actions - uses: actions/setup-node@v1.4.2 - with: - node-version: 12.x - - name: Set up Python 3.8 - uses: actions/setup-python@v2.1.4 - with: - python-version: '3.8' - - name: Run the website - run: ./src/tools/scripts/run_and_test_website.sh - - name: Remove node modules to avoid linting errors - run: rm -rf src/node_modules - - name: Lint Generated HTML - uses: github/super-linter@v3.13.2 - env: - DEFAULT_BRANCH: main - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VALIDATE_HTML: true + - name: Checkout branch + uses: actions/checkout@v2.3.3 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 + - name: Setup Node.js for use with actions + uses: actions/setup-node@v1.4.2 + with: + node-version: 12.x + - name: Set up Python 3.8 + uses: actions/setup-python@v2.1.4 + with: + python-version: '3.8' + - name: Run the website + run: ./src/tools/scripts/run_and_test_website.sh + - name: Remove node modules to avoid linting errors + run: rm -rf src/node_modules + - name: Lint Generated HTML + uses: github/super-linter@v3.13.2 + env: + DEFAULT_BRANCH: main + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_HTML: true + - name: Audit URLs using Lighthouse + uses: treosh/lighthouse-ci-action@v3 + with: + urls: | + http://127.0.0.1:8080/en/2019/ + http://127.0.0.1:8080/en/2019/css + http://127.0.0.1:8080/en/2020/ + assertionPath: .github/lighthouse-assertions.json # test assertion budgets + budgetPath: .github/lighthouse-budget.json # test performance budgets + uploadArtifacts: true # save results as an action artifacts + temporaryPublicStorage: true # upload lighthouse report to the temporary storage From 40f95689824225e407a146f0dc85e1a07fc220fe Mon Sep 17 00:00:00 2001 From: Barry Date: Sat, 31 Oct 2020 09:23:50 +0000 Subject: [PATCH 02/59] Make it run on this repo --- .github/workflows/test_website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index c5bd6ff256d..bbb287daece 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -13,7 +13,7 @@ jobs: build: name: Build and Test Website runs-on: ubuntu-latest - if: github.repository == 'HTTPArchive/almanac.httparchive.org' + if: github.repository == 'bazzadp/almanac.httparchive.org' steps: - name: Checkout branch uses: actions/checkout@v2.3.3 From abe8fa9848594738cddb7cf995ad657eccf528da Mon Sep 17 00:00:00 2001 From: Barry Date: Sat, 31 Oct 2020 09:32:09 +0000 Subject: [PATCH 03/59] Fix config --- .github/workflows/test_website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index bbb287daece..4dfa4d610ab 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -45,7 +45,7 @@ jobs: http://127.0.0.1:8080/en/2019/ http://127.0.0.1:8080/en/2019/css http://127.0.0.1:8080/en/2020/ - assertionPath: .github/lighthouse-assertions.json # test assertion budgets + configPath: .github/lighthouse-assertions.json # test assertion budgets budgetPath: .github/lighthouse-budget.json # test performance budgets uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage From 1ab075c26b795fe86982888eac78f5d1f5687b0e Mon Sep 17 00:00:00 2001 From: Barry Date: Sat, 31 Oct 2020 09:39:09 +0000 Subject: [PATCH 04/59] Fix config --- .github/lighthouse/lighthouse-assertions.json | 6 +++--- .github/workflows/test_website.yml | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/lighthouse/lighthouse-assertions.json b/.github/lighthouse/lighthouse-assertions.json index 712f67f6623..f70a024d8a2 100644 --- a/.github/lighthouse/lighthouse-assertions.json +++ b/.github/lighthouse/lighthouse-assertions.json @@ -2,11 +2,11 @@ "ci": { "assert": { "assertions": { - "categories:performance": ["warn", {"minScore": 0.9}], + "categories:performance": ["warn", {"minScore": 0.88}, "error", {"minScore": 0.85}], "categories:accessibility": ["error", {"minScore": 1}], "categories:best-practice": ["error", {"minScore": 1}], - "categories:seo": ["error", {"minScore": 1}], - "categories:pwa": ["error", {"minScore": 1}] + "categories:seo": ["error", {"minScore": 0.86}], + "categories:pwa": ["error", {"minScore": 0.50}] } } } diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 4dfa4d610ab..20e2791dddd 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -32,12 +32,12 @@ jobs: run: ./src/tools/scripts/run_and_test_website.sh - name: Remove node modules to avoid linting errors run: rm -rf src/node_modules - - name: Lint Generated HTML - uses: github/super-linter@v3.13.2 - env: - DEFAULT_BRANCH: main - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VALIDATE_HTML: true + #- name: Lint Generated HTML + # uses: github/super-linter@v3.13.2 + # env: + # DEFAULT_BRANCH: main + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # VALIDATE_HTML: true - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v3 with: @@ -45,7 +45,7 @@ jobs: http://127.0.0.1:8080/en/2019/ http://127.0.0.1:8080/en/2019/css http://127.0.0.1:8080/en/2020/ - configPath: .github/lighthouse-assertions.json # test assertion budgets - budgetPath: .github/lighthouse-budget.json # test performance budgets + configPath: .github/lighthhouse/lighthouse-assertions.json # test assertions + budgetPath: .github/lighthhouse/lighthouse-budget.json # test performance budgets uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage From e2e7a4edb221b090756c7d203fedf72db846ccb0 Mon Sep 17 00:00:00 2001 From: Barry Date: Sat, 31 Oct 2020 09:42:07 +0000 Subject: [PATCH 05/59] Fix typo --- .github/workflows/test_website.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 20e2791dddd..b2cca27b96f 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -45,7 +45,7 @@ jobs: http://127.0.0.1:8080/en/2019/ http://127.0.0.1:8080/en/2019/css http://127.0.0.1:8080/en/2020/ - configPath: .github/lighthhouse/lighthouse-assertions.json # test assertions - budgetPath: .github/lighthhouse/lighthouse-budget.json # test performance budgets + configPath: .github/lighthouse/lighthouse-assertions.json # test assertions + budgetPath: .github/lighthouse/lighthouse-budget.json # test performance budgets uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage From 0c1f48fe2c7f74662e0daf1a52d080bd752985ef Mon Sep 17 00:00:00 2001 From: Barry Date: Sat, 31 Oct 2020 09:45:21 +0000 Subject: [PATCH 06/59] Better Budgets --- .github/lighthouse/lighthouse-budget.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/lighthouse/lighthouse-budget.json b/.github/lighthouse/lighthouse-budget.json index 02f3b0b685d..195d80aeb84 100644 --- a/.github/lighthouse/lighthouse-budget.json +++ b/.github/lighthouse/lighthouse-budget.json @@ -4,13 +4,13 @@ "resourceSizes": [ { "resourceType": "total", - "budget": 200 + "budget": 500 } ], "resourceCounts": [ { "resourceType": "third-party", - "budget": 10 + "budget": 15 } ] } From 4d9c797cf84934b08adce1a46e83c65a98404ec6 Mon Sep 17 00:00:00 2001 From: Barry Date: Sat, 31 Oct 2020 09:52:33 +0000 Subject: [PATCH 07/59] Revert temp changes for testing --- .github/workflows/test_website.yml | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index b2cca27b96f..1559e4f9d76 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -13,31 +13,31 @@ jobs: build: name: Build and Test Website runs-on: ubuntu-latest - if: github.repository == 'bazzadp/almanac.httparchive.org' + if: github.repository == 'HTTPArchive/almanac.httparchive.org' steps: - - name: Checkout branch - uses: actions/checkout@v2.3.3 - with: - # Full git history is needed to get a proper list of changed files within `super-linter` - fetch-depth: 0 - - name: Setup Node.js for use with actions - uses: actions/setup-node@v1.4.2 - with: - node-version: 12.x - - name: Set up Python 3.8 - uses: actions/setup-python@v2.1.4 - with: - python-version: '3.8' - - name: Run the website - run: ./src/tools/scripts/run_and_test_website.sh - - name: Remove node modules to avoid linting errors - run: rm -rf src/node_modules - #- name: Lint Generated HTML - # uses: github/super-linter@v3.13.2 - # env: - # DEFAULT_BRANCH: main - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # VALIDATE_HTML: true + - name: Checkout branch + uses: actions/checkout@v2.3.3 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 + - name: Setup Node.js for use with actions + uses: actions/setup-node@v1.4.2 + with: + node-version: 12.x + - name: Set up Python 3.8 + uses: actions/setup-python@v2.1.4 + with: + python-version: '3.8' + - name: Run the website + run: ./src/tools/scripts/run_and_test_website.sh + - name: Remove node modules to avoid linting errors + run: rm -rf src/node_modules + - name: Lint Generated HTML + uses: github/super-linter@v3.13.2 + env: + DEFAULT_BRANCH: main + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_HTML: true - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v3 with: From 2657be973d3eaada9f72cc5b1092f027eea8a203 Mon Sep 17 00:00:00 2001 From: Barry Date: Sat, 31 Oct 2020 09:54:21 +0000 Subject: [PATCH 08/59] Fix YAML --- .github/workflows/test_website.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 1559e4f9d76..14ac7240abd 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -38,14 +38,14 @@ jobs: DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_HTML: true - - name: Audit URLs using Lighthouse - uses: treosh/lighthouse-ci-action@v3 - with: - urls: | - http://127.0.0.1:8080/en/2019/ - http://127.0.0.1:8080/en/2019/css - http://127.0.0.1:8080/en/2020/ - configPath: .github/lighthouse/lighthouse-assertions.json # test assertions - budgetPath: .github/lighthouse/lighthouse-budget.json # test performance budgets - uploadArtifacts: true # save results as an action artifacts - temporaryPublicStorage: true # upload lighthouse report to the temporary storage + - name: Audit URLs using Lighthouse + uses: treosh/lighthouse-ci-action@v3 + with: + urls: | + http://127.0.0.1:8080/en/2019/ + http://127.0.0.1:8080/en/2019/css + http://127.0.0.1:8080/en/2020/ + configPath: .github/lighthouse/lighthouse-assertions.json # test assertions + budgetPath: .github/lighthouse/lighthouse-budget.json # test performance budgets + uploadArtifacts: true # save results as an action artifacts + temporaryPublicStorage: true # upload lighthouse report to the temporary storage From 7db18e0c8b97b29682db37225019fc549dd682d9 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 10:38:21 +0000 Subject: [PATCH 09/59] Make list of URLs dynamic --- ...assertions.json => lighthouse-config.json} | 0 .github/workflows/test_website.yml | 8 +- src/tools/scripts/set_lighthouse_urls.sh | 94 +++++++++++++++++++ 3 files changed, 97 insertions(+), 5 deletions(-) rename .github/lighthouse/{lighthouse-assertions.json => lighthouse-config.json} (100%) create mode 100755 src/tools/scripts/set_lighthouse_urls.sh diff --git a/.github/lighthouse/lighthouse-assertions.json b/.github/lighthouse/lighthouse-config.json similarity index 100% rename from .github/lighthouse/lighthouse-assertions.json rename to .github/lighthouse/lighthouse-config.json diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 14ac7240abd..b7ee24cf90b 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -38,14 +38,12 @@ jobs: DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_HTML: true + - name: Set the list of URLs to check + run: ./src/tools/scripts/set_lightouse_urls.sh - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v3 with: - urls: | - http://127.0.0.1:8080/en/2019/ - http://127.0.0.1:8080/en/2019/css - http://127.0.0.1:8080/en/2020/ - configPath: .github/lighthouse/lighthouse-assertions.json # test assertions + configPath: .github/lighthouse/lighthouse-config.json # test assertions budgetPath: .github/lighthouse/lighthouse-budget.json # test performance budgets uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh new file mode 100755 index 00000000000..ac2e8354b9f --- /dev/null +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# exit when any command fails instead of trying to continue on +set -e + +LIGHTHOUSE_CONFIG_FILE="../.github/lighthouse/lighthouse-config.json" + +# Usage info +show_help() { +cat << EOF +Usage: ${0##*/} [-p] +Get a list of URLs to run a lighthouse test on + + -h display this help and exit + -p get all production URLs from sitemap.xml +EOF +} + +OPTIND=1 # Reseting is good practive +production=0 +while getopts "h?p" opt; do + case "$opt" in + h|\?) + show_help + exit 0 + ;; + p) production=1 + ;; + esac +done +shift "$((OPTIND-1))" # Discard the options and sentinel -- + +# This script must be run from src directory +if [ -d "src" ]; then + cd src || exit +fi + +SED_FLAGS=(-i -e) +if [ "$(uname)" = "Darwin" ]; then + echo "Running MacOS" + SED_FLAGS=(-i "" -e) +fi + +LIGHTHOUSE_URLS="" + +# Set some URLs that should always be checked on pull requests +# to ensure basic coverage +BASE_URLS=$(cat <<-END + http://localhost:8080/en/2019/ + http://localhost:8080/en/2019/css + http://localhost:8080/en/2020/ +END +) +# Strip spaces +BASE_URLS=$(echo "${BASE_URLS}" | sed 's/ *//g') + +if [ "${production}" == "1" ]; then + # Get the production URLs from the production sitemap + LIGHTHOUSE_URLS=$(curl -s https://almanac.httparchive.org/sitemap.xml | grep "//g' | sed 's/<\/loc>//g') +elif [ "${COMMIT_SHA}" != "" ]; then + # If this is part of pull request then get list of files as those changed + CHANGED_FILES=$(git diff-tree --diff-filter=AM --no-commit-id --name-only -r "${COMMIT_SHA}" "content/") + LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/localhost:8080/g' ) + if [ "${LIGHTHOUSE_URLS}" = "" ]; then + LIGHTHOUSE_URLS="${BASE_URLS}" + else + LIGHTHOUSE_URLS=$( echo -e "${LIGHTHOUSE_URLS}\n${BASE_URLS}") + fi +else + # Else test every URL (except PDFs) in sitemap + LIGHTHOUSE_URLS=$(grep loc templates/sitemap.xml | grep -v static | sed 's/ *//g' | sed 's/<\/loc>//g' | sed 's/https:\/\/almanac.httparchive.org/http:\/\/localhost/g') +fi + +# Format the URLs for the lighthouse config: +LIGHTHOUSE_URLS=$(echo "${LIGHTHOUSE_URLS}" | sed 's/^/ "/' | sed 's/$/",/') +LIGHTHOUSE_URLS=${LIGHTHOUSE_URLS:0:${#LIGHTHOUSE_URLS}-1} + +# Take all but the first two lines of the existing config +# So as to maintain assertions +LIGHTHOUSE_CONFIG=$(cat ${LIGHTHOUSE_CONFIG_FILE} | sed 1,2d) + +# +cat > "${LIGHTHOUSE_CONFIG_FILE}" << END_CONFIG +{ + "ci": { + "collect": { + "url": [ +${LIGHTHOUSE_URLS} + ] + }, +${LIGHTHOUSE_CONFIG} +END_CONFIG + +#echo 'LIGHTHOUSE_URLS="${LIGHTHOUSE_URLS}"' >> $GITHUB_ENV From 864ea0c7ce55c5f002c99c2a94425fcc46ff722c Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 10:42:30 +0000 Subject: [PATCH 10/59] Aloow testing on this repo --- .github/workflows/test_website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index b7ee24cf90b..66a5075fb50 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -13,7 +13,7 @@ jobs: build: name: Build and Test Website runs-on: ubuntu-latest - if: github.repository == 'HTTPArchive/almanac.httparchive.org' + if: github.repository == 'bazzadp/almanac.httparchive.org' steps: - name: Checkout branch uses: actions/checkout@v2.3.3 From f44826161251f46df4e99ad86a4f3a4b9b488835 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 10:43:05 +0000 Subject: [PATCH 11/59] Linting errors --- src/tools/scripts/set_lighthouse_urls.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index ac2e8354b9f..82cf251f4fb 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -35,12 +35,6 @@ if [ -d "src" ]; then cd src || exit fi -SED_FLAGS=(-i -e) -if [ "$(uname)" = "Darwin" ]; then - echo "Running MacOS" - SED_FLAGS=(-i "" -e) -fi - LIGHTHOUSE_URLS="" # Set some URLs that should always be checked on pull requests From 76a19ac1949433be313a33eb497b7b9e30ca9202 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 10:53:16 +0000 Subject: [PATCH 12/59] Bug fixes and linting errors --- .github/workflows/test_website.yml | 2 +- src/tools/scripts/set_lighthouse_urls.sh | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 66a5075fb50..9ab33ab1fdb 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -39,7 +39,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_HTML: true - name: Set the list of URLs to check - run: ./src/tools/scripts/set_lightouse_urls.sh + run: ./src/tools/scripts/set_lighthouse_urls.sh - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v3 with: diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index 82cf251f4fb..7b405c9ba71 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -45,8 +45,6 @@ BASE_URLS=$(cat <<-END http://localhost:8080/en/2020/ END ) -# Strip spaces -BASE_URLS=$(echo "${BASE_URLS}" | sed 's/ *//g') if [ "${production}" == "1" ]; then # Get the production URLs from the production sitemap @@ -66,12 +64,12 @@ else fi # Format the URLs for the lighthouse config: -LIGHTHOUSE_URLS=$(echo "${LIGHTHOUSE_URLS}" | sed 's/^/ "/' | sed 's/$/",/') +LIGHTHOUSE_URLS=$(echo "${LIGHTHOUSE_URLS}" | sed 's/^ */ "/' | sed 's/$/",/') LIGHTHOUSE_URLS=${LIGHTHOUSE_URLS:0:${#LIGHTHOUSE_URLS}-1} # Take all but the first two lines of the existing config # So as to maintain assertions -LIGHTHOUSE_CONFIG=$(cat ${LIGHTHOUSE_CONFIG_FILE} | sed 1,2d) +LIGHTHOUSE_CONFIG=$(sed "1,2d" ${LIGHTHOUSE_CONFIG_FILE}) # cat > "${LIGHTHOUSE_CONFIG_FILE}" << END_CONFIG From 7885671dc7e055339f56f34e131fb8c2c4ad0513 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 11:03:51 +0000 Subject: [PATCH 13/59] Bug fixes --- .github/workflows/test_website.yml | 3 +++ src/tools/scripts/set_lighthouse_urls.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 9ab33ab1fdb..a05f57acfbe 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -36,9 +36,12 @@ jobs: uses: github/super-linter@v3.13.2 env: DEFAULT_BRANCH: main + FILTER_REGEX_INCLUDE: src/static/html/.* GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_HTML: true - name: Set the list of URLs to check + env: + COMMIT_SHA: ${{ github.sha }} run: ./src/tools/scripts/set_lighthouse_urls.sh - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v3 diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index 7b405c9ba71..f1ae58d33f9 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -60,7 +60,7 @@ elif [ "${COMMIT_SHA}" != "" ]; then fi else # Else test every URL (except PDFs) in sitemap - LIGHTHOUSE_URLS=$(grep loc templates/sitemap.xml | grep -v static | sed 's/ *//g' | sed 's/<\/loc>//g' | sed 's/https:\/\/almanac.httparchive.org/http:\/\/localhost/g') + LIGHTHOUSE_URLS=$(grep loc templates/sitemap.xml | grep -v static | sed 's/ *//g' | sed 's/<\/loc>//g' | sed 's/https:\/\/almanac.httparchive.org/http:\/\/localhost:8080/g') fi # Format the URLs for the lighthouse config: From 1313ba3457b341c2ce387c51fd65e716e317d3ad Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 12:09:57 +0000 Subject: [PATCH 14/59] Add production tests and fix bugs --- ...budget.json => lighthouse-budget-dev.json} | 0 .../lighthouse/lighthouse-budget-prod.json | 17 ++++++++++ ...config.json => lighthouse-config-dev.json} | 0 .../lighthouse/lighthouse-config-prod.json | 13 +++++++ .github/workflows/production_checks.yml | 34 +++++++++++++++++++ .github/workflows/test_website.yml | 5 +-- src/tools/scripts/set_lighthouse_urls.sh | 10 +++--- 7 files changed, 72 insertions(+), 7 deletions(-) rename .github/lighthouse/{lighthouse-budget.json => lighthouse-budget-dev.json} (100%) create mode 100644 .github/lighthouse/lighthouse-budget-prod.json rename .github/lighthouse/{lighthouse-config.json => lighthouse-config-dev.json} (100%) create mode 100644 .github/lighthouse/lighthouse-config-prod.json create mode 100644 .github/workflows/production_checks.yml diff --git a/.github/lighthouse/lighthouse-budget.json b/.github/lighthouse/lighthouse-budget-dev.json similarity index 100% rename from .github/lighthouse/lighthouse-budget.json rename to .github/lighthouse/lighthouse-budget-dev.json diff --git a/.github/lighthouse/lighthouse-budget-prod.json b/.github/lighthouse/lighthouse-budget-prod.json new file mode 100644 index 00000000000..195d80aeb84 --- /dev/null +++ b/.github/lighthouse/lighthouse-budget-prod.json @@ -0,0 +1,17 @@ +[ + { + "path": "/*", + "resourceSizes": [ + { + "resourceType": "total", + "budget": 500 + } + ], + "resourceCounts": [ + { + "resourceType": "third-party", + "budget": 15 + } + ] + } +] diff --git a/.github/lighthouse/lighthouse-config.json b/.github/lighthouse/lighthouse-config-dev.json similarity index 100% rename from .github/lighthouse/lighthouse-config.json rename to .github/lighthouse/lighthouse-config-dev.json diff --git a/.github/lighthouse/lighthouse-config-prod.json b/.github/lighthouse/lighthouse-config-prod.json new file mode 100644 index 00000000000..ad382bb2816 --- /dev/null +++ b/.github/lighthouse/lighthouse-config-prod.json @@ -0,0 +1,13 @@ +{ + "ci": { + "assert": { + "assertions": { + "categories:performance": ["warn", {"minScore": 0.92}, "error", {"minScore": 0.9}], + "categories:accessibility": ["error", {"minScore": 1}], + "categories:best-practice": ["error", {"minScore": 1}], + "categories:seo": ["error", {"minScore": 1}], + "categories:pwa": ["error", {"minScore": 0.50}] + } + } + } +} diff --git a/.github/workflows/production_checks.yml b/.github/workflows/production_checks.yml new file mode 100644 index 00000000000..6f09c1c9800 --- /dev/null +++ b/.github/workflows/production_checks.yml @@ -0,0 +1,34 @@ +###################################### +## Custom Web Almanac GitHub action ## +###################################### +# +# Run checks against the production website +# +name: Production Checks +on: + workflow_dispatch: + schedule: + # ┌───────────── minute (0 - 59) + # │ ┌───────────── hour (0 - 23) + # │ │ ┌───────────── day of the month (1 - 31) + # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) + # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) + # │ │ │ │ │ + # │ │ │ │ │ + # │ │ │ │ │ + # * * * * * + - cron: '30 1 * * 0' +jobs: + checks: + runs-on: ubuntu-latest + if: github.repository == 'bazzadp/almanac.httparchive.org' + steps: + - name: Set the list of URLs to check + run: ./src/tools/scripts/set_lighthouse_urls.sh -p + - name: Audit URLs using Lighthouse + uses: treosh/lighthouse-ci-action@v3 + with: + configPath: .github/lighthouse/lighthouse-config-prod.json # test assertions + budgetPath: .github/lighthouse/lighthouse-budget-prod.json # test performance budgets + uploadArtifacts: true # save results as an action artifacts + temporaryPublicStorage: true # upload lighthouse report to the temporary storage diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index a05f57acfbe..4b27ed05606 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -41,12 +41,13 @@ jobs: VALIDATE_HTML: true - name: Set the list of URLs to check env: + RUN_TYPE: ${{ github.event_name }} COMMIT_SHA: ${{ github.sha }} run: ./src/tools/scripts/set_lighthouse_urls.sh - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v3 with: - configPath: .github/lighthouse/lighthouse-config.json # test assertions - budgetPath: .github/lighthouse/lighthouse-budget.json # test performance budgets + configPath: .github/lighthouse/lighthouse-config-dev.json # test assertions + budgetPath: .github/lighthouse/lighthouse-budget-dev.json # test performance budgets uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index f1ae58d33f9..b419a62c873 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -3,7 +3,8 @@ # exit when any command fails instead of trying to continue on set -e -LIGHTHOUSE_CONFIG_FILE="../.github/lighthouse/lighthouse-config.json" +LIGHTHOUSE_CONFIG_FILE="../.github/lighthouse/lighthouse-config-dev.json" +LIGHTHOUSE_PROD_CONFIG_FILE="../.github/lighthouse/lighthouse-config-prod.json" # Usage info show_help() { @@ -49,7 +50,8 @@ END if [ "${production}" == "1" ]; then # Get the production URLs from the production sitemap LIGHTHOUSE_URLS=$(curl -s https://almanac.httparchive.org/sitemap.xml | grep "//g' | sed 's/<\/loc>//g') -elif [ "${COMMIT_SHA}" != "" ]; then + LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" +elif [ "RUN_TYPE" != "workflow_dispatch" && "${COMMIT_SHA}" != "" ]; then # If this is part of pull request then get list of files as those changed CHANGED_FILES=$(git diff-tree --diff-filter=AM --no-commit-id --name-only -r "${COMMIT_SHA}" "content/") LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/localhost:8080/g' ) @@ -71,7 +73,7 @@ LIGHTHOUSE_URLS=${LIGHTHOUSE_URLS:0:${#LIGHTHOUSE_URLS}-1} # So as to maintain assertions LIGHTHOUSE_CONFIG=$(sed "1,2d" ${LIGHTHOUSE_CONFIG_FILE}) -# +# Write the new config file - inclduing the URLs cat > "${LIGHTHOUSE_CONFIG_FILE}" << END_CONFIG { "ci": { @@ -82,5 +84,3 @@ ${LIGHTHOUSE_URLS} }, ${LIGHTHOUSE_CONFIG} END_CONFIG - -#echo 'LIGHTHOUSE_URLS="${LIGHTHOUSE_URLS}"' >> $GITHUB_ENV From c21b7c575d1b948ab9e79895d56c891ca34bdeeb Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 12:17:21 +0000 Subject: [PATCH 15/59] Linting fixes and outputs --- .github/workflows/production_checks.yml | 3 +++ .github/workflows/test_website.yml | 3 +++ src/tools/scripts/set_lighthouse_urls.sh | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/production_checks.yml b/.github/workflows/production_checks.yml index 6f09c1c9800..f66f5d92e71 100644 --- a/.github/workflows/production_checks.yml +++ b/.github/workflows/production_checks.yml @@ -27,8 +27,11 @@ jobs: run: ./src/tools/scripts/set_lighthouse_urls.sh -p - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v3 + id: LHCIAction with: configPath: .github/lighthouse/lighthouse-config-prod.json # test assertions budgetPath: .github/lighthouse/lighthouse-budget-prod.json # test performance budgets uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage + - name: Show Lighthouse outputs + run: echo ${{steps.LHCIAction.outputs.manifest}} diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 4b27ed05606..226d447414f 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -46,8 +46,11 @@ jobs: run: ./src/tools/scripts/set_lighthouse_urls.sh - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v3 + id: LHCIAction with: configPath: .github/lighthouse/lighthouse-config-dev.json # test assertions budgetPath: .github/lighthouse/lighthouse-budget-dev.json # test performance budgets uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage + - name: Show Lighthouse outputs + run: echo ${{steps.LHCIAction.outputs.manifest}} diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index b419a62c873..52e91c3dfa4 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -51,7 +51,7 @@ if [ "${production}" == "1" ]; then # Get the production URLs from the production sitemap LIGHTHOUSE_URLS=$(curl -s https://almanac.httparchive.org/sitemap.xml | grep "//g' | sed 's/<\/loc>//g') LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" -elif [ "RUN_TYPE" != "workflow_dispatch" && "${COMMIT_SHA}" != "" ]; then +elif [ "${RUN_TYPE}" != "workflow_dispatch" && "${COMMIT_SHA}" != "" ]; then # If this is part of pull request then get list of files as those changed CHANGED_FILES=$(git diff-tree --diff-filter=AM --no-commit-id --name-only -r "${COMMIT_SHA}" "content/") LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/localhost:8080/g' ) From 38903e2b6ab11921c181fb3dc4249f5d9d3e9796 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 12:20:31 +0000 Subject: [PATCH 16/59] Linting fixes --- src/tools/scripts/set_lighthouse_urls.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index 52e91c3dfa4..981ff3118a0 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -51,7 +51,7 @@ if [ "${production}" == "1" ]; then # Get the production URLs from the production sitemap LIGHTHOUSE_URLS=$(curl -s https://almanac.httparchive.org/sitemap.xml | grep "//g' | sed 's/<\/loc>//g') LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" -elif [ "${RUN_TYPE}" != "workflow_dispatch" && "${COMMIT_SHA}" != "" ]; then +elif [ "${RUN_TYPE}" != "workflow_dispatch" ] && [ "${COMMIT_SHA}" != "" ]; then # If this is part of pull request then get list of files as those changed CHANGED_FILES=$(git diff-tree --diff-filter=AM --no-commit-id --name-only -r "${COMMIT_SHA}" "content/") LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/localhost:8080/g' ) From b0944284a23504bdb0ce72376b20781c4b502fe0 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 12:42:22 +0000 Subject: [PATCH 17/59] Assert fixes --- .github/lighthouse/lighthouse-config-dev.json | 4 ++-- .github/lighthouse/lighthouse-config-prod.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index f70a024d8a2..11eb1ee7de5 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -2,9 +2,9 @@ "ci": { "assert": { "assertions": { - "categories:performance": ["warn", {"minScore": 0.88}, "error", {"minScore": 0.85}], + "categories:performance": ["error", {"minScore": 0.85}], "categories:accessibility": ["error", {"minScore": 1}], - "categories:best-practice": ["error", {"minScore": 1}], + "categories:best-practice": ["error", {"minScore": 0.93}], "categories:seo": ["error", {"minScore": 0.86}], "categories:pwa": ["error", {"minScore": 0.50}] } diff --git a/.github/lighthouse/lighthouse-config-prod.json b/.github/lighthouse/lighthouse-config-prod.json index ad382bb2816..b690830d9e6 100644 --- a/.github/lighthouse/lighthouse-config-prod.json +++ b/.github/lighthouse/lighthouse-config-prod.json @@ -2,7 +2,7 @@ "ci": { "assert": { "assertions": { - "categories:performance": ["warn", {"minScore": 0.92}, "error", {"minScore": 0.9}], + "categories:performance": ["error", {"minScore": 0.9}], "categories:accessibility": ["error", {"minScore": 1}], "categories:best-practice": ["error", {"minScore": 1}], "categories:seo": ["error", {"minScore": 1}], From 7d21800e6066e9be734730869b873ee287065c89 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 12:50:47 +0000 Subject: [PATCH 18/59] Remove budgets to test assertions only --- .github/workflows/test_website.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 226d447414f..b3c37bead1e 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -49,7 +49,6 @@ jobs: id: LHCIAction with: configPath: .github/lighthouse/lighthouse-config-dev.json # test assertions - budgetPath: .github/lighthouse/lighthouse-budget-dev.json # test performance budgets uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs From 50592562933ff465749e52aace0be037cfd829f0 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 13:04:27 +0000 Subject: [PATCH 19/59] Remove budgets as prevent assertions working --- .github/lighthouse/lighthouse-budget-dev.json | 17 ----------------- .github/lighthouse/lighthouse-budget-prod.json | 17 ----------------- .github/lighthouse/lighthouse-config-dev.json | 5 ++--- .github/lighthouse/lighthouse-config-prod.json | 2 +- .github/workflows/production_checks.yml | 1 - 5 files changed, 3 insertions(+), 39 deletions(-) delete mode 100644 .github/lighthouse/lighthouse-budget-dev.json delete mode 100644 .github/lighthouse/lighthouse-budget-prod.json diff --git a/.github/lighthouse/lighthouse-budget-dev.json b/.github/lighthouse/lighthouse-budget-dev.json deleted file mode 100644 index 195d80aeb84..00000000000 --- a/.github/lighthouse/lighthouse-budget-dev.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "path": "/*", - "resourceSizes": [ - { - "resourceType": "total", - "budget": 500 - } - ], - "resourceCounts": [ - { - "resourceType": "third-party", - "budget": 15 - } - ] - } -] diff --git a/.github/lighthouse/lighthouse-budget-prod.json b/.github/lighthouse/lighthouse-budget-prod.json deleted file mode 100644 index 195d80aeb84..00000000000 --- a/.github/lighthouse/lighthouse-budget-prod.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "path": "/*", - "resourceSizes": [ - { - "resourceType": "total", - "budget": 500 - } - ], - "resourceCounts": [ - { - "resourceType": "third-party", - "budget": 15 - } - ] - } -] diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index 11eb1ee7de5..a4e847a026b 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -2,9 +2,8 @@ "ci": { "assert": { "assertions": { - "categories:performance": ["error", {"minScore": 0.85}], - "categories:accessibility": ["error", {"minScore": 1}], - "categories:best-practice": ["error", {"minScore": 0.93}], + "categories:accessibility": ["error", {"minScore": 0.98}], + "categories:best-practices": ["error", {"minScore": 0.93}], "categories:seo": ["error", {"minScore": 0.86}], "categories:pwa": ["error", {"minScore": 0.50}] } diff --git a/.github/lighthouse/lighthouse-config-prod.json b/.github/lighthouse/lighthouse-config-prod.json index b690830d9e6..8d0f412c002 100644 --- a/.github/lighthouse/lighthouse-config-prod.json +++ b/.github/lighthouse/lighthouse-config-prod.json @@ -4,7 +4,7 @@ "assertions": { "categories:performance": ["error", {"minScore": 0.9}], "categories:accessibility": ["error", {"minScore": 1}], - "categories:best-practice": ["error", {"minScore": 1}], + "categories:best-practices": ["error", {"minScore": 1}], "categories:seo": ["error", {"minScore": 1}], "categories:pwa": ["error", {"minScore": 0.50}] } diff --git a/.github/workflows/production_checks.yml b/.github/workflows/production_checks.yml index f66f5d92e71..f823e87416f 100644 --- a/.github/workflows/production_checks.yml +++ b/.github/workflows/production_checks.yml @@ -30,7 +30,6 @@ jobs: id: LHCIAction with: configPath: .github/lighthouse/lighthouse-config-prod.json # test assertions - budgetPath: .github/lighthouse/lighthouse-budget-prod.json # test performance budgets uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs From 898bd6389538f0033c2874d964ae94bcc6e3b4c2 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 13:24:13 +0000 Subject: [PATCH 20/59] Switch from using localhost to fix errors --- .github/lighthouse/lighthouse-config-dev.json | 4 ++-- src/tools/scripts/set_lighthouse_urls.sh | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index a4e847a026b..e7cc0e50b1f 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -2,8 +2,8 @@ "ci": { "assert": { "assertions": { - "categories:accessibility": ["error", {"minScore": 0.98}], - "categories:best-practices": ["error", {"minScore": 0.93}], + "categories:accessibility": ["error", {"minScore": 1}], + "categories:best-practices": ["error", {"minScore": 1}], "categories:seo": ["error", {"minScore": 0.86}], "categories:pwa": ["error", {"minScore": 0.50}] } diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index 981ff3118a0..ad64bd20cc9 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -41,9 +41,9 @@ LIGHTHOUSE_URLS="" # Set some URLs that should always be checked on pull requests # to ensure basic coverage BASE_URLS=$(cat <<-END - http://localhost:8080/en/2019/ - http://localhost:8080/en/2019/css - http://localhost:8080/en/2020/ + http://127.0.0.1:8080/en/2019/ + http://127.0.0.1:8080/en/2019/css + http://127.0.0.1:8080/en/2020/ END ) @@ -54,7 +54,7 @@ if [ "${production}" == "1" ]; then elif [ "${RUN_TYPE}" != "workflow_dispatch" ] && [ "${COMMIT_SHA}" != "" ]; then # If this is part of pull request then get list of files as those changed CHANGED_FILES=$(git diff-tree --diff-filter=AM --no-commit-id --name-only -r "${COMMIT_SHA}" "content/") - LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/localhost:8080/g' ) + LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' ) if [ "${LIGHTHOUSE_URLS}" = "" ]; then LIGHTHOUSE_URLS="${BASE_URLS}" else @@ -62,7 +62,7 @@ elif [ "${RUN_TYPE}" != "workflow_dispatch" ] && [ "${COMMIT_SHA}" != "" ]; then fi else # Else test every URL (except PDFs) in sitemap - LIGHTHOUSE_URLS=$(grep loc templates/sitemap.xml | grep -v static | sed 's/ *//g' | sed 's/<\/loc>//g' | sed 's/https:\/\/almanac.httparchive.org/http:\/\/localhost:8080/g') + LIGHTHOUSE_URLS=$(grep loc templates/sitemap.xml | grep -v static | sed 's/ *//g' | sed 's/<\/loc>//g' | sed 's/https:\/\/almanac.httparchive.org/http:\/\/127.0.0.1:8080/g') fi # Format the URLs for the lighthouse config: From 8d2050727b051992b9e88c9bf29613187fe89b99 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 13:40:24 +0000 Subject: [PATCH 21/59] Tidy up --- ...ction_checks.yml => production-checks.yml} | 24 +++++++++---------- src/tools/scripts/set_lighthouse_urls.sh | 9 ++++--- 2 files changed, 18 insertions(+), 15 deletions(-) rename .github/workflows/{production_checks.yml => production-checks.yml} (61%) diff --git a/.github/workflows/production_checks.yml b/.github/workflows/production-checks.yml similarity index 61% rename from .github/workflows/production_checks.yml rename to .github/workflows/production-checks.yml index f823e87416f..b0ea112a8d5 100644 --- a/.github/workflows/production_checks.yml +++ b/.github/workflows/production-checks.yml @@ -6,7 +6,6 @@ # name: Production Checks on: - workflow_dispatch: schedule: # ┌───────────── minute (0 - 59) # │ ┌───────────── hour (0 - 23) @@ -18,19 +17,20 @@ on: # │ │ │ │ │ # * * * * * - cron: '30 1 * * 0' + workflow_dispatch: jobs: checks: runs-on: ubuntu-latest if: github.repository == 'bazzadp/almanac.httparchive.org' steps: - - name: Set the list of URLs to check - run: ./src/tools/scripts/set_lighthouse_urls.sh -p - - name: Audit URLs using Lighthouse - uses: treosh/lighthouse-ci-action@v3 - id: LHCIAction - with: - configPath: .github/lighthouse/lighthouse-config-prod.json # test assertions - uploadArtifacts: true # save results as an action artifacts - temporaryPublicStorage: true # upload lighthouse report to the temporary storage - - name: Show Lighthouse outputs - run: echo ${{steps.LHCIAction.outputs.manifest}} + - name: Set the list of URLs to check + run: ./src/tools/scripts/set_lighthouse_urls.sh -p + - name: Audit URLs using Lighthouse + uses: treosh/lighthouse-ci-action@v3 + id: LHCIAction + with: + configPath: .github/lighthouse/lighthouse-config-prod.json # test assertions + uploadArtifacts: true # save results as an action artifacts + temporaryPublicStorage: true # upload lighthouse report to the temporary storage + - name: Show Lighthouse outputs + run: echo ${{steps.LHCIAction.outputs.manifest}} diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index ad64bd20cc9..92f1dcc7021 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -41,9 +41,9 @@ LIGHTHOUSE_URLS="" # Set some URLs that should always be checked on pull requests # to ensure basic coverage BASE_URLS=$(cat <<-END - http://127.0.0.1:8080/en/2019/ - http://127.0.0.1:8080/en/2019/css - http://127.0.0.1:8080/en/2020/ +http://127.0.0.1:8080/en/2019/ +http://127.0.0.1:8080/en/2019/css +http://127.0.0.1:8080/en/2020/ END ) @@ -65,6 +65,9 @@ else LIGHTHOUSE_URLS=$(grep loc templates/sitemap.xml | grep -v static | sed 's/ *//g' | sed 's/<\/loc>//g' | sed 's/https:\/\/almanac.httparchive.org/http:\/\/127.0.0.1:8080/g') fi +echo "URLS to check:" +echo "${LIGHTHOUSE_URLS}" + # Format the URLs for the lighthouse config: LIGHTHOUSE_URLS=$(echo "${LIGHTHOUSE_URLS}" | sed 's/^ */ "/' | sed 's/$/",/') LIGHTHOUSE_URLS=${LIGHTHOUSE_URLS:0:${#LIGHTHOUSE_URLS}-1} From 0c3263d9439cce1e1ec9ab77f3a5e4c16e5181f5 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 13:41:46 +0000 Subject: [PATCH 22/59] Change production job to run at 13:45 on Sunday --- .github/workflows/production-checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/production-checks.yml b/.github/workflows/production-checks.yml index b0ea112a8d5..a9de2951c43 100644 --- a/.github/workflows/production-checks.yml +++ b/.github/workflows/production-checks.yml @@ -16,7 +16,7 @@ on: # │ │ │ │ │ # │ │ │ │ │ # * * * * * - - cron: '30 1 * * 0' + - cron: '45 13 * * 0' workflow_dispatch: jobs: checks: From d3485e299b7d562a36d02b1c355ed39a544527d7 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 14:08:25 +0000 Subject: [PATCH 23/59] Better formatting --- .github/workflows/production-checks.yml | 4 +++- .github/workflows/test_website.yml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/production-checks.yml b/.github/workflows/production-checks.yml index a9de2951c43..a746d7246ea 100644 --- a/.github/workflows/production-checks.yml +++ b/.github/workflows/production-checks.yml @@ -33,4 +33,6 @@ jobs: uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs - run: echo ${{steps.LHCIAction.outputs.manifest}} + run: | + # All results by URL: + echo ${{ steps.LHCIAction.outputs.manifest }} | jq -r '.[] | (.summary|tostring) + " for " + .url' diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index b3c37bead1e..0b9e1ae4419 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -52,4 +52,6 @@ jobs: uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs - run: echo ${{steps.LHCIAction.outputs.manifest}} + run: | + # All results by URL: + echo ${{ steps.LHCIAction.outputs.manifest }} | jq -r '.[] | (.summary|tostring) + " for " + .url' From ce53e24db20638772244172ae781eb0eaff77c9b Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 14:18:56 +0000 Subject: [PATCH 24/59] Syntax fix --- .github/workflows/production-checks.yml | 4 ++-- .github/workflows/test_website.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/production-checks.yml b/.github/workflows/production-checks.yml index a746d7246ea..f6706eedae5 100644 --- a/.github/workflows/production-checks.yml +++ b/.github/workflows/production-checks.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'bazzadp/almanac.httparchive.org' steps: - - name: Set the list of URLs to check + - name: Set the list of URLs for Lighthouse to check run: ./src/tools/scripts/set_lighthouse_urls.sh -p - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v3 @@ -35,4 +35,4 @@ jobs: - name: Show Lighthouse outputs run: | # All results by URL: - echo ${{ steps.LHCIAction.outputs.manifest }} | jq -r '.[] | (.summary|tostring) + " for " + .url' + echo ${{steps.LHCIAction.outputs.manifest}} | jq -r ".[] | (.summary|tostring) + \" for \" + .url" diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 0b9e1ae4419..dd97cef5c2c 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -39,7 +39,7 @@ jobs: FILTER_REGEX_INCLUDE: src/static/html/.* GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_HTML: true - - name: Set the list of URLs to check + - name: Set the list of URLs for Lighthouse to check env: RUN_TYPE: ${{ github.event_name }} COMMIT_SHA: ${{ github.sha }} @@ -54,4 +54,4 @@ jobs: - name: Show Lighthouse outputs run: | # All results by URL: - echo ${{ steps.LHCIAction.outputs.manifest }} | jq -r '.[] | (.summary|tostring) + " for " + .url' + echo ${{ steps.LHCIAction.outputs.manifest }} | jq -r "[] | (.summary|tostring) + \" for \" + .url" From 844f1b67223b1ad9e2414f6c5786f3d4b8b5889d Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 14:28:50 +0000 Subject: [PATCH 25/59] JQ syntax fix --- .github/workflows/test_website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index dd97cef5c2c..c48dee09856 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -54,4 +54,4 @@ jobs: - name: Show Lighthouse outputs run: | # All results by URL: - echo ${{ steps.LHCIAction.outputs.manifest }} | jq -r "[] | (.summary|tostring) + \" for \" + .url" + echo ${{ steps.LHCIAction.outputs.manifest }} | jq -r "(.[].summary|tostring) + \" for \" + .[].url" From 5695c395f04f62bb0f62946ab76c04190149ac5e Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 14:36:39 +0000 Subject: [PATCH 26/59] More jq fun --- .github/workflows/test_website.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index c48dee09856..03e318ecca7 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -32,13 +32,13 @@ jobs: run: ./src/tools/scripts/run_and_test_website.sh - name: Remove node modules to avoid linting errors run: rm -rf src/node_modules - - name: Lint Generated HTML - uses: github/super-linter@v3.13.2 - env: - DEFAULT_BRANCH: main - FILTER_REGEX_INCLUDE: src/static/html/.* - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VALIDATE_HTML: true + #- name: Lint Generated HTML + # uses: github/super-linter@v3.13.2 + # DEFAULT_BRANCH: main + # env: + # FILTER_REGEX_INCLUDE: src/static/html/.* + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # VALIDATE_HTML: true - name: Set the list of URLs for Lighthouse to check env: RUN_TYPE: ${{ github.event_name }} @@ -53,5 +53,4 @@ jobs: temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs run: | - # All results by URL: - echo ${{ steps.LHCIAction.outputs.manifest }} | jq -r "(.[].summary|tostring) + \" for \" + .[].url" + echo ${{ steps.LHCIAction.outputs.manifest }} | jq From 2922f45c36c8ff94d8c586817d37b162b275bd8d Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 14:43:19 +0000 Subject: [PATCH 27/59] Getting there with jq --- .github/workflows/test_website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 03e318ecca7..39063bcb391 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -53,4 +53,4 @@ jobs: temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs run: | - echo ${{ steps.LHCIAction.outputs.manifest }} | jq + echo '${{ steps.LHCIAction.outputs.manifest }}' | jq From b36b25da3e89bcf3fa5ba4eb2ebdee1b339ce3b6 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 14:48:16 +0000 Subject: [PATCH 28/59] Why is jq so annoying --- .github/workflows/test_website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 39063bcb391..166948c469f 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -53,4 +53,4 @@ jobs: temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs run: | - echo '${{ steps.LHCIAction.outputs.manifest }}' | jq + echo '${{ steps.LHCIAction.outputs.manifest }}' | jq -r ".[]" From f64573b468790e77047366a6e0fdc1a6998f52f3 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 14:53:48 +0000 Subject: [PATCH 29/59] jq formatioing --- .github/workflows/test_website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 166948c469f..42640e4c9a1 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -53,4 +53,4 @@ jobs: temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs run: | - echo '${{ steps.LHCIAction.outputs.manifest }}' | jq -r ".[]" + echo '${{ steps.LHCIAction.outputs.manifest }}' | jq -r "(.[].summary|tostring) + \" - \" + .[].url" From 451340ad999e92343c63edccea80251184e93a87 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 14:58:07 +0000 Subject: [PATCH 30/59] JQ fixes --- .github/workflows/test_website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 42640e4c9a1..91daefb42d9 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -53,4 +53,4 @@ jobs: temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs run: | - echo '${{ steps.LHCIAction.outputs.manifest }}' | jq -r "(.[].summary|tostring) + \" - \" + .[].url" + echo '${{ steps.LHCIAction.outputs.manifest }}' | jq -r ".[] | (.summary|tostring) + \" - \" + .url" From c4242fe30fc3a962adaa1bf53e1a754a80121900 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 15:06:16 +0000 Subject: [PATCH 31/59] Tidy up --- .github/workflows/production-checks.yml | 2 +- .github/workflows/test_website.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/production-checks.yml b/.github/workflows/production-checks.yml index f6706eedae5..d722ba37d65 100644 --- a/.github/workflows/production-checks.yml +++ b/.github/workflows/production-checks.yml @@ -35,4 +35,4 @@ jobs: - name: Show Lighthouse outputs run: | # All results by URL: - echo ${{steps.LHCIAction.outputs.manifest}} | jq -r ".[] | (.summary|tostring) + \" for \" + .url" + echo '${{ steps.LHCIAction.outputs.manifest }}' | jq -r '.[] | (.summary|tostring) + " - " + .url' diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 91daefb42d9..4edcaaea83a 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -53,4 +53,4 @@ jobs: temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs run: | - echo '${{ steps.LHCIAction.outputs.manifest }}' | jq -r ".[] | (.summary|tostring) + \" - \" + .url" + echo '${{ steps.LHCIAction.outputs.manifest }}' | jq -r '.[] | (.summary|tostring) + " - " + .url' From 78f90ea001fadcd437c17e7b64da0619d7a5c342 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 15:26:09 +0000 Subject: [PATCH 32/59] Better scores --- .github/lighthouse/lighthouse-config-dev.json | 3 +-- .github/lighthouse/lighthouse-config-prod.json | 3 +-- .github/workflows/production-checks.yml | 2 +- .github/workflows/test_website.yml | 16 ++++++++-------- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index e7cc0e50b1f..fc98a78ba34 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -4,8 +4,7 @@ "assertions": { "categories:accessibility": ["error", {"minScore": 1}], "categories:best-practices": ["error", {"minScore": 1}], - "categories:seo": ["error", {"minScore": 0.86}], - "categories:pwa": ["error", {"minScore": 0.50}] + "categories:seo": ["error", {"minScore": 0.85}] } } } diff --git a/.github/lighthouse/lighthouse-config-prod.json b/.github/lighthouse/lighthouse-config-prod.json index 8d0f412c002..981a73cd6a9 100644 --- a/.github/lighthouse/lighthouse-config-prod.json +++ b/.github/lighthouse/lighthouse-config-prod.json @@ -5,8 +5,7 @@ "categories:performance": ["error", {"minScore": 0.9}], "categories:accessibility": ["error", {"minScore": 1}], "categories:best-practices": ["error", {"minScore": 1}], - "categories:seo": ["error", {"minScore": 1}], - "categories:pwa": ["error", {"minScore": 0.50}] + "categories:seo": ["error", {"minScore": 1}] } } } diff --git a/.github/workflows/production-checks.yml b/.github/workflows/production-checks.yml index d722ba37d65..c01323bbe86 100644 --- a/.github/workflows/production-checks.yml +++ b/.github/workflows/production-checks.yml @@ -26,7 +26,7 @@ jobs: - name: Set the list of URLs for Lighthouse to check run: ./src/tools/scripts/set_lighthouse_urls.sh -p - name: Audit URLs using Lighthouse - uses: treosh/lighthouse-ci-action@v3 + uses: treosh/lighthouse-ci-action@v3.1.0 id: LHCIAction with: configPath: .github/lighthouse/lighthouse-config-prod.json # test assertions diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 4edcaaea83a..b162e340daf 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -32,20 +32,20 @@ jobs: run: ./src/tools/scripts/run_and_test_website.sh - name: Remove node modules to avoid linting errors run: rm -rf src/node_modules - #- name: Lint Generated HTML - # uses: github/super-linter@v3.13.2 - # DEFAULT_BRANCH: main - # env: - # FILTER_REGEX_INCLUDE: src/static/html/.* - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # VALIDATE_HTML: true + - name: Lint Generated HTML + uses: github/super-linter@v3.13.2 + DEFAULT_BRANCH: main + env: + FILTER_REGEX_INCLUDE: src/static/html/.* + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_HTML: true - name: Set the list of URLs for Lighthouse to check env: RUN_TYPE: ${{ github.event_name }} COMMIT_SHA: ${{ github.sha }} run: ./src/tools/scripts/set_lighthouse_urls.sh - name: Audit URLs using Lighthouse - uses: treosh/lighthouse-ci-action@v3 + uses: treosh/lighthouse-ci-action@v3.1.0 id: LHCIAction with: configPath: .github/lighthouse/lighthouse-config-dev.json # test assertions From 9c831b53285e416400d0cb796e5efb643b516152 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 15:29:06 +0000 Subject: [PATCH 33/59] Typo --- .github/workflows/test_website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index b162e340daf..30dac9c5cd3 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -34,8 +34,8 @@ jobs: run: rm -rf src/node_modules - name: Lint Generated HTML uses: github/super-linter@v3.13.2 - DEFAULT_BRANCH: main env: + DEFAULT_BRANCH: main FILTER_REGEX_INCLUDE: src/static/html/.* GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_HTML: true From 3b87c9e9affcde598152e5e05726aa6cd388a80f Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 15:31:10 +0000 Subject: [PATCH 34/59] Version fixes --- .github/workflows/production-checks.yml | 2 +- .github/workflows/test_website.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/production-checks.yml b/.github/workflows/production-checks.yml index c01323bbe86..cfb070ac197 100644 --- a/.github/workflows/production-checks.yml +++ b/.github/workflows/production-checks.yml @@ -26,7 +26,7 @@ jobs: - name: Set the list of URLs for Lighthouse to check run: ./src/tools/scripts/set_lighthouse_urls.sh -p - name: Audit URLs using Lighthouse - uses: treosh/lighthouse-ci-action@v3.1.0 + uses: treosh/lighthouse-ci-action@3.1.0 id: LHCIAction with: configPath: .github/lighthouse/lighthouse-config-prod.json # test assertions diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 30dac9c5cd3..de2e2d21f34 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -45,7 +45,7 @@ jobs: COMMIT_SHA: ${{ github.sha }} run: ./src/tools/scripts/set_lighthouse_urls.sh - name: Audit URLs using Lighthouse - uses: treosh/lighthouse-ci-action@v3.1.0 + uses: treosh/lighthouse-ci-action@3.1.0 id: LHCIAction with: configPath: .github/lighthouse/lighthouse-config-dev.json # test assertions From f46e484de2b7058292e5879648ef32d1d262633d Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 15:40:06 +0000 Subject: [PATCH 35/59] Fix version numbers --- .github/workflows/production-checks.yml | 2 +- .github/workflows/test_website.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/production-checks.yml b/.github/workflows/production-checks.yml index cfb070ac197..d722ba37d65 100644 --- a/.github/workflows/production-checks.yml +++ b/.github/workflows/production-checks.yml @@ -26,7 +26,7 @@ jobs: - name: Set the list of URLs for Lighthouse to check run: ./src/tools/scripts/set_lighthouse_urls.sh -p - name: Audit URLs using Lighthouse - uses: treosh/lighthouse-ci-action@3.1.0 + uses: treosh/lighthouse-ci-action@v3 id: LHCIAction with: configPath: .github/lighthouse/lighthouse-config-prod.json # test assertions diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index de2e2d21f34..3b2e063ceef 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -45,7 +45,7 @@ jobs: COMMIT_SHA: ${{ github.sha }} run: ./src/tools/scripts/set_lighthouse_urls.sh - name: Audit URLs using Lighthouse - uses: treosh/lighthouse-ci-action@3.1.0 + uses: treosh/lighthouse-ci-action@v3 id: LHCIAction with: configPath: .github/lighthouse/lighthouse-config-dev.json # test assertions From 32e103a5f347e0e35e0d5e54e917ce160097932b Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 16:09:28 +0000 Subject: [PATCH 36/59] Correct Accessinility Issues in ES CSS chapter --- src/content/es/2019/css.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/es/2019/css.md b/src/content/es/2019/css.md index 452f410b032..4f39b300477 100644 --- a/src/content/es/2019/css.md +++ b/src/content/es/2019/css.md @@ -100,7 +100,7 @@ Como era de esperar, en la Figura 2.5, `px` es el tipo de unidad más utilizado, Cuando se trata de unidades basadas en el espacio físico, la unidad `cm` (or centímetros) es la más popular por mucho, seguida por `in` (pulgadas), y luego por `Q`.Sabemos que este tipo de unidades son específicamente útiles para imprimir hojas de estilo, ¡pero ni siquiera sabíamos que la unidad `Q` existía hasta esta encuesta! ¿Sabías? -

Una versión anterior de este capítulo discutia la inesperada popularidad de la unidadQ. Gracias a la discusión de la comunidad alrededor de este capítulo, hemos identificado que esto fue un error en nuestro análisis y hemos actualizado la Figura 2.5 en consecuencia.

+

Una versión anterior de este capítulo discutia la inesperada popularidad de la unidadQ. Gracias a la discusión de la comunidad alrededor de este capítulo, hemos identificado que esto fue un error en nuestro análisis y hemos actualizado la Figura 2.5 en consecuencia.

### Unidades basadas en el viewport From 7e7b674b9af0f2b8e635cdfd0c02dab08bde2983 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 16:10:14 +0000 Subject: [PATCH 37/59] Test run against production --- .github/workflows/test_website.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 3b2e063ceef..7838565d67c 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -43,12 +43,12 @@ jobs: env: RUN_TYPE: ${{ github.event_name }} COMMIT_SHA: ${{ github.sha }} - run: ./src/tools/scripts/set_lighthouse_urls.sh + run: ./src/tools/scripts/set_lighthouse_urls.sh -p - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v3 id: LHCIAction with: - configPath: .github/lighthouse/lighthouse-config-dev.json # test assertions + configPath: .github/lighthouse/lighthouse-config-prod.json # test assertions uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs From b3b7ad5530e05cfedf190d07d67b7d769cd81812 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 17:38:13 +0000 Subject: [PATCH 38/59] Misc fixes --- .github/lighthouse/lighthouse-config-dev.json | 2 +- .github/lighthouse/lighthouse-config-prod.json | 1 - .github/workflows/test_website.yml | 4 ++-- src/static/css/page.css | 1 + src/tools/scripts/set_lighthouse_urls.sh | 5 +++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index fc98a78ba34..1f9f9a8b3ee 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -4,7 +4,7 @@ "assertions": { "categories:accessibility": ["error", {"minScore": 1}], "categories:best-practices": ["error", {"minScore": 1}], - "categories:seo": ["error", {"minScore": 0.85}] + "categories:seo": ["error", {"minScore": 0.86}] } } } diff --git a/.github/lighthouse/lighthouse-config-prod.json b/.github/lighthouse/lighthouse-config-prod.json index 981a73cd6a9..a3ed17a2604 100644 --- a/.github/lighthouse/lighthouse-config-prod.json +++ b/.github/lighthouse/lighthouse-config-prod.json @@ -2,7 +2,6 @@ "ci": { "assert": { "assertions": { - "categories:performance": ["error", {"minScore": 0.9}], "categories:accessibility": ["error", {"minScore": 1}], "categories:best-practices": ["error", {"minScore": 1}], "categories:seo": ["error", {"minScore": 1}] diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 7838565d67c..3b2e063ceef 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -43,12 +43,12 @@ jobs: env: RUN_TYPE: ${{ github.event_name }} COMMIT_SHA: ${{ github.sha }} - run: ./src/tools/scripts/set_lighthouse_urls.sh -p + run: ./src/tools/scripts/set_lighthouse_urls.sh - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v3 id: LHCIAction with: - configPath: .github/lighthouse/lighthouse-config-prod.json # test assertions + configPath: .github/lighthouse/lighthouse-config-dev.json # test assertions uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs diff --git a/src/static/css/page.css b/src/static/css/page.css index ac1de01721d..0e05c2e4601 100644 --- a/src/static/css/page.css +++ b/src/static/css/page.css @@ -165,6 +165,7 @@ .content ul li { list-style: none; + margin: 5px 0; } .content ul li::before { diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index 92f1dcc7021..6e2ed2d77e4 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -53,8 +53,9 @@ if [ "${production}" == "1" ]; then LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" elif [ "${RUN_TYPE}" != "workflow_dispatch" ] && [ "${COMMIT_SHA}" != "" ]; then # If this is part of pull request then get list of files as those changed - CHANGED_FILES=$(git diff-tree --diff-filter=AM --no-commit-id --name-only -r "${COMMIT_SHA}" "content/") - LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' ) + CHANGED_FILES=$(git diff-tree --diff-filter=AM --no-commit-id --name-only -r "${COMMIT_SHA}" content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) + + LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' | sed 's/\.md//g' | sed 's/\/base\//\/en\//g' | sed 's/src\/templates/http:\/\/127.0.0.1:8080/g' | sed 's/\.html//g' | sed 's/_/-/g' | sed 's/\/2019\/accessibility-statement/\/accessibility-statement/g' ) if [ "${LIGHTHOUSE_URLS}" = "" ]; then LIGHTHOUSE_URLS="${BASE_URLS}" else From b4fabf660e79a7c18012ef8bc71511ecd8fc682e Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 20:50:47 +0000 Subject: [PATCH 39/59] Test run --- src/static/css/page.css | 5 ++++- src/tools/scripts/set_lighthouse_urls.sh | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/static/css/page.css b/src/static/css/page.css index 0e05c2e4601..79b94fd97de 100644 --- a/src/static/css/page.css +++ b/src/static/css/page.css @@ -165,7 +165,6 @@ .content ul li { list-style: none; - margin: 5px 0; } .content ul li::before { @@ -648,6 +647,10 @@ figure .fig-desktop { .anchor-link:focus::before { content: ''; } + + .content ul li { + padding: 6px 0; + } } /* Code highlighting */ diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index 6e2ed2d77e4..ee979db51c8 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -42,7 +42,9 @@ LIGHTHOUSE_URLS="" # to ensure basic coverage BASE_URLS=$(cat <<-END http://127.0.0.1:8080/en/2019/ -http://127.0.0.1:8080/en/2019/css +http://127.0.0.1:8080/en/2019/javascript +http://127.0.0.1:8080/en/2019/mobile-web +http://127.0.0.1:8080/en/2019/seo http://127.0.0.1:8080/en/2020/ END ) @@ -54,7 +56,7 @@ if [ "${production}" == "1" ]; then elif [ "${RUN_TYPE}" != "workflow_dispatch" ] && [ "${COMMIT_SHA}" != "" ]; then # If this is part of pull request then get list of files as those changed CHANGED_FILES=$(git diff-tree --diff-filter=AM --no-commit-id --name-only -r "${COMMIT_SHA}" content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) - + LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' | sed 's/\.md//g' | sed 's/\/base\//\/en\//g' | sed 's/src\/templates/http:\/\/127.0.0.1:8080/g' | sed 's/\.html//g' | sed 's/_/-/g' | sed 's/\/2019\/accessibility-statement/\/accessibility-statement/g' ) if [ "${LIGHTHOUSE_URLS}" = "" ]; then LIGHTHOUSE_URLS="${BASE_URLS}" From 7321403e5036e3db4bc0d18cc92c0642320bea9c Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Sun, 1 Nov 2020 21:06:58 +0000 Subject: [PATCH 40/59] Update set_lighthouse_urls.sh --- src/tools/scripts/set_lighthouse_urls.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index ee979db51c8..36781451536 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -3,18 +3,20 @@ # exit when any command fails instead of trying to continue on set -e +echo "Setting Lighthouse URLs" + LIGHTHOUSE_CONFIG_FILE="../.github/lighthouse/lighthouse-config-dev.json" LIGHTHOUSE_PROD_CONFIG_FILE="../.github/lighthouse/lighthouse-config-prod.json" # Usage info show_help() { -cat << EOF +cat << EOH Usage: ${0##*/} [-p] Get a list of URLs to run a lighthouse test on -h display this help and exit -p get all production URLs from sitemap.xml -EOF +EOH } OPTIND=1 # Reseting is good practive From 0f678652eec491017384e33e56953d64cf66db80 Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Sun, 1 Nov 2020 21:14:53 +0000 Subject: [PATCH 41/59] Update set_lighthouse_urls.sh --- src/tools/scripts/set_lighthouse_urls.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index 36781451536..ec1e291e047 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -3,7 +3,8 @@ # exit when any command fails instead of trying to continue on set -e -echo "Setting Lighthouse URLs" +# debug +set -x LIGHTHOUSE_CONFIG_FILE="../.github/lighthouse/lighthouse-config-dev.json" LIGHTHOUSE_PROD_CONFIG_FILE="../.github/lighthouse/lighthouse-config-prod.json" From 9366bbb7c7e571042e42f1bf948308c30ba5d4e4 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 21:49:02 +0000 Subject: [PATCH 42/59] Fixes --- .github/lighthouse/lighthouse-config-dev.json | 5 ++++- src/tools/scripts/set_lighthouse_urls.sh | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index 1f9f9a8b3ee..b11f5109631 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -2,9 +2,12 @@ "ci": { "assert": { "assertions": { + "canonical": "off", + "is-crawlable": "off", + "is-on-https:": "off", "categories:accessibility": ["error", {"minScore": 1}], "categories:best-practices": ["error", {"minScore": 1}], - "categories:seo": ["error", {"minScore": 0.86}] + "categories:seo": ["error", {"minScore": 1}] } } } diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index ec1e291e047..dc5e18859ef 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -1,8 +1,5 @@ #!/bin/bash -# exit when any command fails instead of trying to continue on -set -e - # debug set -x @@ -58,7 +55,7 @@ if [ "${production}" == "1" ]; then LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" elif [ "${RUN_TYPE}" != "workflow_dispatch" ] && [ "${COMMIT_SHA}" != "" ]; then # If this is part of pull request then get list of files as those changed - CHANGED_FILES=$(git diff-tree --diff-filter=AM --no-commit-id --name-only -r "${COMMIT_SHA}" content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) + CHANGED_FILES=$(git diff-tree --diff-filter=AM --no-commit-id --name-only "main...${COMMIT_SHA}" content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' | sed 's/\.md//g' | sed 's/\/base\//\/en\//g' | sed 's/src\/templates/http:\/\/127.0.0.1:8080/g' | sed 's/\.html//g' | sed 's/_/-/g' | sed 's/\/2019\/accessibility-statement/\/accessibility-statement/g' ) if [ "${LIGHTHOUSE_URLS}" = "" ]; then From 9f44782cabf69f395a98ac682300cc1e9b24a019 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 21:57:30 +0000 Subject: [PATCH 43/59] Better audits --- .github/lighthouse/lighthouse-config-dev.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index b11f5109631..734c4dc3aea 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -1,13 +1,11 @@ { "ci": { "assert": { + "preset": "lighthouse:no-pwa", "assertions": { "canonical": "off", "is-crawlable": "off", - "is-on-https:": "off", - "categories:accessibility": ["error", {"minScore": 1}], - "categories:best-practices": ["error", {"minScore": 1}], - "categories:seo": ["error", {"minScore": 1}] + "is-on-https:": "off" } } } From 986b01f94fc66e9c3409cfb96ef5f08a77c34372 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 22:07:30 +0000 Subject: [PATCH 44/59] Better audits --- .github/lighthouse/lighthouse-config-dev.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index 734c4dc3aea..5aa296be6b7 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -5,7 +5,14 @@ "assertions": { "canonical": "off", "is-crawlable": "off", - "is-on-https:": "off" + "is-on-https:": "off", + "unminified-css": "off", + "unminified-javascript": "off", + "unused-css-rules": "off", + "uses-rel-preconnect": "off", + "uses-text-compression": "off", + "uses-responsive-images": "off", + "font-display": "off" } } } From 07821924f8cb274fd4118ee170b894985abfe846 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 22:16:11 +0000 Subject: [PATCH 45/59] Tweak audits --- .github/lighthouse/lighthouse-config-dev.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index 5aa296be6b7..1589f755cb7 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -4,15 +4,16 @@ "preset": "lighthouse:no-pwa", "assertions": { "canonical": "off", + "font-display": "off", "is-crawlable": "off", "is-on-https:": "off", "unminified-css": "off", "unminified-javascript": "off", "unused-css-rules": "off", + "unused-javascript": "off", "uses-rel-preconnect": "off", "uses-text-compression": "off", - "uses-responsive-images": "off", - "font-display": "off" + "uses-responsive-images": "off" } } } From 190d8c7ce03f6692e16609bae265b4d425af3109 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 22:44:41 +0000 Subject: [PATCH 46/59] Testing --- src/static/css/page.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/static/css/page.css b/src/static/css/page.css index 79b94fd97de..ac1de01721d 100644 --- a/src/static/css/page.css +++ b/src/static/css/page.css @@ -647,10 +647,6 @@ figure .fig-desktop { .anchor-link:focus::before { content: ''; } - - .content ul li { - padding: 6px 0; - } } /* Code highlighting */ From b5d14d919d03b9be0b5e5a818c05a00a8d7c87c7 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 22:54:49 +0000 Subject: [PATCH 47/59] Address tap issues --- src/static/css/page.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/static/css/page.css b/src/static/css/page.css index ac1de01721d..5471221d99d 100644 --- a/src/static/css/page.css +++ b/src/static/css/page.css @@ -647,6 +647,10 @@ figure .fig-desktop { .anchor-link:focus::before { content: ''; } + + .content ul li { + padding: 5px 0; + } } /* Code highlighting */ From 380e5c2bc04b528206bb2e2f127a72ad9aad6536 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 23:11:29 +0000 Subject: [PATCH 48/59] Improved git diff --- src/tools/scripts/set_lighthouse_urls.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index dc5e18859ef..a3fe00d0ee9 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -43,8 +43,6 @@ LIGHTHOUSE_URLS="" BASE_URLS=$(cat <<-END http://127.0.0.1:8080/en/2019/ http://127.0.0.1:8080/en/2019/javascript -http://127.0.0.1:8080/en/2019/mobile-web -http://127.0.0.1:8080/en/2019/seo http://127.0.0.1:8080/en/2020/ END ) @@ -55,7 +53,7 @@ if [ "${production}" == "1" ]; then LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" elif [ "${RUN_TYPE}" != "workflow_dispatch" ] && [ "${COMMIT_SHA}" != "" ]; then # If this is part of pull request then get list of files as those changed - CHANGED_FILES=$(git diff-tree --diff-filter=AM --no-commit-id --name-only "main...${COMMIT_SHA}" content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) + CHANGED_FILES=$(git diff --diff-filter=AM --no-commit-id --name-only main content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' | sed 's/\.md//g' | sed 's/\/base\//\/en\//g' | sed 's/src\/templates/http:\/\/127.0.0.1:8080/g' | sed 's/\.html//g' | sed 's/_/-/g' | sed 's/\/2019\/accessibility-statement/\/accessibility-statement/g' ) if [ "${LIGHTHOUSE_URLS}" = "" ]; then From 86c5bfa922b04d8768fc2a1f0cafa76843c46862 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 23:24:37 +0000 Subject: [PATCH 49/59] Diff --- src/tools/scripts/set_lighthouse_urls.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index a3fe00d0ee9..7a6e73042b2 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -53,7 +53,7 @@ if [ "${production}" == "1" ]; then LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" elif [ "${RUN_TYPE}" != "workflow_dispatch" ] && [ "${COMMIT_SHA}" != "" ]; then # If this is part of pull request then get list of files as those changed - CHANGED_FILES=$(git diff --diff-filter=AM --no-commit-id --name-only main content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) + CHANGED_FILES=$(git diff-tree --diff-filter=d --no-commit-id --name-only "main...${GITHUB_SHA}" content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' | sed 's/\.md//g' | sed 's/\/base\//\/en\//g' | sed 's/src\/templates/http:\/\/127.0.0.1:8080/g' | sed 's/\.html//g' | sed 's/_/-/g' | sed 's/\/2019\/accessibility-statement/\/accessibility-statement/g' ) if [ "${LIGHTHOUSE_URLS}" = "" ]; then From 79f1d15b32f60a39799dbcc173514c53d4576e40 Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 23:36:32 +0000 Subject: [PATCH 50/59] Better diff --- src/tools/scripts/set_lighthouse_urls.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index 7a6e73042b2..6a07ad1c830 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -53,7 +53,7 @@ if [ "${production}" == "1" ]; then LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" elif [ "${RUN_TYPE}" != "workflow_dispatch" ] && [ "${COMMIT_SHA}" != "" ]; then # If this is part of pull request then get list of files as those changed - CHANGED_FILES=$(git diff-tree --diff-filter=d --no-commit-id --name-only "main...${GITHUB_SHA}" content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) + CHANGED_FILES=$(git diff --diff-filter=d --no-commit-id --name-only "main...${GITHUB_SHA}" content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' | sed 's/\.md//g' | sed 's/\/base\//\/en\//g' | sed 's/src\/templates/http:\/\/127.0.0.1:8080/g' | sed 's/\.html//g' | sed 's/_/-/g' | sed 's/\/2019\/accessibility-statement/\/accessibility-statement/g' ) if [ "${LIGHTHOUSE_URLS}" = "" ]; then From afc118fea74b359ba7ca1ee12660f5e1b3e35dcf Mon Sep 17 00:00:00 2001 From: Barry Date: Sun, 1 Nov 2020 23:58:41 +0000 Subject: [PATCH 51/59] Better diffs --- .github/lighthouse/lighthouse-config-dev.json | 5 +++++ src/tools/scripts/set_lighthouse_urls.sh | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index 1589f755cb7..3098e808f94 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -5,13 +5,18 @@ "assertions": { "canonical": "off", "font-display": "off", + "interactive": "off", "is-crawlable": "off", "is-on-https:": "off", + "largest-contentful-paint": "off", + "render-blocking-resources": "off", "unminified-css": "off", "unminified-javascript": "off", "unused-css-rules": "off", "unused-javascript": "off", + "uses-long-cache-ttl": "off", "uses-rel-preconnect": "off", + "uses-rel-preload": "off", "uses-text-compression": "off", "uses-responsive-images": "off" } diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index 6a07ad1c830..e421a1001aa 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -51,9 +51,12 @@ if [ "${production}" == "1" ]; then # Get the production URLs from the production sitemap LIGHTHOUSE_URLS=$(curl -s https://almanac.httparchive.org/sitemap.xml | grep "//g' | sed 's/<\/loc>//g') LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" -elif [ "${RUN_TYPE}" != "workflow_dispatch" ] && [ "${COMMIT_SHA}" != "" ]; then +elif [ "${RUN_TYPE}" == "pull_request" ] && [ "${COMMIT_SHA}" != "" ]; then + git pull quiet + git checkout main # If this is part of pull request then get list of files as those changed - CHANGED_FILES=$(git diff --diff-filter=d --no-commit-id --name-only "main...${GITHUB_SHA}" content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) + CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) + git checkout --progress --force "${COMMIT_SHA}" LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' | sed 's/\.md//g' | sed 's/\/base\//\/en\//g' | sed 's/src\/templates/http:\/\/127.0.0.1:8080/g' | sed 's/\.html//g' | sed 's/_/-/g' | sed 's/\/2019\/accessibility-statement/\/accessibility-statement/g' ) if [ "${LIGHTHOUSE_URLS}" = "" ]; then @@ -74,7 +77,7 @@ LIGHTHOUSE_URLS=$(echo "${LIGHTHOUSE_URLS}" | sed 's/^ */ "/' | sed 's/ LIGHTHOUSE_URLS=${LIGHTHOUSE_URLS:0:${#LIGHTHOUSE_URLS}-1} # Take all but the first two lines of the existing config -# So as to maintain assertions +# so as to maintain assertions LIGHTHOUSE_CONFIG=$(sed "1,2d" ${LIGHTHOUSE_CONFIG_FILE}) # Write the new config file - inclduing the URLs From 25bad979545c291a626101c3302699b0c4d3fb45 Mon Sep 17 00:00:00 2001 From: Barry Date: Mon, 2 Nov 2020 00:04:50 +0000 Subject: [PATCH 52/59] Bug fixes --- .github/workflows/test_website.yml | 14 +++++++------- src/tools/scripts/set_lighthouse_urls.sh | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 3b2e063ceef..636f1c85528 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -32,13 +32,13 @@ jobs: run: ./src/tools/scripts/run_and_test_website.sh - name: Remove node modules to avoid linting errors run: rm -rf src/node_modules - - name: Lint Generated HTML - uses: github/super-linter@v3.13.2 - env: - DEFAULT_BRANCH: main - FILTER_REGEX_INCLUDE: src/static/html/.* - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VALIDATE_HTML: true + #- name: Lint Generated HTML + # uses: github/super-linter@v3.13.2 + # env: + # DEFAULT_BRANCH: main + # FILTER_REGEX_INCLUDE: src/static/html/.* + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # VALIDATE_HTML: true - name: Set the list of URLs for Lighthouse to check env: RUN_TYPE: ${{ github.event_name }} diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index e421a1001aa..d6c5ef3b00c 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -52,7 +52,7 @@ if [ "${production}" == "1" ]; then LIGHTHOUSE_URLS=$(curl -s https://almanac.httparchive.org/sitemap.xml | grep "//g' | sed 's/<\/loc>//g') LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" elif [ "${RUN_TYPE}" == "pull_request" ] && [ "${COMMIT_SHA}" != "" ]; then - git pull quiet + git pull --quiet git checkout main # If this is part of pull request then get list of files as those changed CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) From b9db6bc8327a026477fc86fc5f632b3698a77776 Mon Sep 17 00:00:00 2001 From: Barry Date: Mon, 2 Nov 2020 00:06:03 +0000 Subject: [PATCH 53/59] Bug fix --- src/tools/scripts/set_lighthouse_urls.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index d6c5ef3b00c..ff3a98facaa 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -55,7 +55,7 @@ elif [ "${RUN_TYPE}" == "pull_request" ] && [ "${COMMIT_SHA}" != "" ]; then git pull --quiet git checkout main # If this is part of pull request then get list of files as those changed - CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) + CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" --diff-filter=d content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) git checkout --progress --force "${COMMIT_SHA}" LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' | sed 's/\.md//g' | sed 's/\/base\//\/en\//g' | sed 's/src\/templates/http:\/\/127.0.0.1:8080/g' | sed 's/\.html//g' | sed 's/_/-/g' | sed 's/\/2019\/accessibility-statement/\/accessibility-statement/g' ) From ca509830701db6a9e77872da97cf65a87a01eab1 Mon Sep 17 00:00:00 2001 From: Barry Date: Mon, 2 Nov 2020 00:11:05 +0000 Subject: [PATCH 54/59] More exclusions --- .github/lighthouse/lighthouse-config-dev.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index 3098e808f94..5d1185c3287 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -4,11 +4,17 @@ "preset": "lighthouse:no-pwa", "assertions": { "canonical": "off", + "dom-size": "off", + "first-contentful-paint": "off", + "first-cpu-idle": "off", + "first-meaningful-paint": "off", "font-display": "off", "interactive": "off", "is-crawlable": "off", "is-on-https:": "off", "largest-contentful-paint": "off", + "mainthread-work-breakdown": "off", + "max-potential-fid": "off", "render-blocking-resources": "off", "unminified-css": "off", "unminified-javascript": "off", From d64d9a90396ef541c208e539b58cf2c700b68d8c Mon Sep 17 00:00:00 2001 From: Barry Date: Mon, 2 Nov 2020 00:27:37 +0000 Subject: [PATCH 55/59] Cleanup --- .github/lighthouse/lighthouse-config-dev.json | 5 ++++- .github/workflows/test_website.yml | 15 ++++++++------- src/tools/scripts/set_lighthouse_urls.sh | 2 ++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/lighthouse/lighthouse-config-dev.json b/.github/lighthouse/lighthouse-config-dev.json index 5d1185c3287..318ac3205c4 100644 --- a/.github/lighthouse/lighthouse-config-dev.json +++ b/.github/lighthouse/lighthouse-config-dev.json @@ -3,6 +3,7 @@ "assert": { "preset": "lighthouse:no-pwa", "assertions": { + "bootup-time": "off", "canonical": "off", "dom-size": "off", "first-contentful-paint": "off", @@ -15,6 +16,7 @@ "largest-contentful-paint": "off", "mainthread-work-breakdown": "off", "max-potential-fid": "off", + "speed-index": "off", "render-blocking-resources": "off", "unminified-css": "off", "unminified-javascript": "off", @@ -24,7 +26,8 @@ "uses-rel-preconnect": "off", "uses-rel-preload": "off", "uses-text-compression": "off", - "uses-responsive-images": "off" + "uses-responsive-images": "off", + "uses-webp-images": "off" } } } diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 636f1c85528..7dff91e5693 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -32,13 +32,13 @@ jobs: run: ./src/tools/scripts/run_and_test_website.sh - name: Remove node modules to avoid linting errors run: rm -rf src/node_modules - #- name: Lint Generated HTML - # uses: github/super-linter@v3.13.2 - # env: - # DEFAULT_BRANCH: main - # FILTER_REGEX_INCLUDE: src/static/html/.* - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # VALIDATE_HTML: true + - name: Lint Generated HTML + uses: github/super-linter@v3.13.2 + env: + DEFAULT_BRANCH: main + FILTER_REGEX_INCLUDE: src/static/html/.* + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_HTML: true - name: Set the list of URLs for Lighthouse to check env: RUN_TYPE: ${{ github.event_name }} @@ -48,6 +48,7 @@ jobs: uses: treosh/lighthouse-ci-action@v3 id: LHCIAction with: + # Note for dev, turn off all perf audits (too unreliable) and a few others configPath: .github/lighthouse/lighthouse-config-dev.json # test assertions uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index ff3a98facaa..f94c13e6102 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -52,10 +52,12 @@ if [ "${production}" == "1" ]; then LIGHTHOUSE_URLS=$(curl -s https://almanac.httparchive.org/sitemap.xml | grep "//g' | sed 's/<\/loc>//g') LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" elif [ "${RUN_TYPE}" == "pull_request" ] && [ "${COMMIT_SHA}" != "" ]; then + # Checkout main to get list of differences git pull --quiet git checkout main # If this is part of pull request then get list of files as those changed CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" --diff-filter=d content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) + # Back to the pull request changes git checkout --progress --force "${COMMIT_SHA}" LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' | sed 's/\.md//g' | sed 's/\/base\//\/en\//g' | sed 's/src\/templates/http:\/\/127.0.0.1:8080/g' | sed 's/\.html//g' | sed 's/_/-/g' | sed 's/\/2019\/accessibility-statement/\/accessibility-statement/g' ) From 0237c9f05a846a0231beb05ef22b908f2d78d83d Mon Sep 17 00:00:00 2001 From: Barry Date: Mon, 2 Nov 2020 23:04:20 +0000 Subject: [PATCH 56/59] Tidy up ready to open upstream --- .github/workflows/production-checks.yml | 30 +++++++++++----------- .github/workflows/test_website.yml | 6 ++--- src/tools/scripts/set_lighthouse_urls.sh | 32 ++++++++++++++++-------- 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/.github/workflows/production-checks.yml b/.github/workflows/production-checks.yml index d722ba37d65..ff0a9c6b7e4 100644 --- a/.github/workflows/production-checks.yml +++ b/.github/workflows/production-checks.yml @@ -21,18 +21,20 @@ on: jobs: checks: runs-on: ubuntu-latest - if: github.repository == 'bazzadp/almanac.httparchive.org' + if: github.repository == 'HTTPArchive/almanac.httparchive.org' steps: - - name: Set the list of URLs for Lighthouse to check - run: ./src/tools/scripts/set_lighthouse_urls.sh -p - - name: Audit URLs using Lighthouse - uses: treosh/lighthouse-ci-action@v3 - id: LHCIAction - with: - configPath: .github/lighthouse/lighthouse-config-prod.json # test assertions - uploadArtifacts: true # save results as an action artifacts - temporaryPublicStorage: true # upload lighthouse report to the temporary storage - - name: Show Lighthouse outputs - run: | - # All results by URL: - echo '${{ steps.LHCIAction.outputs.manifest }}' | jq -r '.[] | (.summary|tostring) + " - " + .url' + - name: Set the list of URLs for Lighthouse to check + run: ./src/tools/scripts/set_lighthouse_urls.sh -p + - name: Audit URLs using Lighthouse + uses: treosh/lighthouse-ci-action@v3 + id: LHCIAction + with: + # For prod, we simply check for 100% in Accessibility, Best Practices and SEO + # We don't check Performance as too much variability and no guarantees on perf in GitHub Actions. + configPath: .github/lighthouse/lighthouse-config-prod.json + uploadArtifacts: true # save results as an action artifacts + temporaryPublicStorage: true # upload lighthouse report to the temporary storage + - name: Show Lighthouse outputs + run: | + # All results by URL: + echo '${{ steps.LHCIAction.outputs.manifest }}' | jq -r '.[] | (.summary|tostring) + " - " + .url' diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 7dff91e5693..1e08d0ea416 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -13,7 +13,7 @@ jobs: build: name: Build and Test Website runs-on: ubuntu-latest - if: github.repository == 'bazzadp/almanac.httparchive.org' + if: github.repository == 'HTTPArchive/almanac.httparchive.org' steps: - name: Checkout branch uses: actions/checkout@v2.3.3 @@ -48,8 +48,8 @@ jobs: uses: treosh/lighthouse-ci-action@v3 id: LHCIAction with: - # Note for dev, turn off all perf audits (too unreliable) and a few others - configPath: .github/lighthouse/lighthouse-config-dev.json # test assertions + # For dev, turn off all timing perf audits (too unreliable) and a few others that don't work on dev + configPath: .github/lighthouse/lighthouse-config-dev.json uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index f94c13e6102..1502757d5f5 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -1,8 +1,5 @@ #!/bin/bash -# debug -set -x - LIGHTHOUSE_CONFIG_FILE="../.github/lighthouse/lighthouse-config-dev.json" LIGHTHOUSE_PROD_CONFIG_FILE="../.github/lighthouse/lighthouse-config-prod.json" @@ -10,7 +7,8 @@ LIGHTHOUSE_PROD_CONFIG_FILE="../.github/lighthouse/lighthouse-config-prod.json" show_help() { cat << EOH Usage: ${0##*/} [-p] -Get a list of URLs to run a lighthouse test on +Get a list of URLs to run a lighthouse test on. +If a commit is given then only URLs changes are tested otherwise all. -h display this help and exit -p get all production URLs from sitemap.xml @@ -48,27 +46,38 @@ END ) if [ "${production}" == "1" ]; then + # Get the production URLs from the production sitemap LIGHTHOUSE_URLS=$(curl -s https://almanac.httparchive.org/sitemap.xml | grep "//g' | sed 's/<\/loc>//g') + + # Switch to the Production Config file LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" + elif [ "${RUN_TYPE}" == "pull_request" ] && [ "${COMMIT_SHA}" != "" ]; then - # Checkout main to get list of differences + + # If this is part of pull request then get list of files as those changed + # Uses similar logic to GitHub Super Linter + # First checkout main to get list of differences git pull --quiet git checkout main - # If this is part of pull request then get list of files as those changed + # Then get the changes CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" --diff-filter=d content templates | grep -v base.html | grep -v ejs | grep -v base_ | grep -v toc.html | grep -v sitemap) - # Back to the pull request changes + # Then back to the pull request changes git checkout --progress --force "${COMMIT_SHA}" + # Transform the files to http://127.0.0.1:8080 URLs LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' | sed 's/\.md//g' | sed 's/\/base\//\/en\//g' | sed 's/src\/templates/http:\/\/127.0.0.1:8080/g' | sed 's/\.html//g' | sed 's/_/-/g' | sed 's/\/2019\/accessibility-statement/\/accessibility-statement/g' ) if [ "${LIGHTHOUSE_URLS}" = "" ]; then LIGHTHOUSE_URLS="${BASE_URLS}" else LIGHTHOUSE_URLS=$( echo -e "${LIGHTHOUSE_URLS}\n${BASE_URLS}") fi + else - # Else test every URL (except PDFs) in sitemap + + # Else test every URL (except PDFs) in the sitemap LIGHTHOUSE_URLS=$(grep loc templates/sitemap.xml | grep -v static | sed 's/ *//g' | sed 's/<\/loc>//g' | sed 's/https:\/\/almanac.httparchive.org/http:\/\/127.0.0.1:8080/g') + fi echo "URLS to check:" @@ -76,13 +85,14 @@ echo "${LIGHTHOUSE_URLS}" # Format the URLs for the lighthouse config: LIGHTHOUSE_URLS=$(echo "${LIGHTHOUSE_URLS}" | sed 's/^ */ "/' | sed 's/$/",/') +# Remove the comma on the last URL LIGHTHOUSE_URLS=${LIGHTHOUSE_URLS:0:${#LIGHTHOUSE_URLS}-1} -# Take all but the first two lines of the existing config -# so as to maintain assertions +# Remove the first two lines form the config +# (we'll insert them again below when adding the URLs) LIGHTHOUSE_CONFIG=$(sed "1,2d" ${LIGHTHOUSE_CONFIG_FILE}) -# Write the new config file - inclduing the URLs +# Write the new config file - including the URLs cat > "${LIGHTHOUSE_CONFIG_FILE}" << END_CONFIG { "ci": { From 2deae7f7a994de50a69c2a68a356c8753d19162f Mon Sep 17 00:00:00 2001 From: Barry Date: Tue, 3 Nov 2020 18:37:50 +0000 Subject: [PATCH 57/59] Review feedback --- .github/workflows/test_website.yml | 1 + src/tools/scripts/set_lighthouse_urls.sh | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_website.yml b/.github/workflows/test_website.yml index 62d3853047d..10308a9ea68 100644 --- a/.github/workflows/test_website.yml +++ b/.github/workflows/test_website.yml @@ -54,4 +54,5 @@ jobs: temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Show Lighthouse outputs run: | + # All results by URL: echo '${{ steps.LHCIAction.outputs.manifest }}' | jq -r '.[] | (.summary|tostring) + " - " + .url' diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index 1502757d5f5..be2d7bf165f 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -48,7 +48,7 @@ END if [ "${production}" == "1" ]; then # Get the production URLs from the production sitemap - LIGHTHOUSE_URLS=$(curl -s https://almanac.httparchive.org/sitemap.xml | grep "//g' | sed 's/<\/loc>//g') + LIGHTHOUSE_URLS=$(curl -s https://almanac.httparchive.org/sitemap.xml | grep "//g' | sed 's/<\/loc>//g') # Switch to the Production Config file LIGHTHOUSE_CONFIG_FILE="${LIGHTHOUSE_PROD_CONFIG_FILE}" @@ -56,7 +56,7 @@ if [ "${production}" == "1" ]; then elif [ "${RUN_TYPE}" == "pull_request" ] && [ "${COMMIT_SHA}" != "" ]; then # If this is part of pull request then get list of files as those changed - # Uses similar logic to GitHub Super Linter + # Uses similar logic to GitHub Super Linter (https://github.com/github/super-linter/blob/master/lib/buildFileList.sh) # First checkout main to get list of differences git pull --quiet git checkout main @@ -67,16 +67,14 @@ elif [ "${RUN_TYPE}" == "pull_request" ] && [ "${COMMIT_SHA}" != "" ]; then # Transform the files to http://127.0.0.1:8080 URLs LIGHTHOUSE_URLS=$(echo "${CHANGED_FILES}" | sed 's/src\/content/http:\/\/127.0.0.1:8080/g' | sed 's/\.md//g' | sed 's/\/base\//\/en\//g' | sed 's/src\/templates/http:\/\/127.0.0.1:8080/g' | sed 's/\.html//g' | sed 's/_/-/g' | sed 's/\/2019\/accessibility-statement/\/accessibility-statement/g' ) - if [ "${LIGHTHOUSE_URLS}" = "" ]; then - LIGHTHOUSE_URLS="${BASE_URLS}" - else - LIGHTHOUSE_URLS=$( echo -e "${LIGHTHOUSE_URLS}\n${BASE_URLS}") - fi + + # Add base URLs and strip out newlines + LIGHTHOUSE_URLS=$(echo -e "${LIGHTHOUSE_URLS}\n${BASE_URLS}" | sed '/^$/d') else # Else test every URL (except PDFs) in the sitemap - LIGHTHOUSE_URLS=$(grep loc templates/sitemap.xml | grep -v static | sed 's/ *//g' | sed 's/<\/loc>//g' | sed 's/https:\/\/almanac.httparchive.org/http:\/\/127.0.0.1:8080/g') + LIGHTHOUSE_URLS=$(grep loc templates/sitemap.xml | grep -v "/static/" | sed 's/ *//g' | sed 's/<\/loc>//g' | sed 's/https:\/\/almanac.httparchive.org/http:\/\/127.0.0.1:8080/g') fi From 5e65225d3bfcc6909aaee02b73370d5d62f46883 Mon Sep 17 00:00:00 2001 From: Barry Date: Tue, 3 Nov 2020 20:24:03 +0000 Subject: [PATCH 58/59] Move to jq for JSON manipulation --- src/tools/scripts/set_lighthouse_urls.sh | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index be2d7bf165f..bedb89bb3e3 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -81,23 +81,5 @@ fi echo "URLS to check:" echo "${LIGHTHOUSE_URLS}" -# Format the URLs for the lighthouse config: -LIGHTHOUSE_URLS=$(echo "${LIGHTHOUSE_URLS}" | sed 's/^ */ "/' | sed 's/$/",/') -# Remove the comma on the last URL -LIGHTHOUSE_URLS=${LIGHTHOUSE_URLS:0:${#LIGHTHOUSE_URLS}-1} - -# Remove the first two lines form the config -# (we'll insert them again below when adding the URLs) -LIGHTHOUSE_CONFIG=$(sed "1,2d" ${LIGHTHOUSE_CONFIG_FILE}) - -# Write the new config file - including the URLs -cat > "${LIGHTHOUSE_CONFIG_FILE}" << END_CONFIG -{ - "ci": { - "collect": { - "url": [ -${LIGHTHOUSE_URLS} - ] - }, -${LIGHTHOUSE_CONFIG} -END_CONFIG +# Use jq to insert the URLs into the config file: +echo ${LIGHTHOUSE_URLS} | jq -Rs '. | split("\n") | map(select(length > 0))' | jq -s '.[0] * {ci: {collect: {url: .[1]}}}' "${LIGHTHOUSE_CONFIG_FILE}" - > "${LIGHTHOUSE_CONFIG_FILE}" From 7e5686f3db889f5a607f07a5754b016a6ce95de8 Mon Sep 17 00:00:00 2001 From: Barry Date: Tue, 3 Nov 2020 20:33:30 +0000 Subject: [PATCH 59/59] Linting fixes --- src/tools/scripts/set_lighthouse_urls.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/scripts/set_lighthouse_urls.sh b/src/tools/scripts/set_lighthouse_urls.sh index bedb89bb3e3..3244a79ac15 100755 --- a/src/tools/scripts/set_lighthouse_urls.sh +++ b/src/tools/scripts/set_lighthouse_urls.sh @@ -82,4 +82,6 @@ echo "URLS to check:" echo "${LIGHTHOUSE_URLS}" # Use jq to insert the URLs into the config file: -echo ${LIGHTHOUSE_URLS} | jq -Rs '. | split("\n") | map(select(length > 0))' | jq -s '.[0] * {ci: {collect: {url: .[1]}}}' "${LIGHTHOUSE_CONFIG_FILE}" - > "${LIGHTHOUSE_CONFIG_FILE}" +LIGHTHOUSE_CONFIG_WITH_URLS=$(echo "${LIGHTHOUSE_URLS}" | jq -Rs '. | split("\n") | map(select(length > 0))' | jq -s '.[0] * {ci: {collect: {url: .[1]}}}' "${LIGHTHOUSE_CONFIG_FILE}" -) + +echo "${LIGHTHOUSE_CONFIG_WITH_URLS}" > "${LIGHTHOUSE_CONFIG_FILE}"