ci: replace htmlproofer with wjdp/htmltest

Signed-off-by: David Karlsson <david.karlsson@docker.com>
This commit is contained in:
David Karlsson 2023-04-12 15:03:30 +02:00
parent 27485b9f7c
commit 2d44be0fc0
7 changed files with 39 additions and 47 deletions

View File

@ -35,7 +35,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
target: target:
- htmlproofer - htmltest
- mdl - mdl
steps: steps:
- -
@ -70,7 +70,7 @@ jobs:
// construct annotations by parsing output // construct annotations by parsing output
switch ("${{ matrix.target }}") { switch ("${{ matrix.target }}") {
case "htmlproofer": case "htmltest":
const re = /^- (.+)\n \* (.+) \(line (\d+)\)\n(.+)$/gm; const re = /^- (.+)\n \* (.+) \(line (\d+)\)\n(.+)$/gm;
while (true) { while (true) {
const result = re.exec(results); const result = re.exec(results);
@ -79,7 +79,7 @@ jobs:
} }
core.error(`${result[2]}\n${result[4]}`, { core.error(`${result[2]}\n${result[4]}`, {
title: 'Link check failed', title: 'HTML test failed',
// file: result[1], // file: result[1],
// startLine: result[3], // startLine: result[3],
}); });

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ CNAME
_kbase/** _kbase/**
/vendor /vendor
/lint /lint
tmp/.htmltest/**

16
.htmltest.yml Normal file
View File

@ -0,0 +1,16 @@
DirectoryPath: "_site"
EnforceHTTPS: false
CheckDoctype: false
CheckExternal: false
IgnoreAltMissing: true
IgnoreAltEmpty: true
IgnoreEmptyHref: true
IgnoreDirectoryMissingTrailingSlash: true
IgnoreURLs:
- "^/docker-hub/api/latest/.*$"
- "^/engine/api/v.+/#.*$"
- "^/glossary/.*$"
IgnoreDirs:
- "engine/api"
- "registry/configuration"
CacheExpires: "6h"

View File

@ -63,28 +63,27 @@ RUN --mount=type=bind,target=.,rw \
bundle exec jekyll build --profile -d ${TARGET} --config ${CONFIG_FILES} bundle exec jekyll build --profile -d ${TARGET} --config ${CONFIG_FILES}
EOT EOT
# htmlproofer checks for broken links # htmltest checks for broken links
FROM gem AS htmlproofer-base FROM wjdp/htmltest:v0.17.0 as htmltest-base
RUN --mount=type=bind,from=generate,source=/out,target=_site <<EOF RUN --mount=type=bind,from=generate,source=/out,target=_site \
htmlproofer ./_site \ --mount=type=bind,source=.htmltest.yml,target=.htmltest.yml \
--disable-external \ <<EOF
--internal-domains="docs.docker.com,docs-stage.docker.com,localhost:4000" \ htmltest > /results 2>&1
--file-ignore="/^./_site/engine/api/.*$/,./_site/registry/configuration/index.html" \ rc=$?
--url-ignore="/^/docker-hub/api/latest/.*$/,/^/engine/api/v.+/#.*$/,/^/glossary/.*$/" > /results 2>&1 if [[ $rc -eq 0 ]]; then
rc=$? echo -n > /results
if [[ $rc -eq 0 ]]; then fi
echo -n > /results
fi
EOF EOF
FROM htmlproofer-base as htmlproofer FROM base as htmltest
COPY --from=htmltest-base /results /results
RUN <<EOF RUN <<EOF
cat /results cat /results
[ ! -s /results ] || exit 1 [ ! -s /results ] || exit 1
EOF EOF
FROM scratch as htmlproofer-output FROM scratch as htmltest-output
COPY --from=htmlproofer-base /results /results COPY --from=htmltest-base /results /results
# mdl is a lint tool for markdown files # mdl is a lint tool for markdown files
FROM gem AS mdl-base FROM gem AS mdl-base

View File

@ -17,7 +17,6 @@ gem 'rouge', '3.27.0'
gem 'front_matter_parser', '1.0.1' gem 'front_matter_parser', '1.0.1'
gem 'git', '1.13.0' gem 'git', '1.13.0'
gem 'html-proofer', '3.19.4'
gem 'mdl', '0.11.0' gem 'mdl', '0.11.0'
gem 'octopress-hooks', '2.6.2' gem 'octopress-hooks', '2.6.2'
gem 'rake', '13.0.6' gem 'rake', '13.0.6'

View File

@ -10,8 +10,6 @@ GEM
em-websocket (0.5.3) em-websocket (0.5.3)
eventmachine (>= 0.12.9) eventmachine (>= 0.12.9)
http_parser.rb (~> 0) http_parser.rb (~> 0)
ethon (0.15.0)
ffi (>= 1.15.0)
eventmachine (1.2.7) eventmachine (1.2.7)
ffi (1.15.5) ffi (1.15.5)
forwardable-extended (2.6.0) forwardable-extended (2.6.0)
@ -19,14 +17,6 @@ GEM
git (1.13.0) git (1.13.0)
addressable (~> 2.8) addressable (~> 2.8)
rchardet (~> 1.8) rchardet (~> 1.8)
html-proofer (3.19.4)
addressable (~> 2.3)
mercenary (~> 0.3)
nokogiri (~> 1.13)
parallel (~> 1.10)
rainbow (~> 3.0)
typhoeus (~> 1.3)
yell (~> 2.0)
http_parser.rb (0.8.0) http_parser.rb (0.8.0)
i18n (1.12.0) i18n (1.12.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
@ -75,20 +65,11 @@ GEM
tomlrb tomlrb
mixlib-shellout (3.2.7) mixlib-shellout (3.2.7)
chef-utils chef-utils
nokogiri (1.14.3-aarch64-linux)
racc (~> 1.4)
nokogiri (1.14.3-arm-linux)
racc (~> 1.4)
nokogiri (1.14.3-x86_64-linux)
racc (~> 1.4)
octopress-hooks (2.6.2) octopress-hooks (2.6.2)
jekyll (>= 2.0) jekyll (>= 2.0)
parallel (1.22.1)
pathutil (0.16.2) pathutil (0.16.2)
forwardable-extended (~> 2.6) forwardable-extended (~> 2.6)
public_suffix (5.0.1) public_suffix (5.0.1)
racc (1.6.2)
rainbow (3.1.1)
rake (13.0.6) rake (13.0.6)
rb-fsevent (0.11.2) rb-fsevent (0.11.2)
rb-inotify (0.10.1) rb-inotify (0.10.1)
@ -102,10 +83,7 @@ GEM
terminal-table (2.0.0) terminal-table (2.0.0)
unicode-display_width (~> 1.1, >= 1.1.1) unicode-display_width (~> 1.1, >= 1.1.1)
tomlrb (2.0.3) tomlrb (2.0.3)
typhoeus (1.4.0)
ethon (>= 0.9.0)
unicode-display_width (1.8.0) unicode-display_width (1.8.0)
yell (2.2.2)
PLATFORMS PLATFORMS
aarch64-linux aarch64-linux
@ -115,7 +93,6 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
front_matter_parser (= 1.0.1) front_matter_parser (= 1.0.1)
git (= 1.13.0) git (= 1.13.0)
html-proofer (= 3.19.4)
jekyll (= 4.2.2) jekyll (= 4.2.2)
jekyll-redirect-from jekyll-redirect-from
jekyll-relative-links jekyll-relative-links

View File

@ -36,18 +36,18 @@ target "vendor" {
} }
group "validate" { group "validate" {
targets = ["htmlproofer", "mdl"] targets = ["htmltest", "mdl"]
} }
target "htmlproofer" { target "htmltest" {
inherits = ["_common"] inherits = ["_common"]
target = "htmlproofer" target = "htmltest"
output = ["type=cacheonly"] output = ["type=cacheonly"]
} }
target "htmlproofer-output" { target "htmltest-output" {
inherits = ["_common"] inherits = ["_common"]
target = "htmlproofer-output" target = "htmltest-output"
output = ["./lint"] output = ["./lint"]
} }