mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
testers.lycheeLinkCheck: add extraArgs
This commit is contained in:
@@ -129,6 +129,13 @@ It has two modes:
|
|||||||
|
|
||||||
Example: `{ "include_verbatim" = true; }`
|
Example: `{ "include_verbatim" = true; }`
|
||||||
|
|
||||||
|
`extraArgs` (list of strings, optional) {#tester-lycheeLinkCheck-param-extraArgs}
|
||||||
|
|
||||||
|
: Extra command line arguments to pass to the `lychee` invocation.
|
||||||
|
These are passed in both the offline (build) and [`online`](#tester-lycheeLinkCheck-return) modes.
|
||||||
|
|
||||||
|
Example: `[ "--format" "json" ]`
|
||||||
|
|
||||||
`lychee` (derivation, optional) {#tester-lycheeLinkCheck-param-lychee}
|
`lychee` (derivation, optional) {#tester-lycheeLinkCheck-param-lychee}
|
||||||
|
|
||||||
: The `lychee` package to use.
|
: The `lychee` package to use.
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ let
|
|||||||
remap ? { },
|
remap ? { },
|
||||||
lychee ? deps.lychee,
|
lychee ? deps.lychee,
|
||||||
extraConfig ? { },
|
extraConfig ? { },
|
||||||
|
extraArgs ? [ ],
|
||||||
}:
|
}:
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
name = "lychee-link-check";
|
name = "lychee-link-check";
|
||||||
@@ -47,6 +48,7 @@ let
|
|||||||
cacert
|
cacert
|
||||||
];
|
];
|
||||||
configFile = (formats.toml { }).generate "lychee.toml" finalAttrs.passthru.config;
|
configFile = (formats.toml { }).generate "lychee.toml" finalAttrs.passthru.config;
|
||||||
|
inherit extraArgs;
|
||||||
|
|
||||||
# These can be overridden with overrideAttrs if needed.
|
# These can be overridden with overrideAttrs if needed.
|
||||||
passthru = {
|
passthru = {
|
||||||
@@ -69,13 +71,13 @@ let
|
|||||||
site=${finalAttrs.site}
|
site=${finalAttrs.site}
|
||||||
configFile=${finalAttrs.configFile}
|
configFile=${finalAttrs.configFile}
|
||||||
echo Checking links on $site
|
echo Checking links on $site
|
||||||
exec lychee --config $configFile $site "$@"
|
exec lychee --config $configFile ${lib.escapeShellArgs extraArgs} $site "$@"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
echo Checking internal links on $site
|
echo Checking internal links on $site
|
||||||
lychee --offline --config $configFile $site
|
lychee --offline --config $configFile "''${extraArgs[@]}" $site
|
||||||
touch $out
|
touch $out
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,10 +14,21 @@ let
|
|||||||
check = config.node.pkgs.testers.lycheeLinkCheck {
|
check = config.node.pkgs.testers.lycheeLinkCheck {
|
||||||
site = sitePkg;
|
site = sitePkg;
|
||||||
};
|
};
|
||||||
|
checkJson = config.node.pkgs.testers.lycheeLinkCheck {
|
||||||
|
site = sitePkg;
|
||||||
|
extraArgs = [
|
||||||
|
"--format"
|
||||||
|
"json"
|
||||||
|
];
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
name = "testers-lychee-link-check-run";
|
name = "testers-lychee-link-check-run";
|
||||||
nodes.client = { ... }: { };
|
nodes.client =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = [ pkgs.jq ];
|
||||||
|
};
|
||||||
nodes.example = {
|
nodes.example = {
|
||||||
networking.firewall.allowedTCPPorts = [ 80 ];
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
@@ -67,5 +78,13 @@ in
|
|||||||
client.succeed("""
|
client.succeed("""
|
||||||
${lib.getExe check.online}
|
${lib.getExe check.online}
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
# EXTRA ARGS CASE: verify extraArgs are passed through to online wrapper
|
||||||
|
|
||||||
|
with subtest("extraArgs are passed to the online wrapper"):
|
||||||
|
client.succeed("""
|
||||||
|
${lib.getExe checkJson.online} --output /tmp/lychee.json
|
||||||
|
jq -e .total /tmp/lychee.json
|
||||||
|
""")
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user