-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdevenv.nix
46 lines (43 loc) · 1.1 KB
/
devenv.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
pkgs,
lib,
config,
inputs,
...
}: let
flakePackage = import ./package.nix {inherit pkgs lib;};
in {
packages = [
pkgs.alejandra
pkgs.goreleaser
];
languages.nix.enable = true;
languages.go.enable = true;
# https://devenv.sh/tests/
enterTest = ''
go mod verify
goreleaser check
go test -coverprofile=cover.out $(go list ./... | grep -v /cmd | grep -v /claims | grep -v /team)
coverage=$(go tool cover -func=cover.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
if (( $(echo "$coverage < 25" | bc -l) )); then
echo "Test coverage is below 25s%: $coverage%"
exit 1
fi
echo "Test coverage is $coverage%"
'';
# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks = {
alejandra.enable = true;
gofmt.enable = true;
golangci-lint.enable = true;
govet.enable = true;
nix-run = {
name = "Verify package.nix hash";
enable = true;
pass_filenames = false;
files = "go.(mod|sum)$";
entry = "nix run .# -- --help";
};
};
# See full reference at https://devenv.sh/reference/options/
}