From 9dca394a48925bc2e0054fc8e5a154aef9bfa270 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Thu, 15 Oct 2020 18:55:18 +0200 Subject: [PATCH] Add build job running cardano-node-tests intgeration suite. --- default.nix | 11 +++++------ nix/default.nix | 6 ++++++ nix/haskell.nix | 6 +----- nix/pkgs.nix | 29 +++++++++++++++++++++++++++++ nix/scripts.nix | 2 +- nix/sources.json | 20 ++++++++++++++++---- nix/supervisord-cluster/default.nix | 1 + release.nix | 2 +- shell.nix | 25 ++++++++++++++++++------- 9 files changed, 78 insertions(+), 24 deletions(-) diff --git a/default.nix b/default.nix index d3c64c062e2..c47e545b4ec 100644 --- a/default.nix +++ b/default.nix @@ -11,7 +11,7 @@ # }' , sourcesOverride ? {} # pinned version of nixpkgs augmented with overlays (iohk-nix and our packages). -, pkgs ? import ./nix/default.nix { inherit system crossSystem config sourcesOverride gitrev; } +, pkgs ? import ./nix/default.nix { inherit system crossSystem config customConfig sourcesOverride gitrev; } # Git sha1 hash, to be passed when not building from a git work tree. , gitrev ? null }: @@ -72,14 +72,13 @@ let tests = collectChecks haskellPackages; hlint = callPackage iohkNix.tests.hlint { - src = ./. ; + inherit src; projects = attrNames (selectProjectPackages cardanoNodeHaskellPackages); }; - }; - shell = import ./shell.nix { - inherit pkgs; - withHoogle = true; + inherit cardano-node-tests; }; + + shell = cardanoNodeShell; }; in packages diff --git a/nix/default.nix b/nix/default.nix index e7cfc7d1424..51101d70b37 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -1,6 +1,7 @@ { system ? builtins.currentSystem , crossSystem ? null , config ? {} +, customConfig ? {} , sourcesOverride ? {} , gitrev ? null }: @@ -38,6 +39,11 @@ let // { inherit overlays sources nixpkgs; }; svcLib = import ./svclib.nix { inherit pkgs; }; + + cardanoNodeShell = import ../shell.nix { + inherit pkgs sourcesOverride config customConfig; + withHoogle = true; + }; }) # And, of course, our haskell-nix-ified cabal project: (import ./pkgs.nix) diff --git a/nix/haskell.nix b/nix/haskell.nix index a793c67f854..a55d4ed449f 100644 --- a/nix/haskell.nix +++ b/nix/haskell.nix @@ -4,6 +4,7 @@ { pkgs , lib , stdenv +, src , haskell-nix , buildPackages # GHC attribute name @@ -18,11 +19,6 @@ }: let - src = haskell-nix.haskellLib.cleanGit { - name = "cardano-node-src"; - src = ../.; - }; - projectPackages = lib.attrNames (haskell-nix.haskellLib.selectProjectPackages (haskell-nix.cabalProject { inherit src; diff --git a/nix/pkgs.nix b/nix/pkgs.nix index e77fcc590ed..b52472932a3 100644 --- a/nix/pkgs.nix +++ b/nix/pkgs.nix @@ -2,12 +2,20 @@ pkgs: _: with pkgs; let compiler = config.haskellNix.compiler or "ghc8102"; + in { + + src = haskell-nix.haskellLib.cleanGit { + name = "cardano-node-src"; + src = ../.; + }; + cardanoNodeHaskellPackages = import ./haskell.nix { inherit compiler pkgs lib stdenv + src haskell-nix buildPackages gitrev @@ -18,6 +26,7 @@ pkgs: _: with pkgs; pkgs lib stdenv + src haskell-nix buildPackages gitrev @@ -29,6 +38,7 @@ pkgs: _: with pkgs; pkgs lib stdenv + src haskell-nix buildPackages gitrev @@ -65,4 +75,23 @@ pkgs: _: with pkgs; compiler-nix-name = compiler; inherit (cardanoNodeHaskellPackages) index-state; }).components.exes) hlint; + + cardano-node-tests = (import (commonLib.sources.cardano-node-tests + "/shell.nix") { + cardanoNodePkgs = pkgs; + }).overrideAttrs (attrs: rec { + src = commonLib.sources.cardano-node-tests; + setupEnvVariablesFile = pkgs.writeScript "cardano-node-tests-setup-env-variable" attrs.setupEnvVariables; + buildCommand = '' + shopt -s dotglob + ln -s $src/* ./ + source ${setupEnvVariablesFile} + ${lib.optionalString (commonLib.sources.cardano-node-tests ? rev) + "GIT_REVISION=${commonLib.sources.cardano-node-tests.rev}" + } make tests \ + TEST_THREADS=auto \ + ARTIFACTS_DIR=$out/artifacts/ \ + COVERAGE_DIR=$out/cli_coverage/ \ + ALLURE_DIR=$out/reports/ + ''; + }); } diff --git a/nix/scripts.nix b/nix/scripts.nix index e95ba8d45f0..3f0461775f8 100644 --- a/nix/scripts.nix +++ b/nix/scripts.nix @@ -25,7 +25,7 @@ let vrfKey = null; operationalCertificate = null; nodeId = 0; - stateDir = "state-node-${envConfig.name}"; + stateDir = "./state-node-${envConfig.name}"; socketPath = "${config.stateDir}/node.socket"; # defaults to proxy if env has no relays edgeHost = "127.0.0.1"; diff --git a/nix/sources.json b/nix/sources.json index 3cb0b640b76..d2f4c24ab2d 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -11,6 +11,18 @@ "url": "https://github.com/input-output-hk/cardano-byron-proxy/archive/5538821647728516d5702cbfd9fb3000fcf41082.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, + "cardano-node-tests": { + "branch": "sourcesOverride", + "description": "Functional tests for cardano-node", + "homepage": null, + "owner": "input-output-hk", + "repo": "cardano-node-tests", + "rev": "f72884a1d7432db6ff7c71fef592da5a86ed4ff0", + "sha256": "1whv06v6kqbxww3ab33npaipdj8kln10d1riih7siijkq6l91akz", + "type": "tarball", + "url": "https://github.com/input-output-hk/cardano-node-tests/archive/f72884a1d7432db6ff7c71fef592da5a86ed4ff0.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, "cardano-sl": { "branch": "develop", "description": "Cryptographic currency implementing Ouroboros PoS protocol", @@ -53,10 +65,10 @@ "homepage": null, "owner": "NixOS", "repo": "nixpkgs", - "rev": "07e5844fdf6fe99f41229d7392ce81cfe191bcfc", - "sha256": "0p2z6jidm4rlp2yjfl553q234swj1vxl8z0z8ra1hm61lfrlcmb9", + "rev": "89d75bc74391fd5cebf8380f91bafe59178122b9", + "sha256": "03sy719shswnj8dmb1w5m3vdyrflri04v4x2i7sm2c7aybpqsx9q", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/07e5844fdf6fe99f41229d7392ce81cfe191bcfc.tar.gz", + "url": "https://github.com/NixOS/nixpkgs/archive/89d75bc74391fd5cebf8380f91bafe59178122b9.tar.gz", "url_template": "https://github.com///archive/.tar.gz" - } + } } diff --git a/nix/supervisord-cluster/default.nix b/nix/supervisord-cluster/default.nix index 095adc9c654..9437cd1d1c4 100644 --- a/nix/supervisord-cluster/default.nix +++ b/nix/supervisord-cluster/default.nix @@ -145,6 +145,7 @@ let --genesis-dir ${stateDir}/shelley \ --gen-genesis-keys ${toString numBft} \ --gen-utxo-keys 1 + chmod og-r -R ${stateDir}/shelley jq -r --arg systemStart $(date --utc +"%Y-%m-%dT%H:%M:%SZ" --date="5 seconds") \ '.systemStart = $systemStart | .updateQuorum = ${toString numBft} | diff --git a/release.nix b/release.nix index c30924ed2fd..b070f94c642 100644 --- a/release.nix +++ b/release.nix @@ -102,7 +102,7 @@ let # Paths or prefixes of paths of derivations to build only on the default system (ie. linux on hydra): onlyBuildOnDefaultSystem = [ - ["checks" "hlint"] ["dockerImage"] ["clusterTests"] ["nixosTests"] + ["checks" "hlint"] ["checks" "cardano-node-tests"] ["dockerImage"] ["clusterTests"] ["nixosTests"] ]; # Paths or prefix of paths for which cross-builds (mingwW64, musl64) are disabled: noCrossBuild = [ diff --git a/shell.nix b/shell.nix index 7cd17bd91b8..7cefa982116 100644 --- a/shell.nix +++ b/shell.nix @@ -48,7 +48,7 @@ let cluster = mkCluster customConfig; inherit hfcCluster; in - stdenv.mkDerivation { + stdenv.mkDerivation rec { name = "devops-shell"; buildInputs = [ niv @@ -63,14 +63,14 @@ let hfcCluster.stop cardanolib-py ]; - shellHook = '' - echo "DevOps Tools" \ - | ${figlet}/bin/figlet -f banner -c \ - | ${lolcat}/bin/lolcat + CARDANO_NODE_SOCKET_PATH = if (customConfig ? network) + # socket path for when a specific network is used: + then "./state-node-${customConfig.network}/node.socket" + # socket path default to first BFT node launched by "start-cluster": + else "${cluster.baseEnvConfig.stateDir}/bft1.socket"; - source <(cardano-cli --bash-completion-script cardano-cli) - source <(cardano-node --bash-completion-script cardano-node) + setupEnvVariables = '' # Socket path default to first BFT node launched by "start-cluster": export CARDANO_NODE_SOCKET_PATH=$PWD/${cluster.baseEnvConfig.stateDir}/bft1.socket # Unless using specific network: @@ -84,6 +84,17 @@ let ''} ''} + ''; + + shellHook = '' + echo "DevOps Tools" \ + | ${figlet}/bin/figlet -f banner -c \ + | ${lolcat}/bin/lolcat + + source <(cardano-cli --bash-completion-script cardano-cli) + source <(cardano-node --bash-completion-script cardano-node) + + ${setupEnvVariables} echo "NOTE: you may need to export GITHUB_TOKEN if you hit rate limits with niv" echo "Commands: