generated from serokell/metatemplates
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EDNA-11] Add CI checks for Haskell code
- Loading branch information
1 parent
c7297d9
commit 49cba35
Showing
7 changed files
with
302 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(import ./.).pipelineFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |