diff options
author | Franck Cuny <franck@fcuny.net> | 2022-08-15 17:46:32 -0700 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2022-08-15 17:51:52 -0700 |
commit | 2481d0d4cbf72b960361de5d06dc213f0723b4ac (patch) | |
tree | 24bc8ad1bf845668591bbb6479332c2ea972d8f3 | |
parent | fix(fmt): apply gofmt on some files (diff) | |
download | world-2481d0d4cbf72b960361de5d06dc213f0723b4ac.tar.gz |
ci(pre-commit): add a few more checks
Add a mechanism to run checks for go (fmt/mod tidy) and one for terraform. Fix the configuration for shellcheck (it was not checking the files). Change-Id: I1d250b96bd22838eddf624fda6b4d78d5da3e39f Reviewed-on: https://cl.fcuny.net/c/world/+/715 Tested-by: CI Reviewed-by: Franck Cuny <franck@fcuny.net>
Diffstat (limited to '')
-rw-r--r-- | flake.nix | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/flake.nix b/flake.nix index 76e6369..d10c736 100644 --- a/flake.nix +++ b/flake.nix @@ -52,7 +52,37 @@ let pkgs = import inputs.nixpkgs { inherit system; }; home-manager = inputs.home-manager.defaultPackage."${system}"; - ci = import ./ops/ci { inherit pkgs; }; + pre-commit-golang = pkgs.callPackage + ({ stdenv, fetchFromGitHub }: + stdenv.mkDerivation rec { + pname = "pre-commit-golang"; + version = "0.5.0-96221dc"; + src = fetchFromGitHub { + owner = "dnephin"; + repo = pname; + rev = "96221dc741cb30cc0136999083dc6bd0e2113000"; + sha256 = "sha256-lIQBoT+UIlVGnFaaGBgXag0Lm1UhGj/pIGlCCz91L4I="; + }; + dontBuild = true; + dontConfigure = true; + installPhase = '' + runHook preInstall + install -d $out + find . -type f -name 'run-*.sh' \ + | sed -E 's:^\./run-(.*)\.sh:\1:' \ + | xargs -I {} install ./run-{}.sh $out/{} + runHook postInstall + ''; + }) + { }; + pre-commit-golang-hook = name: { + "${name}" = { + inherit name; + enable = true; + entry = "${pre-commit-golang}/${name}"; + files = "\\.go$"; + }; + }; in rec { @@ -85,10 +115,18 @@ enable = true; }; + terraform-format = { + enable = true; + }; + shellcheck = { enable = true; + files = "\\.sh$"; + types_or = [ "file" ]; }; - }; + } + // (pre-commit-golang-hook "go-fmt") + // (pre-commit-golang-hook "go-mod-tidy"); }; }; |