Skip to content

Commit

Permalink
[EDNA-11] Add CI checks for Haskell code
Browse files Browse the repository at this point in the history
  • Loading branch information
sashasashasasha151 committed Feb 20, 2021
1 parent c7297d9 commit 49cba35
Show file tree
Hide file tree
Showing 7 changed files with 302 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
steps:
- label: check trailing whitespace
commands:
- .buildkite/check-trailing-whitespace.sh
- .buildkite/check-trailing-whitespace.sh
- label: backend build
commands:
- nix-build -A packages.x86_64-linux.backend
- label: backend lib
commands:
- nix-build -A packages.x86_64-linux.backend-lib
- label: backend test
commands:
- nix-build -A checks.x86_64-linux.backend-test
- label: backend hlint
commands:
- nix-build -A checks.x86_64-linux.backend-hlint
44 changes: 44 additions & 0 deletions backend/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{ haskell-nix, runCommand, lib }:
let
ignoreFilter = path: type:
let
inherit (lib) removePrefix hasPrefix hasSuffix;
relPath = removePrefix (toString ./. + "/") (toString path);
baseName = baseNameOf relPath;
in
!(
baseName == ".gitignore" ||
hasPrefix "resources" relPath ||
hasSuffix ".md" baseName ||
hasSuffix ".nix" baseName
);

# Set a constant name for the src closure
source = let
root = ./.;
in builtins.path {
name = "edna-backend-src";
path = root;
filter = name: type:
(ignoreFilter name type && lib.cleanSourceFilter name type);
};

project = haskell-nix.stackProject {
src = haskell-nix.haskellLib.cleanGit {
src = haskell-nix.cleanSourceHaskell { src = ./.; };
};
modules = [
{
doHaddock = true;
packages.edna = {
doHaddock = true;
package.ghcOptions = "-Werror";
};
}
];
};
library = project.edna.components.library;
server = project.edna.components.exes.edna-server;
test = project.edna.checks.edna-test;
hlint = runCommand "hlint.html" {} '' ${hlint}/bin/hlint ${source} --no-exit-code --report=$out -j '';
in { inherit server test library hlint; }
4 changes: 4 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(import (fetchTarball
"https://github.com/edolstra/flake-compat/archive/master.tar.gz") {
src = builtins.fetchGit ./.;
}).defaultNix
185 changes: 185 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
inputs = {
nixpkgs.url = "github:serokell/nixpkgs";
haskell-nix.url = "github:input-output-hk/haskell.nix";
hackage = {
url = "github:input-output-hk/hackage.nix";
flake = false;
};
stackage = {
url = "github:input-output-hk/stackage.nix";
flake = false;
};
common-infra.url = "github:serokell/common-infra";
};

outputs = { self, nixpkgs, haskell-nix, hackage, stackage, common-infra }:
let
packagesFor = system: rec {
pkgs = nixpkgs.legacyPackages.${system}.extend
(nixpkgs.lib.foldl nixpkgs.lib.composeExtensions (_: _: { }) [
haskell-nix.overlay
]);
backend = pkgs.callPackage ./backend { };
};
in {
packages = builtins.mapAttrs (system: _:
with packagesFor system; {
backend-lib = backend.library;
backend = backend.server // {
meta.modulePath = [ "services" "edna" "backend" ];
};
}) nixpkgs.legacyPackages;

ciSystems = [ "x86_64-linux" ];

checks = builtins.mapAttrs (system: _:
with packagesFor system; {
backend-test = backend.test;
backend-hlint = backend.hlint;
}) nixpkgs.legacyPackages;

pipelineFile = common-infra.mkPipelineFile self;

devShell = builtins.mapAttrs (system: packages:
let pkgs = nixpkgs.legacyPackages.${system};
in pkgs.mkShell {
inputsFrom = [ packages.backend-lib ];
buildInputs = with pkgs.haskellPackages; [ cabal-install hpack ];
}) self.packages;
};
}
1 change: 1 addition & 0 deletions pipeline.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(import ./.).pipelineFile
4 changes: 4 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(import (fetchTarball
"https://github.com/edolstra/flake-compat/archive/master.tar.gz") {
src = builtins.fetchGit ./.;
}).shellNix

0 comments on commit 49cba35

Please sign in to comment.