Skip to content

Commit

Permalink
Add build job running cardano-node-tests intgeration suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbgi committed Oct 27, 2020
1 parent 30fcd19 commit 9dca394
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 24 deletions.
11 changes: 5 additions & 6 deletions default.nix
Expand Up @@ -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
}:
Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions nix/default.nix
@@ -1,6 +1,7 @@
{ system ? builtins.currentSystem
, crossSystem ? null
, config ? {}
, customConfig ? {}
, sourcesOverride ? {}
, gitrev ? null
}:
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions nix/haskell.nix
Expand Up @@ -4,6 +4,7 @@
{ pkgs
, lib
, stdenv
, src
, haskell-nix
, buildPackages
# GHC attribute name
Expand All @@ -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;
Expand Down
29 changes: 29 additions & 0 deletions nix/pkgs.nix
Expand Up @@ -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
Expand All @@ -18,6 +26,7 @@ pkgs: _: with pkgs;
pkgs
lib
stdenv
src
haskell-nix
buildPackages
gitrev
Expand All @@ -29,6 +38,7 @@ pkgs: _: with pkgs;
pkgs
lib
stdenv
src
haskell-nix
buildPackages
gitrev
Expand Down Expand Up @@ -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/
'';
});
}
2 changes: 1 addition & 1 deletion nix/scripts.nix
Expand Up @@ -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";
Expand Down
20 changes: 16 additions & 4 deletions nix/sources.json
Expand Up @@ -11,6 +11,18 @@
"url": "https://github.com/input-output-hk/cardano-byron-proxy/archive/5538821647728516d5702cbfd9fb3000fcf41082.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.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/<owner>/<repo>/archive/<rev>.tar.gz"
},
"cardano-sl": {
"branch": "develop",
"description": "Cryptographic currency implementing Ouroboros PoS protocol",
Expand Down Expand Up @@ -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/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
}
1 change: 1 addition & 0 deletions nix/supervisord-cluster/default.nix
Expand Up @@ -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} |
Expand Down
2 changes: 1 addition & 1 deletion release.nix
Expand Up @@ -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 = [
Expand Down
25 changes: 18 additions & 7 deletions shell.nix
Expand Up @@ -48,7 +48,7 @@ let
cluster = mkCluster customConfig;
inherit hfcCluster;
in
stdenv.mkDerivation {
stdenv.mkDerivation rec {
name = "devops-shell";
buildInputs = [
niv
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 9dca394

Please sign in to comment.