You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bifromq.apache.org by vi...@apache.org on 2026/08/13 02:38:45 UTC
(bifromq-sites) branch codex/site-readiness-checks updated (e0ba4b5e -> cc3025ee)
This is an automated email from the ASF dual-hosted git repository.
visoar pushed a change to branch codex/site-readiness-checks
in repository https://gitbox.apache.org/repos/asf/bifromq-sites.git
discard e0ba4b5e test: validate generated site readiness
add 1021737a seo: clarify homepage MQTT title
new cc3025ee test: validate generated site readiness
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (e0ba4b5e)
\
N -- N -- N refs/heads/codex/site-readiness-checks (cc3025ee)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/pages/index.tsx | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
(bifromq-sites) 01/01: test: validate generated site readiness
Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
visoar pushed a commit to branch codex/site-readiness-checks
in repository https://gitbox.apache.org/repos/asf/bifromq-sites.git
commit cc3025ee033ab3157d7770186abb0a1745d7ed4e
Author: Visoar Zhang <vi...@gmail.com>
AuthorDate: Thu Aug 13 10:37:52 2026 +0800
test: validate generated site readiness
---
.github/workflows/deploy.yml | 6 +-
package.json | 1 +
scripts/check-site-policy.mjs | 244 +++++++++++++++++++++++++++++++++++++++++-
3 files changed, 242 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 6af8d258..ec15d4fa 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -41,10 +41,8 @@ jobs:
run: pnpm install --frozen-lockfile
- name: Typecheck
run: pnpm run typecheck
- - name: Build site
- run: pnpm run build
- - name: Check documentation and verification policy
- run: pnpm run check:site-policy
+ - name: Build and check generated site
+ run: pnpm run check:site
- name: Copy .asf.yaml
run: cp .asf.yaml build/.asf.yaml
- name: Publish to asf-site
diff --git a/package.json b/package.json
index f01b3768..2f1183b6 100644
--- a/package.json
+++ b/package.json
@@ -7,6 +7,7 @@
"docusaurus": "docusaurus",
"start": "NO_UPDATE_NOTIFIER=1 docusaurus start",
"build": "NO_UPDATE_NOTIFIER=1 docusaurus build",
+ "check:site": "pnpm run build && pnpm run check:site-policy",
"check:site-policy": "node scripts/check-site-policy.mjs",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
diff --git a/scripts/check-site-policy.mjs b/scripts/check-site-policy.mjs
index f82d43b4..5eb48345 100644
--- a/scripts/check-site-policy.mjs
+++ b/scripts/check-site-policy.mjs
@@ -16,9 +16,10 @@
// under the License.
import {readFileSync, readdirSync, statSync} from 'node:fs';
-import {join} from 'node:path';
+import {extname, join, relative} from 'node:path';
const buildDir = new URL('../build/', import.meta.url).pathname;
+const canonicalOrigin = 'https://bifromq.apache.org';
const archivedVersions = ['3.2.x', '3.1.x', '3.0.x', '2.1.x', '2.0.0', '1.0.x'];
function fail(message) {
@@ -29,23 +30,87 @@ function read(relativePath) {
return readFileSync(join(buildDir, relativePath), 'utf8');
}
-function findHtmlFiles(directory) {
+function findFiles(directory, extensions) {
return readdirSync(directory).flatMap((entry) => {
const path = join(directory, entry);
return statSync(path).isDirectory()
- ? findHtmlFiles(path)
- : path.endsWith('.html')
+ ? findFiles(path, extensions)
+ : extensions.includes(extname(path))
? [path]
: [];
});
}
+function findHtmlFiles(directory) {
+ return findFiles(directory, ['.html']);
+}
+
+function getAttribute(tag, name) {
+ return tag.match(new RegExp(`(?:^|\\s)${name}=["']([^"']*)`, 'i'))?.[1] ?? '';
+}
+
+function getTags(html, tagName) {
+ return [...html.matchAll(new RegExp(`<${tagName}\\b[^>]*>`, 'gi'))].map(
+ (match) => match[0],
+ );
+}
+
+function pagePath(htmlFile) {
+ const path = relative(buildDir, htmlFile).split('\\').join('/');
+ if (path === 'index.html') {
+ return '/';
+ }
+ return `/${path.replace(/index\.html$/, '').replace(/\.html$/, '')}`;
+}
+
+function isLocalSiteUrl(value) {
+ try {
+ return new URL(value).origin === canonicalOrigin;
+ } catch {
+ return false;
+ }
+}
+
+function findExternalResources(file, content) {
+ const matches = [];
+
+ if (file.endsWith('.html')) {
+ for (const match of content.matchAll(
+ /<(script|img|source|video|audio|iframe)\b[^>]*?\s(?:src|srcset|poster)=["'](https?:\/\/[^"'\s,>]+)/gi,
+ )) {
+ matches.push(match[2]);
+ }
+
+ for (const link of getTags(content, 'link')) {
+ const rel = getAttribute(link, 'rel');
+ const href = getAttribute(link, 'href');
+ if (
+ href.startsWith('http') &&
+ /(?:stylesheet|icon|preload|prefetch|preconnect|modulepreload)/i.test(rel)
+ ) {
+ matches.push(href);
+ }
+ }
+ }
+
+ for (const match of content.matchAll(
+ /(?:url\(|@import\s+)["']?(https?:\/\/[^"')\s]+)/gi,
+ )) {
+ matches.push(match[1]);
+ }
+
+ return matches;
+}
+
const verification = read('google55353de668345094.html').trim();
if (verification !== 'google-site-verification: google55353de668345094.html') {
fail('Google Search Console verification file is missing or invalid.');
}
const sitemap = read('sitemap.xml');
+const sitemapUrls = new Set(
+ [...sitemap.matchAll(/<loc>([^<]+)<\/loc>/g)].map((match) => match[1]),
+);
if (!sitemap.includes('https://bifromq.apache.org/docs/3.3.x/')) {
fail('The latest historical 3.x documentation must remain in the sitemap.');
}
@@ -73,4 +138,173 @@ for (const version of archivedVersions) {
}
}
-console.log('Site policy checks passed.');
+const robots = read('robots.txt');
+if (!robots.includes('User-agent: *') || !robots.includes('Allow: /')) {
+ fail('robots.txt must allow public crawling.');
+}
+if (!robots.includes('Sitemap: https://bifromq.apache.org/sitemap.xml')) {
+ fail('robots.txt must reference the canonical sitemap URL.');
+}
+
+const doap = read('doap_BifroMQ.rdf');
+for (const requiredValue of [
+ '<doap:name>Apache BifroMQ</doap:name>',
+ '<asfext:pmc rdf:resource="https://incubator.apache.org/" />',
+ '<doap:revision>4.0.0-incubating</doap:revision>',
+]) {
+ if (!doap.includes(requiredValue)) {
+ fail(`The deployed DOAP file is missing: ${requiredValue}`);
+ }
+}
+
+for (const file of findFiles(buildDir, ['.html', '.css'])) {
+ const content = readFileSync(file, 'utf8');
+ const externalResources = findExternalResources(file, content);
+ if (externalResources.length > 0) {
+ fail(
+ `External resource request in ${relative(buildDir, file)}: ${externalResources[0]}`,
+ );
+ }
+}
+
+const canonicalUrls = new Set();
+let indexablePageCount = 0;
+let longTitleCount = 0;
+
+for (const htmlFile of findHtmlFiles(buildDir)) {
+ const html = readFileSync(htmlFile, 'utf8');
+ const path = pagePath(htmlFile);
+ if (!html.startsWith('<!doctype html>') || path === '/404') {
+ continue;
+ }
+
+ const metaTags = getTags(html, 'meta');
+ const robotsMeta = metaTags.find((tag) => getAttribute(tag, 'name') === 'robots');
+ if (getAttribute(robotsMeta ?? '', 'content').includes('noindex')) {
+ continue;
+ }
+
+ indexablePageCount += 1;
+ const title = html.match(/<title[^>]*>([\s\S]*?)<\/title>/i)?.[1]?.trim() ?? '';
+ const description = metaTags.find(
+ (tag) => getAttribute(tag, 'name') === 'description',
+ );
+ const canonical = getTags(html, 'link').find(
+ (tag) => getAttribute(tag, 'rel') === 'canonical',
+ );
+ const canonicalUrl = getAttribute(canonical ?? '', 'href');
+ const h1Count = (html.match(/<h1(?:\s|>)/gi) ?? []).length;
+ const openGraphImage = metaTags.find(
+ (tag) => getAttribute(tag, 'property') === 'og:image',
+ );
+ const twitterImage = metaTags.find(
+ (tag) => getAttribute(tag, 'name') === 'twitter:image',
+ );
+
+ if (!title) {
+ fail(`Indexable page is missing a title: ${path}`);
+ }
+ if (title.length > 70) {
+ longTitleCount += 1;
+ }
+ if (!getAttribute(description ?? '', 'content').trim()) {
+ fail(`Indexable page is missing a description: ${path}`);
+ }
+ if (!isLocalSiteUrl(canonicalUrl)) {
+ fail(`Indexable page has a missing or non-canonical URL: ${path}`);
+ }
+ if (h1Count !== 1) {
+ fail(`Indexable page must have exactly one H1 (${h1Count} found): ${path}`);
+ }
+ if (!isLocalSiteUrl(getAttribute(openGraphImage ?? '', 'content'))) {
+ fail(`Indexable page is missing a local Open Graph image: ${path}`);
+ }
+ if (!isLocalSiteUrl(getAttribute(twitterImage ?? '', 'content'))) {
+ fail(`Indexable page is missing a local Twitter image: ${path}`);
+ }
+ if (canonicalUrls.has(canonicalUrl)) {
+ fail(`Duplicate canonical URL: ${canonicalUrl}`);
+ }
+ canonicalUrls.add(canonicalUrl);
+
+ for (const match of html.matchAll(
+ /<script[^>]+type=["']application\/ld\+json["'][^>]*>([\s\S]*?)<\/script>/gi,
+ )) {
+ try {
+ JSON.parse(match[1]);
+ } catch (error) {
+ fail(`Invalid JSON-LD on ${path}: ${error.message}`);
+ }
+ }
+}
+
+for (const canonicalUrl of canonicalUrls) {
+ if (!sitemapUrls.has(canonicalUrl)) {
+ fail(`Indexable canonical URL is missing from sitemap.xml: ${canonicalUrl}`);
+ }
+}
+for (const sitemapUrl of sitemapUrls) {
+ if (!canonicalUrls.has(sitemapUrl)) {
+ fail(`sitemap.xml contains a non-indexable or non-canonical URL: ${sitemapUrl}`);
+ }
+}
+
+const sharedRequirements = [
+ 'Apache BifroMQ is an effort undergoing incubation',
+ '/img/apache-incubator.svg',
+ 'https://incubator.apache.org/',
+ 'https://www.apache.org/',
+ 'https://www.apache.org/licenses/',
+ 'https://www.apache.org/security/',
+ 'https://www.apache.org/foundation/sponsorship.html',
+ 'https://www.apache.org/foundation/thanks.html',
+ 'https://www.apache.org/foundation/policies/conduct.html',
+ 'https://privacy.apache.org/policies/privacy-policy-public.html',
+ '/download/',
+ '/docs/get_started/intro/',
+ 'https://github.com/apache/bifromq/issues',
+ 'mailto:dev@bifromq.apache.org',
+];
+
+for (const representativePage of [
+ 'index.html',
+ 'docs/get_started/intro/index.html',
+ 'community/index.html',
+]) {
+ const html = read(representativePage);
+ for (const requiredValue of sharedRequirements) {
+ if (!html.includes(requiredValue)) {
+ fail(`${representativePage} is missing shared site requirement: ${requiredValue}`);
+ }
+ }
+}
+
+const communityPage = read('community/index.html');
+if (
+ !communityPage.includes('https://lists.apache.org/list.html?dev@bifromq.apache.org') ||
+ !communityPage.includes('Project decisions are made on the public')
+) {
+ fail('The community page must identify the public dev list and archive as decision channels.');
+}
+
+const homepage = read('index.html');
+const homepageJsonLd = [
+ ...homepage.matchAll(
+ /<script[^>]+type=["']application\/ld\+json["'][^>]*>([\s\S]*?)<\/script>/gi,
+ ),
+].map((match) => JSON.parse(match[1]));
+const homepageGraph = homepageJsonLd.flatMap((value) => value['@graph'] ?? [value]);
+for (const requiredType of ['WebSite', 'SoftwareApplication']) {
+ if (!homepageGraph.some((value) => value['@type'] === requiredType)) {
+ fail(`Homepage JSON-LD is missing ${requiredType}.`);
+ }
+}
+const software = homepageGraph.find((value) => value['@type'] === 'SoftwareApplication');
+if (software.publisher?.name !== 'The Apache Software Foundation') {
+ fail('Homepage software JSON-LD must identify The Apache Software Foundation as publisher.');
+}
+
+console.log(
+ `Site policy checks passed for ${indexablePageCount} indexable pages ` +
+ `(${longTitleCount} titles longer than 70 characters).`,
+);