diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6578741b63550..624a7bfdb9ee1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,6 +16,7 @@ jobs: - run: node --version - run: npm --version + - run: java -version - name: Install npm dependencies run: npm ci @@ -28,5 +29,8 @@ jobs: - name: Run tests run: npm test + - name: Run HTML validator + run: npm run test:html + - name: Run linkinator run: npm run test:linkinator diff --git a/package-lock.json b/package-lock.json index d453187e57445..267bb65d2f4f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1876,7 +1876,6 @@ "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", "dev": true, "requires": { - "cross-spawn": "^5.0.1", "get-stream": "^3.0.0", "is-stream": "^1.1.0", "npm-run-path": "^2.0.0", @@ -7014,6 +7013,12 @@ "extsprintf": "^1.2.0" } }, + "vnu-jar": { + "version": "19.9.4", + "resolved": "https://registry.npmjs.org/vnu-jar/-/vnu-jar-19.9.4.tgz", + "integrity": "sha512-x91WyaNr1oPJaYZkbyMElRyV60BUaxPuhm3zXXjlFOpW3E2KavPWlyohX0LTf6gX7/tujIMgLE5UGc0jn7o4XQ==", + "dev": true + }, "ware": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ware/-/ware-1.3.0.tgz", diff --git a/package.json b/package.json index a37ad9cfe7482..d584d523e9232 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "test:lint:md": "markdownlint \"**/*.md\" -i \"**/node_modules/**\"", "test:lint:stylint": "stylint layouts/css", "test:lint": "npm-run-all --parallel test:lint:*", + "test:html": "node scripts/vnu-jar.js", "test:unit": "tape tests/**/*.test.js | faucet" }, "repository": "nodejs/nodejs.org", @@ -78,6 +79,7 @@ "st": "^1.2.2", "standard": "^14.3.1", "stylint": "^2.0.0", - "tape": "^4.11.0" + "tape": "^4.11.0", + "vnu-jar": "19.9.4" } } diff --git a/scripts/vnu-jar.js b/scripts/vnu-jar.js new file mode 100644 index 0000000000000..11a3dbb3a8464 --- /dev/null +++ b/scripts/vnu-jar.js @@ -0,0 +1,54 @@ +#!/usr/bin/env node + +'use strict' + +const childProcess = require('child_process') +const vnu = require('vnu-jar') + +childProcess.exec('java -version', (error, stdout, stderr) => { + if (error) { + console.error('Skipping vnu-jar test; Java is missing.') + return + } + + const is32bitJava = !stderr.match(/64-Bit/) + + // vnu-jar accepts multiple ignores joined with a `|`. + // Also note that the ignores are regular expressions. + const ignores = [ + // Low priority warnings + 'Section lacks heading.*', + // This seems to happen due to some Unicode characters + 'Text run is not in Unicode Normalization Form C.', + // These are real errors but hard to tackle. + // We should fix them eventually + 'Table column.*', + // These happen due to the commented out English HTML code some translations have... + // They should be removed at some point + 'The document is not mappable to XML 1.0 due to two consecutive hyphens in a comment.' + ].join('|') + + const args = [ + '-jar', + vnu, + '--asciiquotes', + '--skip-non-html', + // Ignore the language code warnings + '--no-langdetect', + '--Werror', + '--errors-only', + `--filterpattern "${ignores}"`, + 'build/' + ] + + // For the 32-bit Java we need to pass `-Xss512k` + if (is32bitJava) { + args.splice(0, 0, '-Xss512k') + } + + return childProcess.spawn('java', args, { + shell: true, + stdio: 'inherit' + }) + .on('exit', process.exit) +})