Skip to content

Commit

Permalink
Merge #2124 #2213
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
6 people authored Oct 16, 2020
3 parents 0640a19 + e2c02b0 + 759fd0e commit 05e59a0
Show file tree
Hide file tree
Showing 40 changed files with 1,051 additions and 331 deletions.
102 changes: 57 additions & 45 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,61 @@ let
} // args);
haskellPackages = buildHaskellPackages {};
profiledHaskellPackages = buildHaskellPackages { profiling = true; };
coveredHaskellPackages = buildHaskellPackages { coverage = true; };

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

# Creates a development environment for Cabal builds or ghci
# sessions, with various build tools included.
mkShell = name: hp: hp.shellFor {
inherit name;
packages = ps: attrValues (selectProjectPackages ps);
buildInputs = (with self; [
jormungandr
jormungandr-cli
cardano-node
cardano-cli
cardano-address
cardano-tx
bech32
]) ++ (with pkgs; [
niv
pkgconfig
python3Packages.openapi-spec-validator
ruby
sqlite-interactive
yq
]) ++ attrValues hls;
tools = {
cabal = "3.2.0.0";
ghcid = "0.8.7";
hlint = "3.2";
lentil = "1.3.2.0";
stylish-haskell = "0.11.0.3";
weeder = "1.0.9";
};
CARDANO_NODE_CONFIGS = cardano-node.deployments;
meta.platforms = lib.platforms.unix;
shellHook = ''
setup_completion() {
local p
for p in $buildInputs; do
if [ -d "$p/share/bash-completion" ]; then
addToSearchPath XDG_DATA_DIRS "$p/share"
fi
done
}
setup_completion
'';
};

# Build latest release of haskell-language-server from github
hls = pkgs.callPackages ./nix/hls.nix {
compiler-nix-name = haskellPackages._config.compiler.nix-name;
};

self = {
inherit pkgs commonLib src haskellPackages profiledHaskellPackages;
inherit pkgs commonLib src haskellPackages profiledHaskellPackages coveredHaskellPackages;
# Jormungandr
inherit (jmPkgs) jormungandr jormungandr-cli;
# expose cardano-node, so daedalus can ship it without needing to pin cardano-node
Expand Down Expand Up @@ -101,9 +151,11 @@ let
};

# `tests` are the test suites which have been built.
tests = collectComponents "tests" isProjectPackage haskellPackages;
tests = collectComponents "tests" isProjectPackage coveredHaskellPackages;
# `checks` are the result of executing the tests.
checks = pkgs.recurseIntoAttrs (getPackageChecks (selectProjectPackages haskellPackages));
checks = pkgs.recurseIntoAttrs (getPackageChecks (selectProjectPackages coveredHaskellPackages));
# Combined project coverage report
inherit (coveredHaskellPackages) testCoverageReport;
# `benchmarks` are only built, not run.
benchmarks = collectComponents "benchmarks" isProjectPackage haskellPackages;

Expand All @@ -114,48 +166,8 @@ let
shelley = self.cardano-wallet;
});

shell = haskellPackages.shellFor {
name = "cardano-wallet-shell";
packages = ps: attrValues (selectProjectPackages ps);
buildInputs = (with self; [
jormungandr
jormungandr-cli
cardano-node
cardano-cli
cardano-address
cardano-tx
bech32
]) ++ (with pkgs; [
niv
pkgconfig
python3Packages.openapi-spec-validator
ruby
sqlite-interactive
yq
]);
tools = {
cabal = "3.2.0.0";
ghcid = "0.8.7";
ghcide = "0.2.0";
hlint = "3.1.6";
lentil = "1.3.2.0";
stylish-haskell = "0.11.0.0";
weeder = "1.0.9";
};
CARDANO_NODE_CONFIGS = cardano-node.deployments;
meta.platforms = lib.platforms.unix;
shellHook = ''
setup_completion() {
local p
for p in $buildInputs; do
if [ -d "$p/share/bash-completion" ]; then
addToSearchPath XDG_DATA_DIRS "$p/share"
fi
done
}
setup_completion
'';
};
shell = mkShell "cardano-wallet-shell" haskellPackages;
shell-prof = mkShell "cardano-wallet-shell-profiled" profiledHaskellPackages;
cabalShell = import ./nix/cabal-shell.nix { inherit pkgs; walletPackages = self; };
stackShell = import ./nix/stack-shell.nix { inherit pkgs; walletPackages = self; };

Expand Down
45 changes: 45 additions & 0 deletions lib/core-integration/src/Test/Integration/Framework/DSL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ module Test.Integration.Framework.DSL
, getFromResponseList
, json
, joinStakePool
, joinStakePoolUnsigned
, delegationFee
, quitStakePool
, quitStakePoolUnsigned
, selectCoins
, listAddresses
, listTransactions
Expand Down Expand Up @@ -144,6 +146,9 @@ module Test.Integration.Framework.DSL
, postExternalTransactionViaCLI
, deleteTransactionViaCLI
, getTransactionViaCLI

-- utilites
, getRetirementEpoch
) where

import Cardano.CLI
Expand Down Expand Up @@ -171,6 +176,7 @@ import Cardano.Wallet.Api.Types
, ApiFee
, ApiNetworkInformation
, ApiNetworkParameters (..)
, ApiStakePool
, ApiT (..)
, ApiTransaction
, ApiTxId (ApiTxId)
Expand Down Expand Up @@ -1233,6 +1239,24 @@ joinStakePool ctx p (w, pass) = do
request @(ApiTransaction n) ctx
(Link.joinStakePool (Identity p) w) Default payload

joinStakePoolUnsigned
:: forall n style t w.
( HasType (ApiT WalletId) w
, DecodeAddress n
, EncodeAddress n
, Link.Discriminate style
)
=> Context t
-> w
-> ApiT PoolId
-> IO (HTTP.Status, Either RequestException (ApiCoinSelection n))
joinStakePoolUnsigned ctx w pid = do
let payload = Json [aesonQQ| {
"delegation_action": { "action": "join", "pool": #{pid} }
} |]
request @(ApiCoinSelection n) ctx
(Link.selectCoins @style w) Default payload

quitStakePool
:: forall n t w.
( HasType (ApiT WalletId) w
Expand All @@ -1249,6 +1273,23 @@ quitStakePool ctx (w, pass) = do
request @(ApiTransaction n) ctx
(Link.quitStakePool w) Default payload

quitStakePoolUnsigned
:: forall n style t w.
( HasType (ApiT WalletId) w
, DecodeAddress n
, EncodeAddress n
, Link.Discriminate style
)
=> Context t
-> w
-> IO (HTTP.Status, Either RequestException (ApiCoinSelection n))
quitStakePoolUnsigned ctx w = do
let payload = Json [aesonQQ| {
"delegation_action": { "action": "quit" }
} |]
request @(ApiCoinSelection n) ctx
(Link.selectCoins @style w) Default payload

selectCoins
:: forall n style t w.
( HasType (ApiT WalletId) w
Expand Down Expand Up @@ -1898,3 +1939,7 @@ delegating
delegating pidActive nexts = (notDelegating nexts)
{ active = ApiWalletDelegationNext Delegating (Just pidActive) Nothing
}


getRetirementEpoch :: ApiStakePool -> Maybe EpochNo
getRetirementEpoch = fmap (view (#epochNumber . #getApiT)) . view #retirement
Loading

0 comments on commit 05e59a0

Please sign in to comment.