Skip to content

Commit 05e59a0

Browse files
iohk-bors[bot]rvlsevanspowellJulian OspaldKtorZ
authored
Merge #2124 #2213
2124: Add haskell program coverage reports to Hydra tests r=KtorZ a=rvl ### Issue Number ADP-99 ### Overview This is a bit of an assortment of nix build improvements. 1. Add a code test coverage report for the Hydra build - implemented by PR input-output-hk/haskell.nix#762 2. Add a nix-shell with profiled packages. Profiled packages will be built on Hydra for master branch but not PRs. This means you can download haskell dependencies with profiling enabled, rather than having to build everything yourself. 3. Update versions of build tools in the nix-shell to latest hackage release - ghcide, hlint and stylish-haskell updated. ### Comments - [Hydra jobset](https://hydra.iohk.io/jobset/Cardano/cardano-wallet-pr-2124) - [Coverage report job](https://hydra.iohk.io/job/Cardano/cardano-wallet-pr-2124/musl64.testCoverageReport.x86_64-linux/latest) - [Coverage report from bors try](https://hydra.iohk.io/build/4328848/download/2/hpc_index.html) <details> <summary>Stack coverage report for comparison</summary> #### Command ``` stack build --coverage --fast --test --skip integration --skip jormungandr-integration ``` #### Result: ``` ... Generating unified report 26% expressions used (26186/98111) 44% boolean coverage (136/305) 42% guards (102/240), 72 always True, 7 always False, 59 unevaluated 52% 'if' conditions (33/63), 4 always True, 8 always False, 18 unevaluated 50% qualifiers (1/2), 1 always True 40% alternatives used (849/2108) 58% local declarations used (859/1456) 50% top-level declarations used (1769/3533) The unified report is available at /home/rodney/iohk/cardano-wallet/.stack-work/install/x86_64-linux/2cecc28bf3aab8c8c3e4a07c1c6c1c846ec8861df3d8a5e9247bce185aeb7542/8.6.5/hpc/combined/all/hpc_index.html An index of the generated HTML coverage reports is available at /home/rodney/iohk/cardano-wallet/.stack-work/install/x86_64-linux/2cecc28bf3aab8c8c3e4a07c1c6c1c846ec8861df3d8a5e9247bce185aeb7542/8.6.5/hpc/index.html -- While building package cardano-wallet-2020.9.30 using: /home/rodney/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.4.0.1 build lib:cardano-wallet exe:cardano-wallet test:unit --ghc-options "-hpcdir .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/hpc -fdiagnostics-color=always" Process exited with code: ExitFailure 1 Progress 335/336 ``` </details> 2213: ADP-455: return unsigned delegation certificate r=KtorZ a=hasufell # Issue Number #2200 # Overview - [x] Added Api types - [x] Refactored some of the Transaction layer (still WIP) - [x] Factored out certificate creation from `joinStakePool` - [x] Added handler for joining stake pool - [x] Add handler for quitting stake pool - [x] serialization of certificates - [x] lots of cleanup - [x] fix jormungandr - [x] fix tests - [ ] add tests # Comments <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: Rodney Lorrimar <[email protected]> Co-authored-by: Samuel Evans-Powell <[email protected]> Co-authored-by: Julian Ospald <[email protected]> Co-authored-by: KtorZ <[email protected]> Co-authored-by: Matthias Benkort <[email protected]>
3 parents 0640a19 + e2c02b0 + 759fd0e commit 05e59a0

File tree

40 files changed

+1051
-331
lines changed

40 files changed

+1051
-331
lines changed

default.nix

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,61 @@ let
6969
} // args);
7070
haskellPackages = buildHaskellPackages {};
7171
profiledHaskellPackages = buildHaskellPackages { profiling = true; };
72+
coveredHaskellPackages = buildHaskellPackages { coverage = true; };
7273

7374
getPackageChecks = mapAttrs (_: package: package.checks);
7475

76+
# Creates a development environment for Cabal builds or ghci
77+
# sessions, with various build tools included.
78+
mkShell = name: hp: hp.shellFor {
79+
inherit name;
80+
packages = ps: attrValues (selectProjectPackages ps);
81+
buildInputs = (with self; [
82+
jormungandr
83+
jormungandr-cli
84+
cardano-node
85+
cardano-cli
86+
cardano-address
87+
cardano-tx
88+
bech32
89+
]) ++ (with pkgs; [
90+
niv
91+
pkgconfig
92+
python3Packages.openapi-spec-validator
93+
ruby
94+
sqlite-interactive
95+
yq
96+
]) ++ attrValues hls;
97+
tools = {
98+
cabal = "3.2.0.0";
99+
ghcid = "0.8.7";
100+
hlint = "3.2";
101+
lentil = "1.3.2.0";
102+
stylish-haskell = "0.11.0.3";
103+
weeder = "1.0.9";
104+
};
105+
CARDANO_NODE_CONFIGS = cardano-node.deployments;
106+
meta.platforms = lib.platforms.unix;
107+
shellHook = ''
108+
setup_completion() {
109+
local p
110+
for p in $buildInputs; do
111+
if [ -d "$p/share/bash-completion" ]; then
112+
addToSearchPath XDG_DATA_DIRS "$p/share"
113+
fi
114+
done
115+
}
116+
setup_completion
117+
'';
118+
};
119+
120+
# Build latest release of haskell-language-server from github
121+
hls = pkgs.callPackages ./nix/hls.nix {
122+
compiler-nix-name = haskellPackages._config.compiler.nix-name;
123+
};
124+
75125
self = {
76-
inherit pkgs commonLib src haskellPackages profiledHaskellPackages;
126+
inherit pkgs commonLib src haskellPackages profiledHaskellPackages coveredHaskellPackages;
77127
# Jormungandr
78128
inherit (jmPkgs) jormungandr jormungandr-cli;
79129
# expose cardano-node, so daedalus can ship it without needing to pin cardano-node
@@ -101,9 +151,11 @@ let
101151
};
102152

103153
# `tests` are the test suites which have been built.
104-
tests = collectComponents "tests" isProjectPackage haskellPackages;
154+
tests = collectComponents "tests" isProjectPackage coveredHaskellPackages;
105155
# `checks` are the result of executing the tests.
106-
checks = pkgs.recurseIntoAttrs (getPackageChecks (selectProjectPackages haskellPackages));
156+
checks = pkgs.recurseIntoAttrs (getPackageChecks (selectProjectPackages coveredHaskellPackages));
157+
# Combined project coverage report
158+
inherit (coveredHaskellPackages) testCoverageReport;
107159
# `benchmarks` are only built, not run.
108160
benchmarks = collectComponents "benchmarks" isProjectPackage haskellPackages;
109161

@@ -114,48 +166,8 @@ let
114166
shelley = self.cardano-wallet;
115167
});
116168

117-
shell = haskellPackages.shellFor {
118-
name = "cardano-wallet-shell";
119-
packages = ps: attrValues (selectProjectPackages ps);
120-
buildInputs = (with self; [
121-
jormungandr
122-
jormungandr-cli
123-
cardano-node
124-
cardano-cli
125-
cardano-address
126-
cardano-tx
127-
bech32
128-
]) ++ (with pkgs; [
129-
niv
130-
pkgconfig
131-
python3Packages.openapi-spec-validator
132-
ruby
133-
sqlite-interactive
134-
yq
135-
]);
136-
tools = {
137-
cabal = "3.2.0.0";
138-
ghcid = "0.8.7";
139-
ghcide = "0.2.0";
140-
hlint = "3.1.6";
141-
lentil = "1.3.2.0";
142-
stylish-haskell = "0.11.0.0";
143-
weeder = "1.0.9";
144-
};
145-
CARDANO_NODE_CONFIGS = cardano-node.deployments;
146-
meta.platforms = lib.platforms.unix;
147-
shellHook = ''
148-
setup_completion() {
149-
local p
150-
for p in $buildInputs; do
151-
if [ -d "$p/share/bash-completion" ]; then
152-
addToSearchPath XDG_DATA_DIRS "$p/share"
153-
fi
154-
done
155-
}
156-
setup_completion
157-
'';
158-
};
169+
shell = mkShell "cardano-wallet-shell" haskellPackages;
170+
shell-prof = mkShell "cardano-wallet-shell-profiled" profiledHaskellPackages;
159171
cabalShell = import ./nix/cabal-shell.nix { inherit pkgs; walletPackages = self; };
160172
stackShell = import ./nix/stack-shell.nix { inherit pkgs; walletPackages = self; };
161173

lib/core-integration/src/Test/Integration/Framework/DSL.hs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ module Test.Integration.Framework.DSL
7373
, getFromResponseList
7474
, json
7575
, joinStakePool
76+
, joinStakePoolUnsigned
7677
, delegationFee
7778
, quitStakePool
79+
, quitStakePoolUnsigned
7880
, selectCoins
7981
, listAddresses
8082
, listTransactions
@@ -144,6 +146,9 @@ module Test.Integration.Framework.DSL
144146
, postExternalTransactionViaCLI
145147
, deleteTransactionViaCLI
146148
, getTransactionViaCLI
149+
150+
-- utilites
151+
, getRetirementEpoch
147152
) where
148153

149154
import Cardano.CLI
@@ -171,6 +176,7 @@ import Cardano.Wallet.Api.Types
171176
, ApiFee
172177
, ApiNetworkInformation
173178
, ApiNetworkParameters (..)
179+
, ApiStakePool
174180
, ApiT (..)
175181
, ApiTransaction
176182
, ApiTxId (ApiTxId)
@@ -1233,6 +1239,24 @@ joinStakePool ctx p (w, pass) = do
12331239
request @(ApiTransaction n) ctx
12341240
(Link.joinStakePool (Identity p) w) Default payload
12351241

1242+
joinStakePoolUnsigned
1243+
:: forall n style t w.
1244+
( HasType (ApiT WalletId) w
1245+
, DecodeAddress n
1246+
, EncodeAddress n
1247+
, Link.Discriminate style
1248+
)
1249+
=> Context t
1250+
-> w
1251+
-> ApiT PoolId
1252+
-> IO (HTTP.Status, Either RequestException (ApiCoinSelection n))
1253+
joinStakePoolUnsigned ctx w pid = do
1254+
let payload = Json [aesonQQ| {
1255+
"delegation_action": { "action": "join", "pool": #{pid} }
1256+
} |]
1257+
request @(ApiCoinSelection n) ctx
1258+
(Link.selectCoins @style w) Default payload
1259+
12361260
quitStakePool
12371261
:: forall n t w.
12381262
( HasType (ApiT WalletId) w
@@ -1249,6 +1273,23 @@ quitStakePool ctx (w, pass) = do
12491273
request @(ApiTransaction n) ctx
12501274
(Link.quitStakePool w) Default payload
12511275

1276+
quitStakePoolUnsigned
1277+
:: forall n style t w.
1278+
( HasType (ApiT WalletId) w
1279+
, DecodeAddress n
1280+
, EncodeAddress n
1281+
, Link.Discriminate style
1282+
)
1283+
=> Context t
1284+
-> w
1285+
-> IO (HTTP.Status, Either RequestException (ApiCoinSelection n))
1286+
quitStakePoolUnsigned ctx w = do
1287+
let payload = Json [aesonQQ| {
1288+
"delegation_action": { "action": "quit" }
1289+
} |]
1290+
request @(ApiCoinSelection n) ctx
1291+
(Link.selectCoins @style w) Default payload
1292+
12521293
selectCoins
12531294
:: forall n style t w.
12541295
( HasType (ApiT WalletId) w
@@ -1898,3 +1939,7 @@ delegating
18981939
delegating pidActive nexts = (notDelegating nexts)
18991940
{ active = ApiWalletDelegationNext Delegating (Just pidActive) Nothing
19001941
}
1942+
1943+
1944+
getRetirementEpoch :: ApiStakePool -> Maybe EpochNo
1945+
getRetirementEpoch = fmap (view (#epochNumber . #getApiT)) . view #retirement

0 commit comments

Comments
 (0)