Skip to content

Commit be28b1b

Browse files
authored
[docsy] Add external link checking, fix links, add cache (#103)
1 parent 1a60f9e commit be28b1b

File tree

6 files changed

+827
-5
lines changed

6 files changed

+827
-5
lines changed

.htmltest.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,50 @@
1+
CacheExpires: 9000h # ~ 12 months
12
DirectoryPath: public
3+
TestFilesConcurrently: true
24
CheckDoctype: false # Sadly, this is false only because of `static/google*.html`
5+
CheckMailto: false
36
IgnoreAltMissing: true # FIXME
47
IgnoreDirectoryMissingTrailingSlash: true # FIXME
58
IgnoreDirs:
69
IgnoreEmptyHref: true # FIXME
710
IgnoreInternalEmptyHash: true # FIXME
811
IgnoreInternalURLs: # list of paths
912
IgnoreURLs: # list of regexs of paths or URLs to be ignored
13+
# Ignore Docsy-generated GitHub links for now
14+
- ^https?://github\.com/.*?/.*?/(new|edit)/ # view-page, edit-source etc
15+
16+
# TUF
1017
- ^/specification/
18+
- ^https://cse.google.com
19+
20+
# FIXME: 4XXs reported by checker, which we ignore until we have time to fix them
21+
# Get "https://events17.linuxfoundation.org/events/kubecon-and-cloudnativecon-north-america/program/schedule": x509: certificate is valid for *.cass.oregonstate.edu, not events17.linuxfoundation.org --- resources/news/index.html
22+
- ^https://events17.linuxfoundation.org/events/kubecon-and-cloudnativecon-north-america/program/schedule
23+
# Non-OK status: 403 --- resources/news/index.html
24+
- ^https://schd.ws/hosted_files/linuxconcontainerconeurope2016/50/When%20the%20going%20gets%20tough%2C%20get%20TUF%20going%21%20Linuxcon%20EU.pdf
25+
# Non-OK status: 403 --- resources/news/index.html
26+
- ^https://www.forbes.com/sites/.../uptane-will-protect-your-connected-car-from-hackers
27+
# Non-OK status: 403 --- resources/news/index.html
28+
- ^https://www.tmcnet.com/usubmit/2019/05/28/8963021.htm
29+
# Non-OK status: 404 --- community/adoptions/index.html
30+
- ^https://github.com/bottlerocket-os/bottlerocket/tree/develop/sources/updater
31+
# Non-OK status: 404 --- resources/news/index.html
32+
- ^https://www.d2pmagazine.com/2020/04/02/6099/
33+
# Non-OK status: 404 --- resources/news/index.html
34+
- ^https://www.just-auto.com/news/here-and-uptane-team-on-automotiveiot-security_id188912.aspx
35+
# Non-OK status: 404 --- resources/news/index.html
36+
- ^https://www.linuxfoundation.org/cloud-containers-virtualization/cncf-host-two-security-projects-notary-tuf-specification/
37+
# Non-OK status: 404 --- resources/news/index.html
38+
- ^https://www.ustream.tv/recorded/64499822#t=1h54m0s
39+
# Non-OK status: 503 --- resources/news/index.html
40+
- ^https://www.airbiquity.com
41+
# Non-OK status: 503 --- resources/news/index.html
42+
- ^https://www.airbiquity.com/news/press-releases/airbiquity-bolsters-otamatictm-security-and-data-analytic-features-latest-over-air-ota-software-and-data-management-offering-aut
43+
# Non-OK status: 503 --- resources/news/index.html
44+
- ^https://www.airbiquity.com/news/press-releases/airbiquity-otamatic-named-2017-new-product-year-business-intelligence-group
45+
# Non-OK status: 503 --- resources/news/index.html
46+
- ^https://www.airbiquity.com/news/press-releases/airbiquity-otamatic-named-2017-new-product-year-business-intelligence-group
47+
# request exceeded our ExternalTimeout --- docs/security/audits/index.html
48+
- ^https://www.nccgroup.trust/globalassets/our-research/us/public-reports/2017/ncc-group-kolide-the-update-framework-security-assessment.pdf
49+
# request exceeded our ExternalTimeout --- resources/news/index.html
50+
- ^http://www.enterprisecloudnews.com/author.asp

Makefile

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
# Set REFCACHE to another value to disable htmltest refcache-file manipulation
2+
REFCACHE?=refcache
13
HTMLTEST_DIR=tmp
24
HTMLTEST?=htmltest # Specify as make arg if different
35
HTMLTEST_ARGS?=--skip-external
6+
LINK_CACHE_FILE?=refcache.json
7+
LINK_CACHE_FILE_DEST_DIR?=static
8+
LINK_CACHE_FILE_SRC_DIR?=$(HTMLTEST_DIR)/.htmltest
9+
OTEL_GEN_REPO?=../$(shell basename $(shell pwd)).g
410

511
# Use $(HTMLTEST) in PATH, if available; otherwise, we'll get a copy
612
ifeq (, $(shell which $(HTMLTEST)))
@@ -10,7 +16,32 @@ GET_LINK_CHECKER_IF_NEEDED=get-link-checker
1016
endif
1117
endif
1218

13-
check-links: $(GET_LINK_CHECKER_IF_NEEDED)
19+
default:
20+
@echo "Make what? Target list:\n"
21+
@make -rpn | grep '^[a-z]\S*:' | sed 's/://' | sort
22+
23+
$(LINK_CACHE_FILE_SRC_DIR):
24+
mkdir -p $(LINK_CACHE_FILE_SRC_DIR)
25+
26+
refcache-restore: $(LINK_CACHE_FILE_SRC_DIR)
27+
ifeq (refcache, $(REFCACHE))
28+
cp $(LINK_CACHE_FILE_DEST_DIR)/$(LINK_CACHE_FILE) $(LINK_CACHE_FILE_SRC_DIR)/
29+
else
30+
@echo "SKIPPING refcache-restore"
31+
endif
32+
33+
refcache-save: $(LINK_CACHE_FILE_SRC_DIR)/$(LINK_CACHE_FILE)
34+
ifeq (refcache, $(REFCACHE))
35+
cp $(LINK_CACHE_FILE_SRC_DIR)/$(LINK_CACHE_FILE) $(LINK_CACHE_FILE_DEST_DIR)/
36+
npm run _prettier:any -- --write $(LINK_CACHE_FILE_DEST_DIR)/$(LINK_CACHE_FILE)
37+
else
38+
@echo "SKIPPING refcache-save"
39+
endif
40+
41+
check-links: $(GET_LINK_CHECKER_IF_NEEDED) \
42+
refcache-restore check-links-only refcache-save
43+
44+
check-links-only:
1445
$(HTMLTEST) $(HTMLTEST_ARGS)
1546

1647
clean:
@@ -19,3 +50,16 @@ clean:
1950
get-link-checker:
2051
rm -Rf $(HTMLTEST_DIR)/bin
2152
curl https://htmltest.wjdp.uk | bash -s -- -b $(HTMLTEST_DIR)/bin
53+
54+
# For local development, create `public` either as a symlink to a given git repo
55+
# (if it exists), or an empty git repo. This is for the purpose of tracking
56+
# build changes.
57+
public:
58+
@if [ -e "$(OTEL_GEN_REPO)" ]; then \
59+
set -x; ln -s $(OTEL_GEN_REPO) public; \
60+
elif [ -z "$(CI)" ]; then \
61+
set -x; git init public; \
62+
fi
63+
64+
ls-public:
65+
if [ -e public ]; then ls -ld public; fi

content/en/docs/project/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ To learn how project decisions are made, and for a more detailed explanation of
2727
the project roles used below, see [Governance].
2828

2929
[contributed]:
30-
https://github.com/theupdateframework/python-tuf/blob/develop/docs/AUTHORS.txt
30+
https://github.com/theupdateframework/python-tuf/blob/develop/README.md#acknowledgements
3131
[Governance]:
3232
https://github.com/theupdateframework/specification/blob/master/GOVERNANCE.md
3333
[Specification]: /specification/latest
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<script type="text/javascript" async src="https://cse.google.com/cse.js?cx={{ .Site.Params.gcs_engine_id }}"></script>
1+
{{ with .Site.Params.gcs_engine_id -}}
2+
<script type="text/javascript" async src="https://cse.google.com/cse.js?cx={{ . }}"></script>
3+
{{ end -}}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"_build": "npm run _hugo-dev --",
66
"_check:format": "npx prettier --check .",
77
"_check:links--warn": "npm run _check:links || (echo; echo 'WARNING: see link-checker output for issues.'; echo)",
8-
"_check:links": "HTMLTEST_ARGS='--log-level 1 --skip-external' npm run __check:links",
8+
"_check:links:internal": "npm run __check:links",
9+
"_check:links": "HTMLTEST_ARGS='--log-level 1' npm run __check:links",
910
"_diff:check": "git diff --name-only --exit-code",
1011
"_filename-error": "echo 'ERROR: the following files violate naming conventions; fix using: `npm run fix:filenames`'; echo; npm run -s _ls-bad-filenames; exit 1",
1112
"_filenames-to-kebab-case": "find assets content -name '*_*' ! -name '[_.]*' -exec sh -c 'mv \"$1\" \"${1//_/-}\"' _ {} \\;",
@@ -15,13 +16,14 @@
1516
"_hugo": "hugo --cleanDestinationDir",
1617
"_ls-bad-filenames": "find assets content -name '*_*' ! -name '[_.]*'",
1718
"_prepare:docsy": "cd themes/docsy && npm install",
19+
"_prettier:any": "npx prettier --ignore-path ''",
1820
"_serve": "npm run _hugo-dev -- serve --minify --disableFastRender --renderToMemory",
1921
"build:preview": "npm run _hugo-dev -- --minify --baseURL \"${DEPLOY_PRIME_URL:-http://localhost}\"",
2022
"build:production": "npm run _hugo -- --minify",
2123
"build": "npm run _build --",
2224
"check:filenames": "test -z \"$(npm run -s _ls-bad-filenames)\" || npm run -s _filename-error",
2325
"check:format": "npm run _check:format || (echo '[help] Run: npm run fix:format'; exit 1)",
24-
"check:links:all": "HTMLTEST_ARGS= npm run _check:links",
26+
"check:links:internal": "npm run _check:links:internal",
2527
"check:links": "npm run _check:links",
2628
"clean": "rm -Rf public",
2729
"diff:check": "npm run _diff:check || (echo; echo 'WARNING: the files above have not been committed'; echo)",

0 commit comments

Comments
 (0)