push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
{
callPackage,
lib,
rustPlatform,
fetchFromGitHub,
pkg-config,
openssl,
testers,
}:
rustPlatform.buildRustPackage rec {
pname = "lychee";
version = "0.20.1";
src = fetchFromGitHub {
owner = "lycheeverse";
repo = "lychee";
rev = "lychee-v${version}";
hash = "sha256-yHIj45RfQch4y+V4Ht7cDMcg5MECejxsbjuE345I/to=";
};
cargoHash = "sha256-d3umjtXPBJbPRtNCuktYhJUPgKFmB8UEeewWMekDZRE=";
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl ];
cargoTestFlags = [
# don't run doctests since they tend to use the network
"--lib"
"--bins"
"--tests"
];
checkFlags = [
# Network errors for all of these tests
# "error reading DNS system conf: No such file or directory (os error 2)" } }
"--skip=archive::wayback::tests::wayback_suggestion_real_unknown"
"--skip=archive::wayback::tests::wayback_api_no_breaking_changes"
"--skip=cli::test_dont_dump_data_uris_by_default"
"--skip=cli::test_dump_data_uris_in_verbose_mode"
"--skip=cli::test_exclude_example_domains"
"--skip=cli::test_local_dir"
"--skip=cli::test_local_file"
"--skip=client::tests"
"--skip=collector::tests"
"--skip=src/lib.rs"
# Color error for those tests as we are not in a tty
"--skip=formatters::response::color::tests::test_format_response_with_error_status"
"--skip=formatters::response::color::tests::test_format_response_with_ok_status"
];
passthru.tests = {
# NOTE: These assume that testers.lycheeLinkCheck uses this exact derivation.
# Which is true most of the time, but not necessarily after overriding.
ok = callPackage ./tests/ok.nix { };
fail = callPackage ./tests/fail.nix { };
fail-emptyDirectory = callPackage ./tests/fail-emptyDirectory.nix { };
network = testers.runNixOSTest ./tests/network.nix;
};
meta = {
description = "Fast, async, stream-based link checker written in Rust";
homepage = "https://github.com/lycheeverse/lychee";
downloadPage = "https://github.com/lycheeverse/lychee/releases/tag/lychee-v${version}";
license = with lib.licenses; [
asl20
mit
];
maintainers = with lib.maintainers; [
totoroot
tuxinaut
];
mainProgram = "lychee";
};
}

View File

@@ -0,0 +1,32 @@
{
runCommand,
testers,
emptyDirectory,
}:
let
sitePkg = runCommand "site" { } ''
dist=$out/dist
mkdir -p $dist
echo "<html><body><a href=\"https://example.com/foo\">foo</a></body></html>" > $dist/index.html
echo "<html><body></body></html>" > $dist/foo.html
'';
check = testers.lycheeLinkCheck {
site = sitePkg + "/dist";
remap = {
# Normally would recommend to append a subpath that hints why it's forbidden; see example in docs.
# However, we also want to test that a package is converted to a string *before*
# it's tested whether it's a store path. Mistake made during development caused:
# cannot check URI: InvalidUrlRemap("The remapping pattern must produce a valid URL, but it is not: /nix/store/4d0ix...empty-directory/foo
"https://example.com" = emptyDirectory;
};
};
failure = testers.testBuildFailure check;
in
runCommand "link-check-fail" { inherit failure; } ''
# The details of the message might change, but we have to make sure the
# correct error is reported, so that we know it's not something else that
# went wrong.
grep 'empty-directory/foo.*Cannot find file' $failure/testBuildFailure.log >/dev/null
touch $out
''

View File

@@ -0,0 +1,23 @@
{ runCommand, testers }:
let
sitePkg = runCommand "site" { } ''
dist=$out/dist
mkdir -p $dist
echo "<html><body><a href=\"https://example.com/foo.html#foos-missing-anchor\">foo</a></body></html>" > $dist/index.html
echo "<html><body><a href=\".\">index</a></body></html>" > $dist/foo.html
'';
linkCheck = testers.lycheeLinkCheck rec {
site = sitePkg + "/dist";
remap = {
"https://exampl[e]\\.com" = site;
};
};
failure = testers.testBuildFailure linkCheck;
in
runCommand "link-check-fail" { inherit failure; } ''
grep -F foos-missing-anchor $failure/testBuildFailure.log >/dev/null
touch $out
''

View File

@@ -0,0 +1,71 @@
{
config,
hostPkgs,
lib,
...
}:
let
sitePkg = hostPkgs.runCommand "site" { } ''
dist=$out/dist
mkdir -p $dist
echo "<html><body><a href=\"http://example/foo.html\">foo</a></body></html>" > $dist/index.html
echo "<html><body><a href=\".\">index</a></body></html>" > $dist/foo.html
'';
check = config.node.pkgs.testers.lycheeLinkCheck {
site = sitePkg;
};
in
{
name = "testers-lychee-link-check-run";
nodes.client = { ... }: { };
nodes.example = {
networking.firewall.allowedTCPPorts = [ 80 ];
services.nginx = {
enable = true;
virtualHosts."example" = {
locations."/" = {
root = "/var/www/example";
index = "index.html";
};
};
};
};
testScript = ''
start_all()
# SETUP
example.succeed("""
mkdir -p /var/www/example
echo '<h1>hi</h1>' > /var/www/example/index.html
""")
client.wait_until_succeeds("""
curl --fail -v http://example
""")
# FAILURE CASE
client.succeed("""
exec 1>&2
r=0
${lib.getExe check.online} || {
r=$?
}
if [[ $r -ne 2 ]]; then
echo "lycheeLinkCheck unexpected exit code $r"
exit 1
fi
""")
# SUCCESS CASE
example.succeed("""
echo '<h1>foo</h1>' > /var/www/example/foo.html
""")
client.succeed("""
${lib.getExe check.online}
""")
'';
}

View File

@@ -0,0 +1,15 @@
{ runCommand, testers }:
let
sitePkg = runCommand "site" { } ''
dist=$out/dist
mkdir -p $dist
echo "<html><body><a href=\"https://example.com/foo.html\">foo</a><a href=\"https://nixos.org/this-is-ignored.html\">bar</a></body></html>" > $dist/index.html
echo "<html><body><a href=\".\">index</a></body></html>" > $dist/foo.html
'';
in
testers.lycheeLinkCheck rec {
site = sitePkg + "/dist";
remap = {
"https://example.com" = site;
};
}