From 80609a726d455b4880e10296c147bb73ace8cc19 Mon Sep 17 00:00:00 2001 From: Marie Ramlow Date: Fri, 16 Aug 2024 10:20:31 +0200 Subject: [PATCH 1/6] gaugePlugins.makeGaugePlugin: fix updateScript --- pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix b/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix index 81fbff823802..b9a4b1441632 100644 --- a/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix +++ b/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix @@ -71,7 +71,7 @@ stdenvNoCC.mkDerivation (finalAttrs: (lib.recursiveUpdate { 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() { @@ -81,7 +81,7 @@ stdenvNoCC.mkDerivation (finalAttrs: (lib.recursiveUpdate { 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" From 66839cb7d27e631637ea645dcb16847ecb39d7e9 Mon Sep 17 00:00:00 2001 From: Marie Ramlow Date: Fri, 16 Aug 2024 08:23:11 +0000 Subject: [PATCH 2/6] gaugePlugins.screenshot: 0.2.0 -> 0.3.0 --- .../tools/gauge/plugins/screenshot/data.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkgs/development/tools/gauge/plugins/screenshot/data.json b/pkgs/development/tools/gauge/plugins/screenshot/data.json index c836d5a84a95..bc2c83ad6425 100644 --- a/pkgs/development/tools/gauge/plugins/screenshot/data.json +++ b/pkgs/development/tools/gauge/plugins/screenshot/data.json @@ -1,19 +1,19 @@ { - "version": "0.2.0", + "version": "0.3.0", "x86_64-darwin": { - "url": "https://github.com/getgauge/gauge_screenshot/releases/download/v0.2.0/screenshot-0.2.0-darwin.x86_64.zip", - "hash": "sha256-7bFuInEYAQ+fN12HTazQNfqpz5DAkYNCjUJbaj0DYb4=" + "url": "https://github.com/getgauge/gauge_screenshot/releases/download/v0.3.0/screenshot-0.3.0-darwin.x86_64.zip", + "hash": "sha256-2PL0WrIpfDCK5+aKH1rtNVBTiIPYHU4f81UZpv9M2sQ=" }, "aarch64-darwin": { - "url": "https://github.com/getgauge/gauge_screenshot/releases/download/v0.2.0/screenshot-0.2.0-darwin.arm64.zip", - "hash": "sha256-Ly6iHBc2PfeFkKkZIkyD2JD5+EpFNL4SDjzG1oMpKfA=" + "url": "https://github.com/getgauge/gauge_screenshot/releases/download/v0.3.0/screenshot-0.3.0-darwin.arm64.zip", + "hash": "sha256-QfpylVGxE/qKiN57ni4aJsh8Dfg/VIN9vfd1nHX2QO0=" }, "aarch64-linux": { - "url": "https://github.com/getgauge/gauge_screenshot/releases/download/v0.2.0/screenshot-0.2.0-linux.arm64.zip", - "hash": "sha256-Pzfnhs4H0MmeBIhrZElFmvC+PuabLNU/pftVdIu4+LI=" + "url": "https://github.com/getgauge/gauge_screenshot/releases/download/v0.3.0/screenshot-0.3.0-linux.arm64.zip", + "hash": "sha256-HfO2KjK1xSp6xw9F38JjkrUs7JfxkrdltRr6j5/5Cw8=" }, "x86_64-linux": { - "url": "https://github.com/getgauge/gauge_screenshot/releases/download/v0.2.0/screenshot-0.2.0-linux.x86_64.zip", - "hash": "sha256-Wpuq3aSgbIhd4WuJx4SMv+NbEZMVIpAOUMdKV2xxd7c=" + "url": "https://github.com/getgauge/gauge_screenshot/releases/download/v0.3.0/screenshot-0.3.0-linux.x86_64.zip", + "hash": "sha256-2EEUI2jBmEC2JfeJizFqNzINZtYy/y1c+B70hE1hCQk=" } } From 6cf198e132c2be18df48559c9b6cbb9d38dbde63 Mon Sep 17 00:00:00 2001 From: Marie Ramlow Date: Fri, 16 Aug 2024 08:23:12 +0000 Subject: [PATCH 3/6] gaugePlugins.ruby: 0.8.0 -> 0.9.2 --- .../tools/gauge/plugins/ruby/data.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkgs/development/tools/gauge/plugins/ruby/data.json b/pkgs/development/tools/gauge/plugins/ruby/data.json index b7f827cfc569..95316f6b7ca0 100644 --- a/pkgs/development/tools/gauge/plugins/ruby/data.json +++ b/pkgs/development/tools/gauge/plugins/ruby/data.json @@ -1,19 +1,19 @@ { - "version": "0.8.0", + "version": "0.9.2", "aarch64-darwin": { - "url": "https://github.com/getgauge/gauge-ruby/releases/download/v0.8.0/gauge-ruby-0.8.0-darwin.arm64.zip", - "hash": "sha256-HQ7reuC7dQUMbhEzUBiEelPmFBsFJBHe42lmFufkZJY=" + "url": "https://github.com/getgauge/gauge-ruby/releases/download/v0.9.2/gauge-ruby-0.9.2-darwin.arm64.zip", + "hash": "sha256-QPwqgQ+Qd+eHbw445GstcPqEODoKcvvt+YJxsJqxtPc=" }, "x86_64-darwin": { - "url": "https://github.com/getgauge/gauge-ruby/releases/download/v0.8.0/gauge-ruby-0.8.0-darwin.x86_64.zip", - "hash": "sha256-poxT9wYgs21GRx/eVvD7jA1T0VBDEHgH0Zv941pZcKA=" + "url": "https://github.com/getgauge/gauge-ruby/releases/download/v0.9.2/gauge-ruby-0.9.2-darwin.x86_64.zip", + "hash": "sha256-AWe5S8QXkps6eV1+1GZbHY/S+kY/QQoiG/gbddZHZdk=" }, "aarch64-linux": { - "url": "https://github.com/getgauge/gauge-ruby/releases/download/v0.8.0/gauge-ruby-0.8.0-linux.arm64.zip", - "hash": "sha256-SAEHPaWScux6C05jQBfDuLBN2J22Df9eKVM46kWawiU=" + "url": "https://github.com/getgauge/gauge-ruby/releases/download/v0.9.2/gauge-ruby-0.9.2-linux.arm64.zip", + "hash": "sha256-7d6FETLrd7OePiWWRu+5OMKKH9t9H+ZnQCqqYTsuRrk=" }, "x86_64-linux": { - "url": "https://github.com/getgauge/gauge-ruby/releases/download/v0.8.0/gauge-ruby-0.8.0-linux.x86_64.zip", - "hash": "sha256-aXLDK/7phdsX0CmIuxfK39mdrjGo2IpwYBL7uolP5Mk=" + "url": "https://github.com/getgauge/gauge-ruby/releases/download/v0.9.2/gauge-ruby-0.9.2-linux.x86_64.zip", + "hash": "sha256-iPHQ5Tx3iCb/e3RoF5P2grCbNBFuagezQrABK7snFvw=" } } From c30eb0c5e69fd8cca33b5adf283ce7025bbc4d97 Mon Sep 17 00:00:00 2001 From: Marie Ramlow Date: Fri, 16 Aug 2024 08:23:25 +0000 Subject: [PATCH 4/6] gaugePlugins.java: 0.10.3 -> 0.11.0 --- .../tools/gauge/plugins/java/data.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkgs/development/tools/gauge/plugins/java/data.json b/pkgs/development/tools/gauge/plugins/java/data.json index 96c993e6f306..f5a9e09edfdc 100644 --- a/pkgs/development/tools/gauge/plugins/java/data.json +++ b/pkgs/development/tools/gauge/plugins/java/data.json @@ -1,19 +1,19 @@ { - "version": "0.10.3", + "version": "0.11.0", "aarch64-darwin": { - "url": "https://github.com/getgauge/gauge-java/releases/download/v0.10.3/gauge-java-0.10.3-darwin.arm64.zip", - "hash": "sha256-Hs9ZNupj0s7YRjRZibphr7m5YjOj3MTgx/hqAbWyY6I=" + "url": "https://github.com/getgauge/gauge-java/releases/download/v0.11.0/gauge-java-0.11.0-darwin.arm64.zip", + "hash": "sha256-o7viYih6oghPipGmpsdGZXxtML4++Ux7Qul8pRzkdUc=" }, "x86_64-darwin": { - "url": "https://github.com/getgauge/gauge-java/releases/download/v0.10.3/gauge-java-0.10.3-darwin.x86_64.zip", - "hash": "sha256-Hj/Lkwsx/RvyMiJO8dI6vFpIvvyhOA2Un5deC1syYY4=" + "url": "https://github.com/getgauge/gauge-java/releases/download/v0.11.0/gauge-java-0.11.0-darwin.x86_64.zip", + "hash": "sha256-wTXVuyXU9mfVxAc/l0mgvKt3c/jinffILBUhe/tikgs=" }, "aarch64-linux": { - "url": "https://github.com/getgauge/gauge-java/releases/download/v0.10.3/gauge-java-0.10.3-linux.arm64.zip", - "hash": "sha256-XJqP2eew+aI1jFaDzsJhfML8Ft+adFJrHURF8F391Pc=" + "url": "https://github.com/getgauge/gauge-java/releases/download/v0.11.0/gauge-java-0.11.0-linux.arm64.zip", + "hash": "sha256-CsEzoNseWllbNtN5mOYVCPvTPlm60fd7eSXuTpxbRx8=" }, "x86_64-linux": { - "url": "https://github.com/getgauge/gauge-java/releases/download/v0.10.3/gauge-java-0.10.3-linux.x86_64.zip", - "hash": "sha256-sMyWhAGo6oa7MsqK8xApdrwhZo8NkSTIRbsCu5LW3ls=" + "url": "https://github.com/getgauge/gauge-java/releases/download/v0.11.0/gauge-java-0.11.0-linux.x86_64.zip", + "hash": "sha256-zig+Wq6uyBl8fKfjcpKCRFtHBZ/xFeDaUrUqvx1ails=" } } From 73c318b001fdb5549217fe9e2e759de096fae5ae Mon Sep 17 00:00:00 2001 From: Marie Ramlow Date: Fri, 16 Aug 2024 10:52:59 +0200 Subject: [PATCH 5/6] 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. --- .../tools/gauge/plugins/default.nix | 1 + .../tools/gauge/plugins/make-gauge-plugin.nix | 78 ++++++++++--------- .../gauge/plugins/test-gauge-plugins.nix | 35 +++++++++ pkgs/development/tools/gauge/wrapper.nix | 3 + 4 files changed, 80 insertions(+), 37 deletions(-) create mode 100644 pkgs/development/tools/gauge/plugins/test-gauge-plugins.nix diff --git a/pkgs/development/tools/gauge/plugins/default.nix b/pkgs/development/tools/gauge/plugins/default.nix index 92ee2fca77d0..b68d48ba4767 100644 --- a/pkgs/development/tools/gauge/plugins/default.nix +++ b/pkgs/development/tools/gauge/plugins/default.nix @@ -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 { }; diff --git a/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix b/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix index b9a4b1441632..f88a236d7068 100644 --- a/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix +++ b/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix @@ -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)) diff --git a/pkgs/development/tools/gauge/plugins/test-gauge-plugins.nix b/pkgs/development/tools/gauge/plugins/test-gauge-plugins.nix new file mode 100644 index 000000000000..3648e87f7b91 --- /dev/null +++ b/pkgs/development/tools/gauge/plugins/test-gauge-plugins.nix @@ -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} +'' diff --git a/pkgs/development/tools/gauge/wrapper.nix b/pkgs/development/tools/gauge/wrapper.nix index 67b1a8ddc52b..8f4ceca25e9e 100644 --- a/pkgs/development/tools/gauge/wrapper.nix +++ b/pkgs/development/tools/gauge/wrapper.nix @@ -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; From ad16a8d0524fee884fa38a5b7e145d2fa9827f9c Mon Sep 17 00:00:00 2001 From: Marie Ramlow Date: Tue, 20 Aug 2024 09:05:46 +0200 Subject: [PATCH 6/6] gaugePlugins.makeGaugePlugin: fix darwin build Only use autoPatchelfHook on Linux --- pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix b/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix index f88a236d7068..acf902e1b79d 100644 --- a/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix +++ b/pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix @@ -35,7 +35,7 @@ stdenvNoCC.mkDerivation (finalAttrs: (lib.recursiveUpdate { stripRoot = false; }; - nativeBuildInputs = [ autoPatchelfHook ]; + nativeBuildInputs = lib.optional stdenvNoCC.hostPlatform.isLinux autoPatchelfHook; installPhase = '' mkdir -p "$out/share/gauge-plugins/${pname}/${finalAttrs.version}"