Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Feature/sre xxx use cabal for coverage #371

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 0 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ steps:
- label: 'stack coveralls coverage'
command:
- 'nix-shell -A runCoveralls'
soft_fail:
- exit_status: '*'
agents:
system: x86_64-linux

Expand Down
47 changes: 32 additions & 15 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,45 @@ test-show-details: direct

-- Then enable specific tests in this repo

-- Disabling all coverage by default doesn't work the same as
-- disabling and enabling coverage individually, so we disable/enable
-- coverage individually here:

package cardano-shell
tests: True
coverage: True

package cardano-launcher
tests: True
coverage: True

package cardano-prelude
coverage: False

package cardano-sl-x509
coverage: False

package iohk-monitoring
coverage: False

package contra-tracer
coverage: False

package tracer-transformers
coverage: False

package Win32-network
coverage: False

package canononical-json
coverage: False

-- ---------------------------------------------------------

-- The iohk-monitoring requires async-timer >= 0.2.0.0 but does not
-- list this constraint in it's cabal file.
constraints: async-timer >= 0.2.0.0

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-sl-x509
Expand Down Expand Up @@ -72,18 +103,4 @@ source-repository-package
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: efa4b5ecd7f0a13124616b12679cd42517cd905a
--sha256: 0h1h5ifl5d7dl3y6fym9pjd6rfrbh5rbyxs0xw5las503pibv2bf
subdir: tracer-transformers

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: efa4b5ecd7f0a13124616b12679cd42517cd905a
--sha256: 0h1h5ifl5d7dl3y6fym9pjd6rfrbh5rbyxs0xw5las503pibv2bf
subdir: tracer-transformers

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 1361bb92814c65e5964732777fc7f8ec9ebdccfe
--sha256: 1znl9zzw5hswcd09zcvmgq50ppp46nbzjmw67wm4wpnw5lhnlwfy
subdir: Win32-network
subdir: tracer-transformers
41 changes: 34 additions & 7 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ let

haskellPackages = recRecurseIntoAttrs
# the Haskell.nix package set, reduced to local packages.
(selectProjectPackages cardanoNodeHaskellPackages);
(selectProjectPackages cardanoShellHaskellPackages);

self = {
inherit cardanoShellHaskellPackages;
inherit haskellPackages hydraEvalErrors;

inherit (haskellPackages.cardano-shell.identifier) version;
Expand All @@ -41,14 +42,40 @@ let
tests = collectChecks haskellPackages;
};

runCoveralls = pkgs.stdenv.mkDerivation {
runCoveralls = cardanoShellHaskellPackages.shellFor {
name = "run-coveralls";
buildInputs = with pkgs; [ commonLib.stack-hpc-coveralls stack ];

packages = ps: with ps; [
ps.cardano-shell
ps.cardano-launcher
ps.cardano-prelude
ps.canonical-json
ps.iohk-monitoring
ps.Win32-network
];

# These programs will be available inside the nix-shell.
buildInputs = (with haskellPackages; [
]) ++ (with pkgs; [
cabal-install
git
commonLib.stack-hpc-coveralls
pkgconfig
]);

# Prevents cabal from choosing alternate plans, so that
# *all* dependencies are provided by Nix.
exactDeps = true;

GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";

shellHook = ''
echo '~~~ stack nix test'
stack test --nix --coverage
echo '~~~ shc'
shc --repo-token=$COVERALLS_REPO_TOKEN combined all
# echo '~~~ cabal coverage'
# cabal clean
# cabal build all
# cabal test all
# echo '~~~ shc'
# shc --repo-token=$COVERALLS_REPO_TOKEN combined all
exit
'';
};
Expand Down
9 changes: 9 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ let
})
# And, of course, our haskell-nix-ified cabal project:
(import ./pkgs.nix)
# stack needs to be version 1.9.3, because versions greater than
# this can't be re-execed in a nix shell:
#
# https://github.com/commercialhaskell/stack/issues/5000
#
# i.e. "runCoveralls" fails with stack > 1.9.3
(self: super: {
stack_1_9_3 = (import sources."nixpkgs-19.03" {}).stack;
})
];

pkgs = import nixpkgs {
Expand Down
37 changes: 36 additions & 1 deletion nix/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,41 @@ let
# These tests need files from the source tree.
packages.cardano-launcher.components.tests.cardano-launcher-test.keepSource = true;

# Coverage
packages.cardano-shell.components.library.doCoverage = true;
packages.cardano-shell.components.library.postInstall = ''
cp -r dist/hpc $out/share
'';

packages.cardano-launcher.components.library.doCoverage = true;
packages.cardano-launcher.components.library.keepSource = true;
packages.cardano-launcher.components.library.postInstall = ''
cp -r dist/hpc $out/share
'';

# packages.cardano-launcher.components.tests.cardano-launcher-test.doCheck = true;
packages.cardano-launcher.components.tests.cardano-launcher-test.doCoverage = true;
packages.cardano-launcher.components.tests.cardano-launcher-test.preBuild = ''
mkdir .hpc
for outdir in $buildInputs; do
if [ -d "$outdir" ]; then
find "$outdir" -iname '*.mix' -exec sh -c 'mixdir="$(basename $(dirname $1))"; mkdir -p .hpc/$mixdir; ln -s $1 --target-directory=.hpc/$mixdir' sh {} \;
fi
done
ls -lah .hpc/
find .hpc -iname '*.mix' -print
echo ${src}
cp -r ${src}/cardano-launcher/src ./
ls -lah
$SETUP_HS build
$SETUP_HS test
'';
packages.cardano-launcher.components.tests.cardano-launcher-test.postInstall = ''
cp -r dist/hpc $out/share
'';
# packages.cardano-launcher.components.tests.cardano-launcher-test.preCheck = ''echo "HELLO"'';
# packages.cardano-launcher.checks.cardano-launcher-test.doCoverage = true;

# Packages we wish to ignore version bounds of.
# This is similar to jailbreakCabal, however it
# does not require any messing with cabal files.
Expand Down Expand Up @@ -82,7 +117,7 @@ let
];
# TODO add flags to packages (like cs-ledger) so we can turn off tests that will
# not build for windows on a per package bases (rather than using --disable-tests).
configureArgs = lib.optionalString stdenv.hostPlatform.isWindows "--disable-tests";
configureArgs = (lib.optionalString stdenv.hostPlatform.isWindows "--disable-tests");
});
in
pkgSet
2 changes: 1 addition & 1 deletion nix/pkgs.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# our packages overlay
pkgs: _: with pkgs; {
cardanoNodeHaskellPackages = import ./haskell.nix {
cardanoShellHaskellPackages = import ./haskell.nix {
inherit config
lib
stdenv
Expand Down
12 changes: 12 additions & 0 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,17 @@
"type": "tarball",
"url": "https://github.com/input-output-hk/iohk-nix/archive/b2b9c8e24d694a9c7ccf76ea175eba8493f3ab2a.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-19.03": {
"branch": "nixos-19.03",
"description": "Nix Packages collection",
"homepage": null,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "34c7eb7545d155cc5b6f499b23a7cb1c96ab4d59",
"sha256": "11z6ajj108fy2q5g8y4higlcaqncrbjm3dnv17pvif6avagw4mcb",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/34c7eb7545d155cc5b6f499b23a7cb1c96ab4d59.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
20 changes: 13 additions & 7 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,42 @@ with pkgs;
let
# This provides a development environment that can be used with nix-shell or
# lorri. See https://input-output-hk.github.io/haskell.nix/user-guide/development/
shell = cardanoNodeHaskellPackages.shellFor {
shell = cardanoShellHaskellPackages.shellFor {
name = "cabal-dev-shell";

# If shellFor local packages selection is wrong,
# then list all local packages then include source-repository-package that cabal complains about:
packages = ps: with ps; [
ps.cardano-shell
ps.cardano-launcher
ps.cardano-prelude
ps.canonical-json
ps.iohk-monitoring
];

# These programs will be available inside the nix-shell.
buildInputs = with haskellPackages; [
buildInputs = (with haskellPackages; [
profiteur
weeder
]) ++ (with pkgs; [
cabal-install
ghcid
git
hlint
weeder
nix
niv
nix
pkgconfig
profiteur
sqlite-interactive
tmux
git
];
]);

# Prevents cabal from choosing alternate plans, so that
# *all* dependencies are provided by Nix.
exactDeps = true;

inherit withHoogle;

GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
};

devops = pkgs.stdenv.mkDerivation {
Expand Down