antora: verify core functionality with a minimal working example

Link: https://github.com/NixOS/nixpkgs/pull/332341
This commit is contained in:
NAHO 2024-09-15 19:28:51 +02:00
parent c5f5cc355f
commit d5443c9174
No known key found for this signature in database
GPG Key ID: 229CB671D09B95F5
5 changed files with 79 additions and 1 deletions

View File

@ -1,5 +1,6 @@
{
buildNpmPackage,
callPackage,
fetchFromGitLab,
lib,
nix-update-script,
@ -29,7 +30,10 @@ buildNpmPackage rec {
ln -s $out/lib/node_modules/antora-build/packages/cli/bin/antora $out/bin/antora
'';
passthru.updateScript = nix-update-script { };
passthru = {
tests.run = callPackage ./test { };
updateScript = nix-update-script { };
};
meta = with lib; {
description = "Modular documentation site generator. Designed for users of Asciidoctor";

View File

@ -0,0 +1,63 @@
{
antora,
antora-ui-default,
gitMinimal,
lib,
stdenvNoCC,
}:
stdenvNoCC.mkDerivation {
name = "${antora.pname}-test";
src = ./minimal_working_example;
postPatch =
let
date = lib.escapeShellArg "1/1/1970 00:00:00 +0000";
in
''
# > In order to use a local content repository with Antora, even when using
# > the worktree (HEAD), the repository must have at least one commit.
# >
# > -- https://docs.antora.org/antora/3.1/playbook/content-source-url
git init &&
GIT_AUTHOR_DATE=${date} \
GIT_AUTHOR_EMAIL= \
GIT_AUTHOR_NAME=Nixpkgs \
GIT_COMMITTER_DATE=${date} \
GIT_COMMITTER_EMAIL= \
GIT_COMMITTER_NAME=Nixpkgs \
git commit --allow-empty --allow-empty-message --message ""
'';
buildPhase =
let
playbook = builtins.toFile "antora-playbook.json" (
builtins.toJSON {
content.sources = [ { url = "~+"; } ];
runtime.log.failure_level = "warn";
}
);
in
''
# The --to-dir and --ui-bundle-url options are not included in the
# playbook due to Antora and Nix limitations.
antora ${
lib.cli.toGNUCommandLineShell { } {
cache-dir = "$(mktemp --directory)";
to-dir = placeholder "out";
ui-bundle-url = "${antora-ui-default}/ui-bundle.zip";
}
} "${playbook}"
'';
nativeBuildInputs = [
antora
gitMinimal
];
meta = {
description = "Reproducible Antora test framework";
license = lib.licenses.mit;
maintainers = [ lib.maintainers.naho ];
platforms = lib.platforms.all;
};
}

View File

@ -0,0 +1,7 @@
---
name: Antora
nav:
- modules/ROOT/nav.adoc
version: ~

View File

@ -0,0 +1 @@
* xref:index.adoc[]

View File

@ -0,0 +1,3 @@
= Antora
== Minimal Working Example