Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 135 lines 4.4 kB view raw
1{ 2 jetbrains, 3 symlinkJoin, 4 lib, 5 runCommand, 6 # If not set, all IDEs are tested. 7 ideName ? null, 8}: 9 10let 11 12 # Known broken plugins, PLEASE remove entries here whenever possible. 13 broken-plugins = [ 14 "github-copilot" # GitHub Copilot: https://github.com/NixOS/nixpkgs/issues/400317 15 ]; 16 17 ides = 18 if ideName == null then 19 with jetbrains; 20 [ 21 aqua 22 clion 23 datagrip 24 dataspell 25 gateway 26 goland 27 idea-community-src 28 idea-community-bin 29 idea-ultimate 30 mps 31 phpstorm 32 pycharm-community-src 33 pycharm-community-bin 34 pycharm-professional 35 rider 36 ruby-mine 37 rust-rover 38 webstorm 39 writerside 40 ] 41 else 42 [ (jetbrains.${ideName}) ]; 43in 44{ 45 # Check to see if the process for adding plugins is breaking anything, instead of the plugins themselves 46 empty = 47 let 48 modify-ide = ide: jetbrains.plugins.addPlugins ide [ ]; 49 in 50 symlinkJoin { 51 name = "jetbrains-test-plugins-empty"; 52 paths = (map modify-ide ides); 53 }; 54 55 # Test all plugins. This will only build plugins compatible with the IDE and version. It will fail if the plugin is marked 56 # as compatible, but the build version is somehow not in the "builds" map (as that would indicate that something with update_plugins.py went wrong). 57 all = 58 let 59 plugins-json = builtins.fromJSON (builtins.readFile ./plugins.json); 60 plugins-for = 61 with lib.asserts; 62 ide: 63 builtins.map (plugin: plugin.name) ( 64 builtins.filter ( 65 plugin: 66 ( 67 # Plugin has to not be broken 68 (!builtins.elem plugin.name broken-plugins) 69 # IDE has to be compatible 70 && (builtins.elem ide.pname plugin.compatible) 71 # Assert: The build number needs to be included (if marked compatible) 72 && (assertMsg (builtins.elem ide.buildNumber (builtins.attrNames plugin.builds)) "For plugin ${plugin.name} no entry for IDE build ${ide.buildNumber} is defined, even though ${ide.pname} is on that build.") 73 # The plugin has to exist for the build 74 && (plugin.builds.${ide.buildNumber} != null) 75 ) 76 ) (builtins.attrValues plugins-json.plugins) 77 ); 78 modify-ide = ide: jetbrains.plugins.addPlugins ide (plugins-for ide); 79 in 80 symlinkJoin { 81 name = "jetbrains-test-plugins-all"; 82 paths = (map modify-ide ides); 83 }; 84 85 # This test builds the IDEs with some plugins and checks that they can be discovered by the IDE. 86 # Test always succeeds on IDEs that the tested plugins don't support. 87 stored-correctly = 88 let 89 plugins-json = builtins.fromJSON (builtins.readFile ./plugins.json); 90 plugin-ids = [ 91 # This is a "normal plugin", it's output must be linked into /${pname}/plugins. 92 "8607" # nixidea 93 # This is a plugin where the output contains a single JAR file. This JAR file needs to be linked directly in /${pname}/plugins. 94 "7425" # wakatime 95 ]; 96 check-if-supported = 97 ide: 98 builtins.all ( 99 plugin: 100 (builtins.elem ide.pname plugins-json.plugins.${plugin}.compatible) 101 && (plugins-json.plugins.${plugin}.builds.${ide.buildNumber} != null) 102 ) plugin-ids; 103 modify-ide = ide: jetbrains.plugins.addPlugins ide plugin-ids; 104 in 105 runCommand "test-jetbrains-plugins-stored-correctly" 106 { 107 idePaths = (map modify-ide (builtins.filter check-if-supported ides)); 108 } 109 # TODO: instead of globbing using $ide/*/plugins we could probably somehow get the package name here properly. 110 '' 111 set -e 112 exec &> >(tee -a "$out") 113 114 IFS=' ' read -ra ideArray <<< "$idePaths" 115 for ide in "''${ideArray[@]}"; do 116 echo "processing $ide" 117 118 echo "> ensure normal plugin is available" 119 ( 120 set -x 121 find -L $ide/*/plugins -type f -iname 'NixIDEA-*.jar' | grep . 122 ) 123 124 echo "> ensure single JAR file plugin is available" 125 ( 126 set -x 127 PATH_TO_LINK=$(find $ide/*/plugins -maxdepth 1 -type l -iname '*wakatime.jar' | grep .) 128 test -f $(readlink $PATH_TO_LINK) 129 ) 130 echo "" 131 done 132 133 echo "test done! ok!" 134 ''; 135}