Skip to content

Commit

Permalink
Merge pull request #939 from Webperf-se/lint-html
Browse files Browse the repository at this point in the history
Added new HTML Test based on html-validate
  • Loading branch information
7h3Rabbit authored Feb 9, 2025
2 parents fa26fb4 + f53878c commit 78c154d
Show file tree
Hide file tree
Showing 22 changed files with 454 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/manual-start-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
test:
description: 'Test to run, comma separated list of numbers'
required: true
default: '1,2,4,5,6,7,9,10,15,20,21,22,23,24,25,26,27'
default: '1,2,4,5,6,7,9,10,15,20,21,22,23,24,25,26,27,28'
type: string
details:
description: 'Setting general.review.details'
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/regression-test-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,15 @@ jobs:
run: |
testresult=$(docker run ${{ env.TEST_TAG }} python default.py -t 27 -r -i defaults/sites.json)
echo "$testresult"
if [[ "$testresult" != *"Standards:"* ]]; then
echo "Error: WebPerf-core testresult is NOT returning expected review"
exit 1
fi
- name: Check if webperf_core can run Test 28
if: always()
run: |
testresult=$(docker run ${{ env.TEST_TAG }} python default.py -t 28 -r -i defaults/sites.json)
echo "$testresult"
if [[ "$testresult" != *"Standards:"* ]]; then
echo "Error: WebPerf-core testresult is NOT returning expected review"
exit 1
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/regression-test-lint-html.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: "Regression Test - HTML Linting Test"
on:
workflow_dispatch:
push:
paths-ignore:
- '**.md'
- '**software-full.json'
- '**software-sources.json'
- '**update-software.yml'
- '**update_software_helper.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-404.yml'
- '**regression-test-a11y-statement.yml'
- '**regression-test-css.yml'
- '**regression-test-docker-image.yml'
- '**regression-test-email.yml'
- '**regression-test-energy-efficiency.yml'
- '**regression-test-google-lighthouse-based.yml'
- '**regression-test-html.yml'
- '**regression-test-http.yml'
- '**regression-test-lint-css.yml'
- '**regression-test-pa11y.yml'
- '**regression-test-sitespeed-browsertime-har.yml'
- '**regression-test-sitespeed.yml'
- '**regression-test-software.yml'
- '**regression-test-standard-files.yml'
- '**regression-test-tracking.yml'
- '**regression-test-translations.yml'
- '**regression-test-webbkoll.yml'
- '**regression-test-ylt.yml'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
config: ['SITESPEED_USE_DOCKER=False']
version: [28]
include:
- os: ubuntu-latest
config: 'SITESPEED_USE_DOCKER=True'
version: 28
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.13' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Setup dependencies using pip
run: pip install -r requirements.txt
- name: Java Version
run: java -version
- name: Setup Node.js (v4 version 20.x)
uses: actions/setup-node@v4
with:
node-version: '20.x'
- if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
name: Setup Google Chrome browser (ONLY used for Sitespeed)
run: |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get --only-upgrade install google-chrome-stable
google-chrome --version
- name: Setup npm packages
run: npm install --omit=dev
timeout-minutes: 30
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: RUNNING TEST - LINUX
run: |
python default.py -t ${{ matrix.version }} -r -u https://msb.se?webperf-core-test-28 -o data/testresult-${{ matrix.version }}.json --setting ${{ matrix.config }} --setting tests.sitespeed.xvfb=true --setting general.cache.use=true --setting general.cache.max-age=5256000 --setting general.cache.folder=unittests
python .github/workflows/verify_result.py -t ${{ matrix.version }}
- if: ${{ matrix.os == 'windows-latest' }}
name: RUNNING TEST - WINDOWS
run: |
python default.py -t ${{ matrix.version }} -r -u https://msb.se?webperf-core-test-28 -o data\testresult-${{ matrix.version }}.json --setting ${{ matrix.config }} --setting general.cache.use=true --setting general.cache.max-age=5256000 --setting general.cache.folder=unittests
python .github\workflows\verify_result.py -t ${{ matrix.version }}
1 change: 1 addition & 0 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def show_test_help(global_translation):
print(global_translation('TEXT_TEST_VALID_ARGUMENTS_SOFTWARE'))
print(global_translation('TEXT_TEST_VALID_ARGUMENTS_A11Y_STATEMENT'))
print(global_translation('TEXT_TEST_VALID_ARGUMENTS_CSS_LINT'))
print(global_translation('TEXT_TEST_VALID_ARGUMENTS_HTML_LINT'))
sys.exit()


Expand Down
8 changes: 5 additions & 3 deletions helpers/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from tests.html_validator_w3c import run_test as run_test_html_validator_w3c
from tests.css_validator_w3c import run_test as run_test_css_validator_w3c
from tests.css_linting import run_test as run_test_lint_css
from tests.html_linting import run_test as run_test_lint_html
from tests.privacy_webbkollen import run_test as run_test_privacy_webbkollen
from tests.performance_lighthouse import run_test as run_test_performance_lighthouse
from tests.seo_lighthouse import run_test as run_test_seo_lighthouse
Expand Down Expand Up @@ -43,8 +44,8 @@
TEST_UNKNOWN_19,
TEST_WEBBKOLL, TEST_HTTP, TEST_ENERGY_EFFICIENCY, TEST_TRACKING,
TEST_EMAIL, TEST_SOFTWARE, TEST_A11Y_STATEMENT,
TEST_LINT_CSS#, TEST_LINT_HTML, TEST
) = range(28)
TEST_LINT_CSS, TEST_LINT_HTML #, TEST
) = range(29)

TEST_FUNCS = {
TEST_PAGE_NOT_FOUND: run_test_page_not_found,
Expand All @@ -65,7 +66,8 @@
TEST_EMAIL: run_test_email_validator,
TEST_SOFTWARE: run_test_software,
TEST_A11Y_STATEMENT: run_test_a11y_statement,
TEST_LINT_CSS: run_test_lint_css
TEST_LINT_CSS: run_test_lint_css,
TEST_LINT_HTML: run_test_lint_html
}

CONFIG_WARNINGS = {}
Expand Down
2 changes: 2 additions & 0 deletions helpers/translation_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ def validate_locale(msg_ids, locales_dir,
bash_command = (f"python {msgfmt_path} -o ",
f"{os.path.join(lang_sub_directory, file.replace('.po', '.mo'))} ",
f"{os.path.join(lang_sub_directory, file)}")
# Konvertera tuple till sträng
bash_command = "".join(bash_command)

with subprocess.Popen(
bash_command.split(),
Expand Down
Binary file added locales/en/LC_MESSAGES/html_linting.mo
Binary file not shown.
43 changes: 43 additions & 0 deletions locales/en/LC_MESSAGES/html_linting.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# English (default).
# Copyright (C) 2025 WebPerf
# FIRST AUTHOR <[email protected]>, 2025.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-02-08 21:45+0200\n"
"PO-Revision-Date: 2025-02-08 21:45+0200\n"
"Last-Translator: mattias <[email protected]>\n"
"Language-Team: English <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"


msgid "TEXT_RUNNING_TEST"
msgstr "## Test: 28 - HTML\n"

msgid "TEXT_REVIEW_HTML_VERY_GOOD"
msgstr "- The HTML is very good.\n"

msgid "TEXT_REVIEW_HTML_IS_GOOD"
msgstr "- The HTML is good.\n"

msgid "TEXT_REVIEW_HTML_IS_OK"
msgstr "- The HTML is neither good or bad.\n"

msgid "TEXT_REVIEW_HTML_IS_BAD"
msgstr "- The HTML is bad.\n"

msgid "TEXT_REVIEW_HTML_IS_VERY_BAD"
msgstr "- The HTML is very bad.\n"

msgid "TEXT_REVIEW_ERRORS_ITEM"
msgstr " - {0} (number of errors of this type: {1})\n"

msgid "TEXT_REVIEW_RATING_GROUPED"
msgstr ", number of grouped error type: {0}"

msgid "TEXT_REVIEW_RATING_ITEMS"
msgstr ", number of errors: {0}"
Binary file modified locales/en/LC_MESSAGES/webperf-core.mo
Binary file not shown.
3 changes: 3 additions & 0 deletions locales/en/LC_MESSAGES/webperf-core.po
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ msgstr "-t 26\t: Accessibility Statement (Alfa)"
msgid "TEXT_TEST_VALID_ARGUMENTS_CSS_LINT"
msgstr "-t 27\t: CSS Lint (Stylelint)"

msgid "TEXT_TEST_VALID_ARGUMENTS_HTML_LINT"
msgstr "-t 28\t: HTML Lint (html-validate)"

msgid "TEXT_COMMAND_USAGE"
msgstr "\n\tWebPerf Core\n\n\tUsage:\n\tdefault.py -u https://webperf.se\n\n\tOptions and arguments:\n\t-h/--help\t\t\t: Help information on how to use script\n\t-u/--url <site url>\t\t: website url to test against\n\t-t/--test <test number>\t\t: run ONE test (use ? to list available tests)\n\t-r/--review\t\t\t: show reviews in terminal\n\t-i/--input <file path>\t\t: input file path (.json/.sqlite/.sitemap/<category name>.webprf)\n\t-i/--input-skip <number>\t: number of items to skip\n\t-i/--input-take <number>\t: number of items to take\n\t-o/--output <file path>\t\t: output file path (.json/.csv/.sql/.sqlite/.md)\n\t-A/--addUrl <site url>\t\t: website url (required in compination with -i/--input)\n\t-D/--deleteUrl <site url>\t: website url (required in compination with -i/--input)\n\t-L/--language <lang code>\t: language used for output(en = default/sv)\n\t--setting <key>=<value>\t\t: override configuration for current run\n\t\t\t\t\t (use ? to list available settings)\n\t--save-setting <filename>\t: create own configuration from currently used configuration\n\t\t\t\t\t (You should use 'settings.json')\n\t-c/--credits/--contributors\t: Show projects and people we are thankful for\n\n\n\tAdvanced options and arguments:\n\t--dependency\t\t\t: Validates your installation of WebPerf_core\n\t--find-unknown-sources\t\t: Filters out interesting software from software-unknown-sources.json\n\t--update-credits\t\t: Updates CREDITS.md\n\t--update-browser\t\t: Updates general.useragent in defaults/settings.json\n\t--update-definitions <api-key>\t: Updates software info in defaults/software-sources.json\n\t--update-mdn-sources\t\t: Updates webstandards from mdn web docs to defaults/mdn-rules.json\n\t--update-carbon <file path>\t: Updates carbon percentile in energy_efficiency_carbon_percentiles.py\n\t--update-translations\t\t: Validates and updates translation files\n\t--prepare-release\t\t: Updates package.json in preparation of new release\n\t--create-release\t\t: Creates new release for github and docker hub"

Expand Down
Binary file added locales/gov/LC_MESSAGES/html_linting.mo
Binary file not shown.
43 changes: 43 additions & 0 deletions locales/gov/LC_MESSAGES/html_linting.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# English (default).
# Copyright (C) 2025 WebPerf
# FIRST AUTHOR <[email protected]>, 2025.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-02-08 21:45+0200\n"
"PO-Revision-Date: 2025-02-08 21:45+0200\n"
"Last-Translator: mattias <[email protected]>\n"
"Language-Team: English <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"


msgid "TEXT_RUNNING_TEST"
msgstr "## Test: 28 - HTML\n"

msgid "TEXT_REVIEW_HTML_VERY_GOOD"
msgstr "- The HTML is very good.\n"

msgid "TEXT_REVIEW_HTML_IS_GOOD"
msgstr "- The HTML is good.\n"

msgid "TEXT_REVIEW_HTML_IS_OK"
msgstr "- The HTML is neither good or bad.\n"

msgid "TEXT_REVIEW_HTML_IS_BAD"
msgstr "- The HTML is bad.\n"

msgid "TEXT_REVIEW_HTML_IS_VERY_BAD"
msgstr "- The HTML is very bad.\n"

msgid "TEXT_REVIEW_ERRORS_ITEM"
msgstr " - {0} (number of errors of this type: {1})\n"

msgid "TEXT_REVIEW_RATING_GROUPED"
msgstr ", number of grouped error type: {0}"

msgid "TEXT_REVIEW_RATING_ITEMS"
msgstr ", number of errors: {0}"
Binary file modified locales/gov/LC_MESSAGES/webperf-core.mo
Binary file not shown.
3 changes: 3 additions & 0 deletions locales/gov/LC_MESSAGES/webperf-core.po
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ msgstr "-t 26\t: Accessibility Statement (Alfa)"
msgid "TEXT_TEST_VALID_ARGUMENTS_CSS_LINT"
msgstr "-t 27\t: CSS Lint (Stylelint)"

msgid "TEXT_TEST_VALID_ARGUMENTS_HTML_LINT"
msgstr "-t 28\t: HTML Lint (html-validate)"

#: default.py:137 default.py:141 default.py:146 default.py:213
msgid "TEXT_COMMAND_USAGE"
msgstr "\n\tWebPerf Core\n\n\tUsage:\n\tdefault.py -u https://webperf.se\n\n\tOptions and arguments:\n\t-h/--help\t\t\t: Help information on how to use script\n\t-u/--url <site url>\t\t: website url to test against\n\t-t/--test <test number>\t\t: run ONE test (use ? to list available tests)\n\t-r/--review\t\t\t: show reviews in terminal\n\t-i/--input <file path>\t\t: input file path (.json/.sqlite/.sitemap/<category name>.webprf)\n\t-i/--input-skip <number>\t: number of items to skip\n\t-i/--input-take <number>\t: number of items to take\n\t-o/--output <file path>\t\t: output file path (.json/.csv/.sql/.sqlite/.md)\n\t-A/--addUrl <site url>\t\t: website url (required in compination with -i/--input)\n\t-D/--deleteUrl <site url>\t: website url (required in compination with -i/--input)\n\t-L/--language <lang code>\t: language used for output(en = default/sv)\n\t--setting <key>=<value>\t\t: override configuration for current run\n\t\t\t\t\t (use ? to list available settings)\n\t--save-setting <filename>\t: create own configuration from currently used configuration\n\t\t\t\t\t (You should use 'settings.json')\n\t-c/--credits/--contributors\t: Show projects and people we are thankful for\n\n\n\tAdvanced options and arguments:\n\t--dependency\t\t\t: Validates your installation of WebPerf_core\n\t--find-unknown-sources\t\t: Filters out interesting software from software-unknown-sources.json\n\t--update-credits\t\t: Updates CREDITS.md\n\t--update-browser\t\t: Updates general.useragent in defaults/settings.json\n\t--update-definitions <api-key>\t: Updates software info in defaults/software-sources.json\n\t--update-mdn-sources\t\t: Updates webstandards from mdn web docs to defaults/mdn-rules.json\n\t--update-carbon <file path>\t: Updates carbon percentile in energy_efficiency_carbon_percentiles.py\n\t--update-translations\t\t: Validates and updates translation files\n\t--prepare-release\t\t: Updates package.json in preparation of new release\n\t--create-release\t\t: Creates new release for github and docker hub"
Expand Down
Binary file added locales/sv/LC_MESSAGES/html_linting.mo
Binary file not shown.
43 changes: 43 additions & 0 deletions locales/sv/LC_MESSAGES/html_linting.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Swedish
# Copyright (C) 2025 WebPerf
# FIRST AUTHOR <[email protected]>, 2025.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-02-08 21:45+0200\n"
"PO-Revision-Date: 2025-02-08 21:45+0200\n"
"Last-Translator: mattias <[email protected]>\n"
"Language-Team: Swedish <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"


msgid "TEXT_RUNNING_TEST"
msgstr "## Test: 28 - HTML\n"

msgid "TEXT_REVIEW_HTML_VERY_GOOD"
msgstr "- HTML är välbyggd!\n"

msgid "TEXT_REVIEW_HTML_IS_GOOD"
msgstr "- HTML är bra.\n"

msgid "TEXT_REVIEW_HTML_IS_OK"
msgstr "- HTML är ok.\n"

msgid "TEXT_REVIEW_HTML_IS_BAD"
msgstr "- HTML är dålig.\n"

msgid "TEXT_REVIEW_HTML_IS_VERY_BAD"
msgstr "- HTML är väldigt dålig.\n"

msgid "TEXT_REVIEW_ERRORS_ITEM"
msgstr " - {0} (totalt {1} st)\n"

msgid "TEXT_REVIEW_RATING_GROUPED"
msgstr ", antal grupperade fel: {0}"

msgid "TEXT_REVIEW_RATING_ITEMS"
msgstr ", antal fel: {0}"
Binary file modified locales/sv/LC_MESSAGES/webperf-core.mo
Binary file not shown.
3 changes: 3 additions & 0 deletions locales/sv/LC_MESSAGES/webperf-core.po
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ msgstr "-t 26\t: Tillgänglighetsredogörelse (Alfa)"
msgid "TEXT_TEST_VALID_ARGUMENTS_CSS_LINT"
msgstr "-t 27\t: CSS-validering (Stylelint)"

msgid "TEXT_TEST_VALID_ARGUMENTS_HTML_LINT"
msgstr "-t 28\t: HTML-validering (html-validate)"

msgid "TEXT_COMMAND_USAGE"
msgstr "\n\tWebPerf Core\n\n\tAnvänd så här:\n\tdefault.py -u https://webperf.se\n\n\tVal och argument:\n\t-h/--help\t\t\t: Hjälp och hur du använder skriptet\n\t-u/--url <site url>\t\t: webbplatsens adress att testa\n\t-t/--test <test nummer>\t\t: kör ett specifikt test (ange ? för att lista tillgängliga tester)\n\t-r/--review\t\t\t: visar omdömen direkt i terminalen\n\t-i/--input <file path>\t\t: sökväg för input-fil (.json/.sqlite)\n\t-i/--input-skip <nummer>\t: antal att hoppa över\n\t-i/--input-take <nummer>\t: antal att testa\n\t-o/--output <file path>\t\t: sökväg till output-fil (.json/.csv/.sql/.sqlite/.md)\n\t-A/--addUrl <site url>\t\t: webbplatsens adress/url (ett krav när du använder -i/--input)\n\t-D/--deleteUrl <site url>\t: webbplats adress/url (ett krav när du använder -i/--input)\n\t-L/--language <lang code>\t: språk som används för output(en = default/sv)\n\t--setting <nyckel>=<värde>\t: Använd inställning för nuvarande körning\n\t\t\t\t\t (ange ? för att lista tillgängliga inställningar)\n\t--save-setting <filnamn>\t: Skapa egen inställningsfil från nuvarande använda inställningar\n\t\t\t\t\t (Du bör använda 'settings.json')\n\t-c/--credits/--contributors\t: Visa projekt och människor vi är tacksamma för\n\n\n\tAvancerade val och argument:\n\t--dependency\t\t\t: Validates your installation of WebPerf_core\n\t--find-unknown-sources\t\t: Filters out interesting software from software-unknown-sources.json\n\t--update-credits\t\t: Updates CREDITS.md\n\t--update-browser\t\t: Updates general.useragent in defaults/settings.json\n\t--update-definitions <api-key>\t: Updates software info in defaults/software-sources.json\n\t--update-mdn-sources\t\t: Updates webstandards from mdn web docs to defaults/mdn-rules.json\n\t--update-carbon <file path>\t: Updates carbon percentile in energy_efficiency_carbon_percentiles.py\n\t--update-translations\t\t: Validates and updates translation files\n\t--prepare-release\t\t: Updates package.json in preparation of new release\n\t--create-release\t\t: Creates new release for github and docker hub"

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@sitespeed.io/plugin": "1.0.0",
"@sitespeed.io/plugin-lighthouse": "12.3.0",
"html-validate": "9.2.1",
"pa11y": "8.0.0",
"sitespeed.io": "36.2.5",
"stylelint": "16.14.1",
Expand All @@ -22,4 +23,4 @@
"engines": {
"node": ">=20.x"
}
}
}
Loading

0 comments on commit 78c154d

Please sign in to comment.