mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
gauge: add plugin loading tests
Adds tests to every plugin which makes sure installation works. Also adds another test to gauge itself to make sure all plugins load correctly when installed simultaneously.
This commit is contained in:
parent
c30eb0c5e6
commit
73c318b001
@ -3,6 +3,7 @@ lib.makeScope pkgs.newScope (final: let
|
||||
inherit (final) callPackage;
|
||||
in {
|
||||
makeGaugePlugin = callPackage ./make-gauge-plugin.nix { };
|
||||
testGaugePlugins = callPackage ./test-gauge-plugins.nix { };
|
||||
dotnet = callPackage ./dotnet { };
|
||||
html-report = callPackage ./html-report { };
|
||||
java = callPackage ./java { };
|
||||
|
@ -3,6 +3,7 @@
|
||||
, lib
|
||||
, writeScript
|
||||
, autoPatchelfHook
|
||||
, testGaugePlugins
|
||||
}:
|
||||
|
||||
{ pname
|
||||
@ -41,57 +42,60 @@ stdenvNoCC.mkDerivation (finalAttrs: (lib.recursiveUpdate {
|
||||
cp -r . "$out/share/gauge-plugins/${pname}/${finalAttrs.version}"
|
||||
'';
|
||||
|
||||
passthru.updateScript = writeScript "update-${finalAttrs.pname}" ''
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl nix-prefetch yq-go
|
||||
passthru = {
|
||||
tests.loadPlugin = testGaugePlugins { plugins = [ finalAttrs.finalPackage ]; };
|
||||
updateScript = writeScript "update-${finalAttrs.pname}" ''
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl nix-prefetch yq-go
|
||||
|
||||
set -e
|
||||
set -e
|
||||
|
||||
dirname="pkgs/development/tools/gauge/plugins/${pname}"
|
||||
dirname="pkgs/development/tools/gauge/plugins/${pname}"
|
||||
|
||||
currentVersion=$(nix eval --raw -f default.nix gaugePlugins.${pname}.version)
|
||||
currentVersion=$(nix eval --raw -f default.nix gaugePlugins.${pname}.version)
|
||||
|
||||
latestTag=$(curl -s ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} https://api.github.com/repos/${repo}/releases/latest | yq ".tag_name")
|
||||
latestVersion="$(expr $latestTag : 'v\(.*\)')"
|
||||
latestTag=$(curl -s ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} https://api.github.com/repos/${repo}/releases/latest | yq ".tag_name")
|
||||
latestVersion="$(expr $latestTag : 'v\(.*\)')"
|
||||
|
||||
tempfile=$(mktemp)
|
||||
tempfile=$(mktemp)
|
||||
|
||||
if [[ "$FORCE_UPDATE" != "true" && "$currentVersion" == "$latestVersion" ]]; then
|
||||
echo "gauge-${pname} is up-to-date: ''${currentVersion}"
|
||||
exit 0
|
||||
fi
|
||||
if [[ "$FORCE_UPDATE" != "true" && "$currentVersion" == "$latestVersion" ]]; then
|
||||
echo "gauge-${pname} is up-to-date: ''${currentVersion}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
yq -iPoj "{ \"version\": \"$latestVersion\" }" "$tempfile"
|
||||
yq -iPoj "{ \"version\": \"$latestVersion\" }" "$tempfile"
|
||||
|
||||
updateSystem() {
|
||||
system=$1
|
||||
url=$2
|
||||
updateSystem() {
|
||||
system=$1
|
||||
url=$2
|
||||
|
||||
echo "Fetching hash for $system"
|
||||
hash=$(nix-prefetch-url --type sha256 $url --unpack)
|
||||
sriHash="$(nix hash to-sri --type sha256 $hash)"
|
||||
echo "Fetching hash for $system"
|
||||
hash=$(nix-prefetch-url --type sha256 $url --unpack)
|
||||
sriHash="$(nix hash to-sri --type sha256 $hash)"
|
||||
|
||||
yq -iPoj ". + { \"$system\": { \"url\": \"$url\", \"hash\": \"$sriHash\" } }" "$tempfile"
|
||||
}
|
||||
yq -iPoj ". + { \"$system\": { \"url\": \"$url\", \"hash\": \"$sriHash\" } }" "$tempfile"
|
||||
}
|
||||
|
||||
updateSingle() {
|
||||
url=$1
|
||||
updateSingle() {
|
||||
url=$1
|
||||
|
||||
echo "Fetching hash"
|
||||
hash=$(nix-prefetch-url --type sha256 $url --unpack)
|
||||
sriHash="$(nix hash to-sri --type sha256 $hash)"
|
||||
echo "Fetching hash"
|
||||
hash=$(nix-prefetch-url --type sha256 $url --unpack)
|
||||
sriHash="$(nix hash to-sri --type sha256 $hash)"
|
||||
|
||||
yq -iPoj ". + { \"url\": \"$url\", \"hash\": \"$sriHash\" }" "$tempfile"
|
||||
}
|
||||
yq -iPoj ". + { \"url\": \"$url\", \"hash\": \"$sriHash\" }" "$tempfile"
|
||||
}
|
||||
|
||||
baseUrl="https://github.com/${repo}/releases/download/$latestTag/${releasePrefix}$latestVersion"
|
||||
baseUrl="https://github.com/${repo}/releases/download/$latestTag/${releasePrefix}$latestVersion"
|
||||
|
||||
${if isCrossArch then
|
||||
"updateSingle \${baseUrl}.zip"
|
||||
else
|
||||
lib.concatStringsSep "\n" (map (platform: ''updateSystem "${platform}" "''${baseUrl}-${systemMap.${platform}}.zip"'') meta.platforms)
|
||||
}
|
||||
${if isCrossArch then
|
||||
"updateSingle \${baseUrl}.zip"
|
||||
else
|
||||
lib.concatStringsSep "\n" (map (platform: ''updateSystem "${platform}" "''${baseUrl}-${systemMap.${platform}}.zip"'') meta.platforms)
|
||||
}
|
||||
|
||||
mv "$tempfile" "$dirname/data.json"
|
||||
'';
|
||||
mv "$tempfile" "$dirname/data.json"
|
||||
'';
|
||||
};
|
||||
} otherArgs))
|
||||
|
35
pkgs/development/tools/gauge/plugins/test-gauge-plugins.nix
Normal file
35
pkgs/development/tools/gauge/plugins/test-gauge-plugins.nix
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
runCommand,
|
||||
gauge,
|
||||
lib,
|
||||
}:
|
||||
|
||||
/**
|
||||
Creates a gauge install with all given plugins and makes sure every plugin is loaded.
|
||||
*/
|
||||
{ plugins }:
|
||||
|
||||
let
|
||||
gaugeWithPlugins = gauge.withPlugins (_: plugins);
|
||||
in
|
||||
|
||||
runCommand "gauge-test" { nativeBuildInputs = [ gaugeWithPlugins ]; } ''
|
||||
mkdir $out
|
||||
echo $(gauge install || true) > $out/output.txt
|
||||
|
||||
function checkPlugin() {
|
||||
plugin="$1"
|
||||
version="$2"
|
||||
|
||||
echo Checking for plugin $plugin version $version
|
||||
if ! grep "$plugin ($version)" $out/output.txt
|
||||
then
|
||||
echo "Couldn't find plugin $plugin version $version"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
${lib.concatMapStringsSep "\n" (
|
||||
p: "checkPlugin '${lib.removePrefix "gauge-plugin-" p.pname}' '${p.version}'"
|
||||
) plugins}
|
||||
''
|
@ -6,6 +6,7 @@
|
||||
, xorg
|
||||
, gaugePlugins
|
||||
, plugins ? []
|
||||
, runCommand
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
@ -53,6 +54,8 @@ stdenvNoCC.mkDerivation {
|
||||
requiredPlugins = with manifest; [ Language ] ++ Plugins;
|
||||
manifestPlugins = plugins: map (name: plugins.${name} or (throw "Gauge plugin ${name} is not available!")) requiredPlugins;
|
||||
in gauge.withPlugins manifestPlugins;
|
||||
# Builds gauge with all plugins and checks for successful installation
|
||||
tests.allPlugins = gaugePlugins.testGaugePlugins { plugins = lib.filter lib.isDerivation (lib.attrValues gaugePlugins); };
|
||||
};
|
||||
|
||||
inherit (gauge-unwrapped) meta;
|
||||
|
Loading…
Reference in New Issue
Block a user