From a8f16814c298253ae9bf51e5303cd57924d619b7 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 5 Dec 2026 12:09:32 -0600 Subject: [PATCH] feat(ci[lua]) Export Lua in the reusable docs workflow why: Lua cannot share the port docs builder without exporting the selected source with its native tooling. what: - Record the Lua generator checkout before the source snapshot. - Install its pinned LuaJIT, LuaLS, and rocks and run its exporter. - Check the export order, quoted arguments and failure propagation. --- .github/workflows/port-docs.yml | 31 +++++++++++++++++++- docs/ci.md | 4 +++ site/test/port-docs-runtime.test.ts | 45 +++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/.github/workflows/port-docs.yml b/.github/workflows/port-docs.yml index ab5d4e332..0666b5c87 100644 --- a/.github/workflows/port-docs.yml +++ b/.github/workflows/port-docs.yml @@ -202,7 +202,7 @@ jobs: # The caller's tooling can document an older selected source revision. # Record both checkouts before either native exporter produces files. - name: Check out native documentation tooling - if: matrix.port == 'powershell' || matrix.port == 'julia' + if: matrix.port == 'powershell' || matrix.port == 'julia' || matrix.port == 'lua' uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: # A port caller's generator is its own tooling at the caller's commit. @@ -213,6 +213,10 @@ jobs: path: docs-generator persist-credentials: false + - name: Record the Lua documentation tooling checkout + if: matrix.port == 'lua' + run: echo "LIBTMUX_DOCS_GENERATOR_CHECKOUT=$GITHUB_WORKSPACE/docs-generator" >> "$GITHUB_ENV" + - name: Read native documentation toolchain if: matrix.port == 'powershell' || matrix.port == 'julia' id: docs-runtime @@ -685,6 +689,31 @@ jobs: if: matrix.port == 'raku' run: zef install --/test JSON::Fast + - name: Install the selected Lua tooling + if: matrix.port == 'lua' + uses: jdx/mise-action@3277a0f272901982804abc53abd93520db809be4 # v5.4.0 + with: + version: 2026.9.9 + working_directory: docs-generator + cache: false + - name: Bootstrap the pinned LuaLS exporter and its LuaJIT + if: matrix.port == 'lua' + working-directory: docs-generator + run: | + set -euo pipefail + lua scripts/bootstrap/bootstrap.lua runtimes luajit + lua scripts/bootstrap/bootstrap.lua rocks dev live --lua=.cache/toolchains/luajit-2.1/bin/luajit + lua scripts/bootstrap/bootstrap.lua luals + - name: Export Lua API from the selected source + if: matrix.port == 'lua' + working-directory: docs-generator + run: | + set -euo pipefail + .cache/toolchains/luajit-2.1/bin/luajit scripts/docs/docs.lua export \ + --source "$GITHUB_WORKSPACE/port" \ + --luals "$GITHUB_WORKSPACE/docs-generator/.cache/tools/luals-3.19.1/bin/lua-language-server" \ + --output "$GITHUB_WORKSPACE/port/docs/_build" + - name: Install Common Lisp documentation toolchain if: matrix.port == 'lisp' uses: jdx/mise-action@3277a0f272901982804abc53abd93520db809be4 # v5.4.0 diff --git a/docs/ci.md b/docs/ci.md index 65641f3f5..0a65b3907 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -142,6 +142,10 @@ record itself is excluded from the inventory; symlinks are rejected. Ruby and Lua also record `nativeGenerator`: the native exporter's repository, commit, and dirty state. Their custom callers keep the source, exporter, and shared docs in separate checkouts and set `LIBTMUX_DOCS_GENERATOR_CHECKOUT`. +The reusable `port-docs.yml` Lua job uses the same layout. A Lua caller can +build an older revision with the exporter from its own workflow commit. To +build a release that used a shell launcher, select a Lua tooling revision +whose exporter accepts that release's manifest. Local native builds default to the exporter in the selected source checkout. The publisher requires a clean exporter from the port's owning repository. diff --git a/site/test/port-docs-runtime.test.ts b/site/test/port-docs-runtime.test.ts index da6712aad..e7e17995e 100644 --- a/site/test/port-docs-runtime.test.ts +++ b/site/test/port-docs-runtime.test.ts @@ -583,6 +583,51 @@ require('node:fs').appendFileSync(process.env.EXPORT_CALLS, JSON.stringify({ too }) }) +describe('Lua documentation producer', () => { + it('exports with the tooling checkout after the snapshot and before assembly', () => { + const step = (name: string) => workflow.split(/\n(?= - )/).find((value) => value.includes(`name: ${name}\n`))! + const at = (name: string) => workflow.indexOf(`name: ${name}\n`) + const snapshot = at('Snapshot source inputs before native generation') + const names = ['Install the selected Lua tooling', 'Bootstrap the pinned LuaLS exporter and its LuaJIT', 'Export Lua API from the selected source'] + expect(at('Record the Lua documentation tooling checkout')).toBeLessThan(snapshot) + const order = [snapshot, ...names.map(at), at("Build this port's tree")] + expect(order).toEqual(order.toSorted((a, b) => a - b)) + expect(order[0]).toBeGreaterThan(-1) + expect(step('Check out native documentation tooling')).toContain("matrix.port == 'lua'") + expect(step('Check out native documentation tooling')).toContain("ref: ${{ inputs.source-repository && needs.identity.outputs.source-ref || github.sha }}") + for (const name of names) expect(step(name)).toContain("if: matrix.port == 'lua'") + for (const name of names.slice(1)) expect(step(name)).toContain('working-directory: docs-generator') + expect(step(names[0])).toContain('working_directory: docs-generator') + expect(step('Record the Lua documentation tooling checkout')).toContain('LIBTMUX_DOCS_GENERATOR_CHECKOUT=$GITHUB_WORKSPACE/docs-generator') + expect(script('Export Lua API from the selected source')).toContain('scripts/docs/docs.lua export') + expect(script('Export Lua API from the selected source')).toContain('--output "$GITHUB_WORKSPACE/port/docs/_build"') + }) + + it.each([0, 23])('runs the Lua exporter with source and output paths intact and propagates exit %s', (exitCode) => { + const workspace = mkdtempSync(join(tmpdir(), 'libtmux Lua workflow ')) + const generator = join(workspace, 'docs-generator') + const runtime = join(generator, '.cache/toolchains/luajit-2.1/bin') + try { + mkdirSync(runtime, { recursive: true }) + writeFileSync(join(runtime, 'luajit'), `#!${process.execPath} +process.stdout.write(JSON.stringify(process.argv.slice(2))) +process.exitCode = ${exitCode} +`, { mode: 0o700 }) + const result = spawnSync('bash', ['-e', '-c', script('Export Lua API from the selected source')], { + cwd: generator, encoding: 'utf8', timeout: 5000, + env: { ...process.env, GITHUB_WORKSPACE: workspace }, + }) + expect(result.status, result.stderr).toBe(exitCode) + expect(JSON.parse(result.stdout)).toEqual([ + 'scripts/docs/docs.lua', 'export', + '--source', join(workspace, 'port'), + '--luals', join(generator, '.cache/tools/luals-3.19.1/bin/lua-language-server'), + '--output', join(workspace, 'port/docs/_build'), + ]) + } finally { rmSync(workspace, { recursive: true, force: true }) } + }) +}) + describe('Erlang documentation producer', () => { function toolchain(source?: string) { const directory = mkdtempSync(join(tmpdir(), 'libtmux-erlang-toolchain-'))