at 23.11-beta 2.5 kB view raw
1# to run these tests (and the others) 2# nix-build nixpkgs/lib/tests/release.nix 3# These tests should stay in sync with the comment in maintainers/maintainers-list.nix 4{ # The pkgs used for dependencies for the testing itself 5 pkgs ? import ../.. {} 6, lib ? pkgs.lib 7}: 8 9let 10 checkMaintainer = handle: uncheckedAttrs: 11 let 12 prefix = [ "lib" "maintainers" handle ]; 13 checkedAttrs = (lib.modules.evalModules { 14 inherit prefix; 15 modules = [ 16 ./maintainer-module.nix 17 { 18 _file = toString ../../maintainers/maintainer-list.nix; 19 config = uncheckedAttrs; 20 } 21 ]; 22 }).config; 23 24 checks = lib.optional (checkedAttrs.github != null && checkedAttrs.githubId == null) '' 25 echo ${lib.escapeShellArg (lib.showOption prefix)}': If `github` is specified, `githubId` must be too.' 26 # Calling this too often would hit non-authenticated API limits, but this 27 # shouldn't happen since such errors will get fixed rather quickly 28 info=$(curl -sS https://api.github.com/users/${checkedAttrs.github}) 29 id=$(jq -r '.id' <<< "$info") 30 echo "The GitHub ID for GitHub user ${checkedAttrs.github} is $id:" 31 echo -e " githubId = $id;\n" 32 '' ++ lib.optional (checkedAttrs.email == null && checkedAttrs.github == null && checkedAttrs.matrix == null) '' 33 echo ${lib.escapeShellArg (lib.showOption prefix)}': At least one of `email`, `github` or `matrix` must be specified, so that users know how to reach you.' 34 '' ++ lib.optional (checkedAttrs.email != null && lib.hasSuffix "noreply.github.com" checkedAttrs.email) '' 35 echo ${lib.escapeShellArg (lib.showOption prefix)}': If an email address is given, it should allow people to reach you. If you do not want that, you can just provide `github` or `matrix` instead.' 36 ''; 37 in lib.deepSeq checkedAttrs checks; 38 39 missingGithubIds = lib.concatLists (lib.mapAttrsToList checkMaintainer lib.maintainers); 40 41 success = pkgs.runCommand "checked-maintainers-success" {} ">$out"; 42 43 failure = pkgs.runCommand "checked-maintainers-failure" { 44 nativeBuildInputs = [ pkgs.curl pkgs.jq ]; 45 outputHash = "sha256:${lib.fakeSha256}"; 46 outputHAlgo = "sha256"; 47 outputHashMode = "flat"; 48 SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; 49 } '' 50 ${lib.concatStringsSep "\n" missingGithubIds} 51 exit 1 52 ''; 53in if missingGithubIds == [] then success else failure