Skip to content

Commit

Permalink
Merge pull request #190 from input-output-hk/KtorZ/buildkite-pipeline…
Browse files Browse the repository at this point in the history
…-ENV

move ENV var export from buildkite script, to buildkite pipeline settings
  • Loading branch information
KtorZ authored Apr 29, 2019
2 parents 4e2d11a + 21081de commit 8a10276
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
13 changes: 2 additions & 11 deletions .buildkite/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@

set -euo pipefail

netname="${1-}"

if [ -z "$netname" ]; then
echo "usage: benchmark.sh NETWORK"
exit 1
fi

echo "--- Build code and benchmarks"
stack build --bench --no-run-benchmarks

export NETWORK=$netname

echo "+++ Run benchmarks"
stack bench cardano-wallet:restore --interleaved-output --ba "$netname +RTS -N2 -qg -A1m -I0 -T -M8G -h -RTS"
echo "+++ Run benchmarks - $NETWORK"
stack bench cardano-wallet:restore --interleaved-output --ba "$NETWORK +RTS -N2 -qg -A1m -I0 -T -M8G -h -RTS"

hp2pretty restore.hp

Expand Down
8 changes: 6 additions & 2 deletions .buildkite/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ env:
NIX_PATH: "channel:nixos-19.03"
steps:
- label: 'Restore benchmark - testnet'
command: "./.buildkite/benchmark.sh testnet"
command: "./.buildkite/benchmark.sh"
timeout_in_minutes: 60
agents:
system: x86_64-linux
env:
NETWORK: testnet
- label: 'Restore benchmark - mainnet'
command: "./.buildkite/benchmark.sh mainnet"
command: "./.buildkite/benchmark.sh"
timeout_in_minutes: 60
agents:
system: x86_64-linux
env:
NETWORK: mainnet
14 changes: 14 additions & 0 deletions test/bench/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ import Fmt
( fmt, (+|), (+||), (|+), (||+) )
import Say
( sayErr )
import System.Environment
( getArgs, setEnv )
import System.IO
( BufferMode (..), hSetBuffering, stderr, stdout )

Expand All @@ -77,6 +79,7 @@ main = do
hSetBuffering stdout NoBuffering
hSetBuffering stderr NoBuffering
installSignalHandlers
getArgs >>= overrideEnvironment
prepareNode
runBenchmarks
[ bench ("restore " <> toText network <> " seq")
Expand Down Expand Up @@ -125,6 +128,17 @@ bench benchName action = do
printResult :: Text -> Double -> IO ()
printResult benchName dur = sayErr . fmt $ " "+|benchName|+": "+|secs dur|+""

-- FIXME This only exists because somehow, in buildkite, we can't pass ENV var
-- to the haskell executable? There's probably some Nix magic going on and I
-- don't have time for this.
overrideEnvironment :: [String] -> IO ()
overrideEnvironment [ntwrk] =
setEnv "NETWORK" ntwrk
overrideEnvironment [] =
return ()
overrideEnvironment _ =
fail "benchmark expects only one argument to override the '$NETWORK' ENV var"

{-------------------------------------------------------------------------------
Benchmarks
-------------------------------------------------------------------------------}
Expand Down

0 comments on commit 8a10276

Please sign in to comment.