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; }`
|
||||
|
||||
`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}
|
||||
|
||||
: The `lychee` package to use.
|
||||
|
||||
@@ -37,6 +37,7 @@ let
|
||||
remap ? { },
|
||||
lychee ? deps.lychee,
|
||||
extraConfig ? { },
|
||||
extraArgs ? [ ],
|
||||
}:
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
name = "lychee-link-check";
|
||||
@@ -47,6 +48,7 @@ let
|
||||
cacert
|
||||
];
|
||||
configFile = (formats.toml { }).generate "lychee.toml" finalAttrs.passthru.config;
|
||||
inherit extraArgs;
|
||||
|
||||
# These can be overridden with overrideAttrs if needed.
|
||||
passthru = {
|
||||
@@ -69,13 +71,13 @@ let
|
||||
site=${finalAttrs.site}
|
||||
configFile=${finalAttrs.configFile}
|
||||
echo Checking links on $site
|
||||
exec lychee --config $configFile $site "$@"
|
||||
exec lychee --config $configFile ${lib.escapeShellArgs extraArgs} $site "$@"
|
||||
'';
|
||||
};
|
||||
};
|
||||
buildCommand = ''
|
||||
echo Checking internal links on $site
|
||||
lychee --offline --config $configFile $site
|
||||
lychee --offline --config $configFile "''${extraArgs[@]}" $site
|
||||
touch $out
|
||||
'';
|
||||
});
|
||||
|
||||
@@ -14,10 +14,21 @@ let
|
||||
check = config.node.pkgs.testers.lycheeLinkCheck {
|
||||
site = sitePkg;
|
||||
};
|
||||
checkJson = config.node.pkgs.testers.lycheeLinkCheck {
|
||||
site = sitePkg;
|
||||
extraArgs = [
|
||||
"--format"
|
||||
"json"
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
name = "testers-lychee-link-check-run";
|
||||
nodes.client = { ... }: { };
|
||||
nodes.client =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = [ pkgs.jq ];
|
||||
};
|
||||
nodes.example = {
|
||||
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||
services.nginx = {
|
||||
@@ -67,5 +78,13 @@ in
|
||||
client.succeed("""
|
||||
${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