at 21.11-pre 2.5 kB view raw
1# to run these tests (and the others) 2# nix-build nixpkgs/lib/tests/release.nix 3{ # The pkgs used for dependencies for the testing itself 4 pkgs 5, lib 6}: 7 8let 9 inherit (lib) types; 10 11 maintainerModule = { config, ... }: { 12 options = { 13 name = lib.mkOption { 14 type = types.str; 15 }; 16 email = lib.mkOption { 17 type = types.str; 18 }; 19 github = lib.mkOption { 20 type = types.nullOr types.str; 21 default = null; 22 }; 23 githubId = lib.mkOption { 24 type = types.nullOr types.ints.unsigned; 25 default = null; 26 }; 27 keys = lib.mkOption { 28 type = types.listOf (types.submodule { 29 options.longkeyid = lib.mkOption { type = types.str; }; 30 options.fingerprint = lib.mkOption { type = types.str; }; 31 }); 32 default = []; 33 }; 34 }; 35 }; 36 37 checkMaintainer = handle: uncheckedAttrs: 38 let 39 prefix = [ "lib" "maintainers" handle ]; 40 checkedAttrs = (lib.modules.evalModules { 41 inherit prefix; 42 modules = [ 43 maintainerModule 44 { 45 _file = toString ../../maintainers/maintainer-list.nix; 46 config = uncheckedAttrs; 47 } 48 ]; 49 }).config; 50 51 checkGithubId = lib.optional (checkedAttrs.github != null && checkedAttrs.githubId == null) '' 52 echo ${lib.escapeShellArg (lib.showOption prefix)}': If `github` is specified, `githubId` must be too.' 53 # Calling this too often would hit non-authenticated API limits, but this 54 # shouldn't happen since such errors will get fixed rather quickly 55 info=$(curl -sS https://api.github.com/users/${checkedAttrs.github}) 56 id=$(jq -r '.id' <<< "$info") 57 echo "The GitHub ID for GitHub user ${checkedAttrs.github} is $id:" 58 echo -e " githubId = $id;\n" 59 ''; 60 in lib.deepSeq checkedAttrs checkGithubId; 61 62 missingGithubIds = lib.concatLists (lib.mapAttrsToList checkMaintainer lib.maintainers); 63 64 success = pkgs.runCommandNoCC "checked-maintainers-success" {} ">$out"; 65 66 failure = pkgs.runCommandNoCC "checked-maintainers-failure" { 67 nativeBuildInputs = [ pkgs.curl pkgs.jq ]; 68 outputHash = "sha256:${lib.fakeSha256}"; 69 outputHAlgo = "sha256"; 70 outputHashMode = "flat"; 71 SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; 72 } '' 73 ${lib.concatStringsSep "\n" missingGithubIds} 74 exit 1 75 ''; 76in if missingGithubIds == [] then success else failure