Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ defaults:

jobs:
build-tests:
runs-on: ubuntu-latest
name: build-tests (${{ matrix.os }}, hugo ${{ matrix.hugo-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# 0.161.1 embeds KaTeX 0.16.x; 0.166.0 embeds KaTeX 0.18.x. Testing
# both covers each branch of the KaTeX CSS version selection in
# layouts/_partials/scripts/katex.html.
hugo-version: ["0.161.1", "0.166.0"]
env:
HUGO_VERSION: ${{ matrix.hugo-version }}
# These specs build temporary Hugo sites and inspect the output files
# directly, so no browser or web server is needed. Setting BASE_URL
# keeps Playwright from starting the docs webServer.
Expand All @@ -35,27 +36,36 @@ jobs:
fetch-depth: 0
submodules: recursive

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.26"

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "24"
cache: npm

- name: Setup Hugo
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
uses: peaceiris/actions-hugo@v3
with:
hugo-version: ${{ matrix.hugo-version }}
extended: true

- name: Install dependencies
run: npm ci

- name: Build docs site
run: npm run build

- name: Run build tests
run: npm run test:build

- name: Upload report
if: always()
uses: actions/upload-artifact@v4
with:
name: build-tests-report-hugo-${{ matrix.hugo-version }}
name: build-tests-report-${{ matrix.os }}-hugo-${{ matrix.hugo-version }}
path: playwright-report/
retention-days: 14
26 changes: 16 additions & 10 deletions tests/asciidoc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, expect } from "@playwright/test";
import { execFileSync } from "node:child_process";
import { chmodSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { delimiter, join } from "node:path";

test("AsciiDoc pages provide TOC and search fragments", () => {
const siteDir = mkdtempSync(join(tmpdir(), "hextra-asciidoc-"));
Expand All @@ -16,13 +16,12 @@ test("AsciiDoc pages provide TOC and search fragments", () => {
mkdirSync(binDir);
symlinkSync(process.cwd(), join(themesDir, "hextra"), "dir");

const asciidoctorPath = join(binDir, "asciidoctor");
// Windows can't run shebang scripts, so use a .cmd launcher there.
writeFileSync(
asciidoctorPath,
`#!/bin/sh
cat >/dev/null
cat <<'HTML'
<div class="sect1">
join(binDir, "asciidoctor.js"),
`process.stdin.resume();
process.stdin.on("end", () => {
process.stdout.write(\`<div class="sect1">
<h2 id="_overview">Overview</h2>
<div class="sectionbody">
<div class="paragraph"><p>AsciiDoc paragraph content.</p></div>
Expand All @@ -32,10 +31,17 @@ cat <<'HTML'
</div>
</div>
</div>
HTML
\`);
});
`
);
chmodSync(asciidoctorPath, 0o755);
if (process.platform === "win32") {
writeFileSync(join(binDir, "asciidoctor.cmd"), `@node "%~dp0asciidoctor.js" %*\r\n`);
} else {
const asciidoctorPath = join(binDir, "asciidoctor");
writeFileSync(asciidoctorPath, `#!/bin/sh\nexec node "$(dirname "$0")/asciidoctor.js" "$@"\n`);
chmodSync(asciidoctorPath, 0o755);
}

writeFileSync(
join(siteDir, "hugo.yaml"),
Expand Down Expand Up @@ -83,7 +89,7 @@ Nested detail content.
try {
execFileSync("hugo", ["--source", siteDir, "--themesDir", themesDir, "--destination", publishDir], {
cwd: process.cwd(),
env: { ...process.env, PATH: `${binDir}:${process.env.PATH}` },
env: { ...process.env, PATH: `${binDir}${delimiter}${process.env.PATH}` },
stdio: "pipe",
});

Expand Down
Loading