haskell-numerics / random-fu

A suite of Haskell libraries for representing, manipulating, and sampling random variables
42 stars 21 forks source link

Improve testing / performance testing and CI #71

Open idontgetoutmuch opened 3 years ago

idontgetoutmuch commented 3 years ago

At the moment I am building the current version like this

let

 myHaskellPackageOverlay = self: super: {
  myHaskellPackages = super.haskellPackages.override {
    overrides = hself: hsuper: rec {

      random-fu = self.haskell.lib.addBuildDepends (super.haskell.lib.dontHaddock (super.haskell.lib.dontCheck (
        hself.callCabal2nixWithOptions "random-fu" (builtins.fetchGit {
          url = "https://github.com/haskell-numerics/random-fu";
          rev = "68716ae55b960a978866991d89a024f5f1b0ba80";
          ref = "master";
        }) "--subpath random-fu" { }
      ))) [ ];

      rvar = self.haskell.lib.addBuildDepends (super.haskell.lib.dontHaddock (super.haskell.lib.dontCheck (
        hself.callCabal2nixWithOptions "rvar" (builtins.fetchGit {
          url = "https://github.com/haskell-numerics/random-fu";
          rev = "68716ae55b960a978866991d89a024f5f1b0ba80";
          ref = "master";
        }) "--subpath rvar" { }
      ))) [ ];

      random-source = self.haskell.lib.addBuildDepends (super.haskell.lib.dontHaddock (super.haskell.lib.dontCheck (
        hself.callCabal2nixWithOptions "random-source" (builtins.fetchGit {
          url = "https://github.com/haskell-numerics/random-fu";
          rev = "68716ae55b960a978866991d89a024f5f1b0ba80";
          ref = "master";
        }) "--subpath random-source" { }
      ))) [ ];

      random = self.haskell.lib.addBuildDepends (super.haskell.lib.dontHaddock (super.haskell.lib.dontCheck (
        hself.callCabal2nixWithOptions "random" (builtins.fetchGit {
          url = "https://github.com/haskell/random";
          rev = "edae4f7908f3c7e00be1094034a4a09cd72ab35e";
        }) "" { }
      ))) [ ];

      mwc-random = hself.callHackage "mwc-random" "0.15.0.1" {};

      hashable = super.haskell.lib.doJailbreak hsuper.hashable;

    };
  };
};

in

{ nixpkgs ? import <nixpkgs> { config.allowBroken = true; overlays = [ myHaskellPackageOverlay ]; }, compiler ? "default", doBenchmark ? true }:

let

orig =
  let src = builtins.fetchGit {
        url = "https://github.com/haskell-numerics/random-fu";
        rev = "68716ae55b960a978866991d89a024f5f1b0ba80";
        ref = "master";
      };
      nixSrc = nixpkgs.myHaskellPackages.callCabal2nixWithOptions "speed" src "--subpath tests/speed" { };
      newSrc = nixpkgs.pkgs.haskell.lib.doBenchmark (
        nixpkgs.haskell.lib.dontCheck (
          nixpkgs.haskell.lib.dontHaddock nixSrc
        )
      );
      preSrc = nixpkgs.haskell.lib.overrideCabal newSrc (old: {
        preConfigure = ''
                       sed -i -e s/benchmark/executable/ speed-tests.cabal
                       '';
      });
    in
      nixpkgs.myHaskellPackages.callPackage preSrc {
        random-fu     = nixpkgs.myHaskellPackages.random-fu;
        random-source = nixpkgs.myHaskellPackages.random-source;
      };

in

orig

and the proposal / PR like this

let

 myHaskellPackageOverlay = self: super: {
  myHaskellPackages = super.haskellPackages.override {
    overrides = hself: hsuper: rec {

      random-fu = self.haskell.lib.addBuildDepends (super.haskell.lib.dontHaddock (super.haskell.lib.dontCheck (
        hself.callCabal2nixWithOptions "random-fu" (builtins.fetchGit {
          url = "https://github.com/lehins/random-fu";
          rev = "23d4390dbad60ae491b12ebd2cabb7a985302b55";
          ref = "switch-to-random";
        }) "--subpath random-fu" { }
      ))) [ ];

      rvar = self.haskell.lib.addBuildDepends (super.haskell.lib.dontHaddock (super.haskell.lib.dontCheck (
        hself.callCabal2nixWithOptions "rvar" (builtins.fetchGit {
          url = "https://github.com/lehins/random-fu";
          rev = "23d4390dbad60ae491b12ebd2cabb7a985302b55";
          ref = "switch-to-random";
        }) "--subpath rvar" { }
      ))) [ ];

      random = self.haskell.lib.addBuildDepends (super.haskell.lib.dontHaddock (super.haskell.lib.dontCheck (
        hself.callCabal2nixWithOptions "rvar" (builtins.fetchGit {
          url = "https://github.com/haskell/random";
          rev = "edae4f7908f3c7e00be1094034a4a09cd72ab35e";
        }) "" { }
      ))) [ ];

      mwc-random = hself.callHackage "mwc-random" "0.15.0.1" {};

      hashable = super.haskell.lib.doJailbreak hsuper.hashable;

    };
  };
};

in

{ nixpkgs ? import <nixpkgs> { config.allowBroken = true; overlays = [ myHaskellPackageOverlay ]; }, compiler ? "default", doBenchmark ? true }:

let

orig =
  let src = builtins.fetchGit {
        url = "https://github.com/lehins/random-fu";
        rev = "23d4390dbad60ae491b12ebd2cabb7a985302b55";
        ref = "switch-to-random";
      };
      nixSrc = nixpkgs.myHaskellPackages.callCabal2nixWithOptions "speed" src "--subpath tests/speed" { };
      newSrc = nixpkgs.pkgs.haskell.lib.doBenchmark (
        nixpkgs.haskell.lib.dontCheck (
          nixpkgs.haskell.lib.dontHaddock nixSrc
        )
      );
      preSrc = nixpkgs.haskell.lib.overrideCabal newSrc (old: {
        preConfigure = ''
                       sed -i -e s/benchmark/executable/ speed-tests.cabal
                       '';
      });
    in
      nixpkgs.myHaskellPackages.callPackage preSrc {
        random-fu     = nixpkgs.myHaskellPackages.random-fu;
        random-source = nixpkgs.myHaskellPackages.random-source;
      };

in

orig

And then running the performance suite by hand and generating charts by hand. It would be nice to automate this.

Possibly run the performance tests as part of CI?

Add doctests (I think this is already being done).