Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[DEVOPS-810] [DEVOPS-908] Inject gitrev using file-embed #3130

Merged
merged 5 commits into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions auxx/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Pos.Launcher (HasConfigurations, NodeParams (..), NodeResources
runRealMode, withConfigurations)
import Pos.Txp (txpGlobalSettings)
import Pos.Util (logException)
import Pos.Util.CompileInfo (HasCompileInfo, retrieveCompileTimeInfo, withCompileInfo)
import Pos.Util.CompileInfo (HasCompileInfo, withCompileInfo)
import Pos.Util.Config (ConfigurationException (..))
import Pos.Util.UserSecret (usVss)
import Pos.WorkMode (EmptyMempoolExt, RealMode)
Expand Down Expand Up @@ -130,7 +130,7 @@ action opts@AuxxOptions {..} command = do
CLI.NodeArgs {behaviorConfigPath = Nothing}

main :: IO ()
main = withCompileInfo $(retrieveCompileTimeInfo) $ do
main = withCompileInfo $ do
opts <- getAuxxOptions
let disableConsoleLog
| Repl <- aoAction opts =
Expand Down
2 changes: 1 addition & 1 deletion auxx/src/Command/BlockGen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ generateBlocks pm GenBlocksParams{..} = withStateLock HighPriority ApplyBlock $
, _bgpSkipNoKey = True
, _bgpTxpGlobalSettings = txpGlobalSettings pm
}
withCompileInfo def $ evalRandT (genBlocks pm bgenParams (const ())) (mkStdGen seed)
withCompileInfo $ evalRandT (genBlocks pm bgenParams (const ())) (mkStdGen seed)
-- We print it twice because there can be a ton of logs and
-- you don't notice the first message.
logInfo $ "Generated with seed " <> show seed
5 changes: 2 additions & 3 deletions auxx/src/Mode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import Control.Lens (lens, makeLensesWith)
import Control.Monad.Reader (withReaderT)
import Control.Monad.Trans.Resource (transResourceT)
import Data.Conduit (transPipe)
import Data.Default (def)
import Mockable (Production)
import System.Wlog (HasLoggerName (..))

Expand Down Expand Up @@ -234,8 +233,8 @@ instance ( HasConfiguration

instance (HasConfigurations) =>
MonadTxpLocal (BlockGenMode EmptyMempoolExt AuxxMode) where
txpNormalize = withCompileInfo def $ txNormalize
txpProcessTx = withCompileInfo def $ txProcessTransactionNoLock
txpNormalize = withCompileInfo $ txNormalize
txpProcessTx = withCompileInfo $ txProcessTransactionNoLock

-- | In order to create an 'Address' from a 'PublicKey' we need to
-- choose suitable stake distribution. We want to pick it based on
Expand Down
55 changes: 27 additions & 28 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@ with pkgs.lib;
with pkgs.haskell.lib;

let
addGitRev = subject:
subject.overrideAttrs (
drv: {
GITREV = gitrev;
librarySystemDepends = (drv.librarySystemDepends or []) ++ [ pkgs.git ];
executableSystemDepends = (drv.executableSystemDepends or []) ++ [ pkgs.git ];
}
);
justStaticExecutablesGitRev = import ./scripts/set-git-rev {
inherit pkgs gitrev;
inherit (cardanoPkgs) ghc;
};
addRealTimeTestLogs = drv: overrideCabal drv (attrs: {
testTarget = "--log=test.log || (sleep 10 && kill $TAILPID && false)";
preCheck = ''
Expand All @@ -47,11 +43,6 @@ let
kill $TAILPID
'';
});
# Enables building but not running of benchmarks when
# enableBenchmarks argument is true.
buildWithBenchmarks = drv: if enableBenchmarks
then doBenchmark (appendConfigureFlag drv "--enable-benchmarks")
else drv;

cardanoPkgs = ((import ./pkgs { inherit pkgs; }).override {
ghc = overrideDerivation pkgs.haskell.compiler.ghc822 (drv: {
Expand All @@ -65,7 +56,7 @@ let
];
});

cardano-sl = overrideCabal (buildWithBenchmarks super.cardano-sl) (drv: {
cardano-sl = overrideCabal super.cardano-sl (drv: {
# production full nodes shouldn't use wallet as it means different constants
configureFlags = (drv.configureFlags or []) ++ [
"-f-asserts"
Expand All @@ -77,24 +68,19 @@ let
};
});

cardano-sl-networking = buildWithBenchmarks super.cardano-sl-networking;
cardano-sl-block-bench = buildWithBenchmarks super.cardano-sl-block-bench;
cardano-sl-explorer = buildWithBenchmarks super.cardano-sl-explorer;
cardano-sl-wallet-static = justStaticExecutables super.cardano-sl-wallet;
cardano-sl-wallet-static = justStaticExecutablesGitRev super.cardano-sl-wallet;
cardano-sl-client = addRealTimeTestLogs super.cardano-sl-client;
cardano-sl-generator = addRealTimeTestLogs super.cardano-sl-generator;
# cardano-sl-auxx = addGitRev (justStaticExecutables super.cardano-sl-auxx);
cardano-sl-auxx = addGitRev (justStaticExecutables super.cardano-sl-auxx);
cardano-sl-node = addGitRev super.cardano-sl-node;
cardano-sl-wallet-new = addGitRev (justStaticExecutables (buildWithBenchmarks super.cardano-sl-wallet-new));
cardano-sl-tools = addGitRev (justStaticExecutables (overrideCabal super.cardano-sl-tools (drv: {
cardano-sl-auxx = justStaticExecutablesGitRev super.cardano-sl-auxx;
cardano-sl-wallet-new = justStaticExecutablesGitRev super.cardano-sl-wallet-new;
cardano-sl-tools = justStaticExecutablesGitRev (overrideCabal super.cardano-sl-tools (drv: {
# waiting on load-command size fix in dyld
doCheck = ! pkgs.stdenv.isDarwin;
})));
}));

cardano-sl-node-static = justStaticExecutables self.cardano-sl-node;
cardano-sl-explorer-static = addGitRev (justStaticExecutables self.cardano-sl-explorer);
cardano-report-server-static = justStaticExecutables self.cardano-report-server;
cardano-sl-node-static = justStaticExecutablesGitRev self.cardano-sl-node;
cardano-sl-explorer-static = justStaticExecutablesGitRev self.cardano-sl-explorer;
cardano-report-server-static = justStaticExecutablesGitRev self.cardano-report-server;

# Undo configuration-nix.nix change to hardcode security binary on darwin
# This is needed for macOS binary not to fail during update system (using http-client-tls)
Expand All @@ -118,7 +104,15 @@ let
# This will be the default in nixpkgs since
# https://github.com/NixOS/nixpkgs/issues/29011
enableSharedExecutables = false;
} // optionalAttrs (args ? src) {
} // optionalAttrs (enableBenchmarks && localLib.isCardanoSL args.pname) ({
# Enables building but not running of benchmarks for all
# cardano-sl packages when enableBenchmarks argument is true.
doBenchmark = true;
configureFlags = (args.configureFlags or []) ++ ["--enable-benchmarks"];
} // optionalAttrs (localLib.isBenchmark args) {
# Provide a dummy installPhase for benchmark packages.
installPhase = "mkdir -p $out";
}) // optionalAttrs (args ? src) {
src = let
cleanSourceFilter = with pkgs.stdenv;
name: type: let baseName = baseNameOf (toString name); in ! (
Expand Down Expand Up @@ -167,6 +161,11 @@ let
inherit system config gitrev pkgs;
cardano-sl-explorer = cardanoPkgs.cardano-sl-explorer-static;
});
all-cardano-sl = pkgs.buildEnv {
name = "all-cardano-sl";
paths = attrValues (filterAttrs (name: drv: localLib.isCardanoSL name) cardanoPkgs);
ignoreCollisions = true;
};
mkDocker = { environment, connectArgs ? {} }: import ./docker.nix { inherit environment connect gitrev pkgs connectArgs; };
stack2nix = import (pkgs.fetchFromGitHub {
owner = "avieth";
Expand Down
4 changes: 2 additions & 2 deletions explorer/src/explorer/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import Pos.Launcher (ConfigurationOptions (..), HasConfigurations, Nod
import Pos.Launcher.Configuration (AssetLockPath (..))
import Pos.Update.Worker (updateTriggerWorker)
import Pos.Util (logException)
import Pos.Util.CompileInfo (HasCompileInfo, retrieveCompileTimeInfo, withCompileInfo)
import Pos.Util.CompileInfo (HasCompileInfo, withCompileInfo)
import Pos.Util.UserSecret (usVss)

loggerName :: LoggerName
Expand All @@ -56,7 +56,7 @@ main = do
action :: ExplorerNodeArgs -> Production ()
action (ExplorerNodeArgs (cArgs@CommonNodeArgs{..}) ExplorerArgs{..}) =
withConfigurations blPath conf $ \ntpConfig pm ->
withCompileInfo $(retrieveCompileTimeInfo) $ do
withCompileInfo $ do
CLI.printInfoOnStart cArgs ntpConfig
logInfo $ "Explorer is enabled!"
currentParams <- getNodeParams loggerName cArgs nodeArgs
Expand Down
9 changes: 4 additions & 5 deletions generator/src/Test/Pos/Block/Logic/Mode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ module Test.Pos.Block.Logic.Mode
import Universum

import Control.Lens (lens, makeClassy, makeLensesWith)
import Data.Default (def)
import qualified Data.Map as Map
import qualified Data.Text.Buildable
import Data.Time.Units (TimeUnit (..))
Expand Down Expand Up @@ -506,9 +505,9 @@ instance MonadBListener BlockTestMode where
type instance MempoolExt BlockTestMode = EmptyMempoolExt

instance HasConfigurations => MonadTxpLocal (BlockGenMode EmptyMempoolExt BlockTestMode) where
txpNormalize = withCompileInfo def $ txNormalize
txpProcessTx = withCompileInfo def $ txProcessTransactionNoLock
txpNormalize = withCompileInfo $ txNormalize
txpProcessTx = withCompileInfo $ txProcessTransactionNoLock

instance HasConfigurations => MonadTxpLocal BlockTestMode where
txpNormalize = withCompileInfo def $ txNormalize
txpProcessTx = withCompileInfo def $ txProcessTransactionNoLock
txpNormalize = withCompileInfo $ txNormalize
txpProcessTx = withCompileInfo $ txProcessTransactionNoLock
3 changes: 1 addition & 2 deletions generator/test/Test/Pos/Binary/CommunicationSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Test.Pos.Binary.CommunicationSpec
import Universum

import qualified Data.ByteString.Lazy as BSL
import Data.Default (def)
import Test.Hspec (Spec, describe)
import Test.Hspec.QuickCheck (prop)
import Test.QuickCheck.Monadic (assert)
Expand Down Expand Up @@ -63,7 +62,7 @@ deserializeSerilizedMsgSerializedBlockSpec = do
descNoBlock = "deserialization of a serialized MsgNoSerializedBlock message should give back corresponding MsgNoBlock"

spec :: Spec
spec = withStaticConfigurations $ \_ -> withCompileInfo def $
spec = withStaticConfigurations $ \_ -> withCompileInfo $
describe "Pos.Binary.Communication" $ do
describe "serializeMsgSerializedBlock" serializeMsgSerializedBlockSpec
describe "decode is left inverse of serializeMsgSerializedBlock" deserializeSerilizedMsgSerializedBlockSpec
2 changes: 2 additions & 0 deletions lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ let
lib = pkgs.lib;
in lib // (rec {
inherit fetchNixPkgs;
isCardanoSL = lib.hasPrefix "cardano-sl";
isBenchmark = args: !((args.isExecutable or false) || (args.isLibrary or true));
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: node-ipc
name: cardano-sl-node-ipc
version: 1.3.0
license: MIT
license-file: LICENSE
Expand Down
4 changes: 2 additions & 2 deletions node/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Pos.Launcher.Configuration (AssetLockPath (..))
import Pos.Ssc.Types (SscParams)
import Pos.Update.Worker (updateTriggerWorker)
import Pos.Util (logException)
import Pos.Util.CompileInfo (HasCompileInfo, retrieveCompileTimeInfo, withCompileInfo)
import Pos.Util.CompileInfo (HasCompileInfo, withCompileInfo)
import Pos.Util.UserSecret (usVss)

loggerName :: LoggerName
Expand Down Expand Up @@ -61,7 +61,7 @@ action (SimpleNodeArgs (cArgs@CommonNodeArgs {..}) (nArgs@NodeArgs {..})) ntpCon
actionWithoutWallet pm sscParams currentParams

main :: IO ()
main = withCompileInfo $(retrieveCompileTimeInfo) $ do
main = withCompileInfo $ do
args@(CLI.SimpleNodeArgs commonNodeArgs _) <- CLI.getSimpleNodeOptions
let loggingParams = CLI.loggingParams loggerName commonNodeArgs
let conf = CLI.configurationOptions (CLI.commonArgs commonNodeArgs)
Expand Down
Loading