feat(depotfmt): run formatting checks in CI
Right now this only includes Go, but more is to come. Change-Id: Idd8fc27c0eb25e82688ef8337ba20810d834f4b6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4504 Reviewed-by: zseri <zseri.devel@ytrizja.de> Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI Autosubmit: tazjin <mail@tazj.in>
This commit is contained in:
parent
9c61d64a11
commit
4c23a9c1d4
1 changed files with 19 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
|||
# Builds treefmt for depot, with a hardcoded configuration that
|
||||
# includes the right paths to formatters.
|
||||
{ pkgs, ... }:
|
||||
{ depot, pkgs, ... }:
|
||||
|
||||
let
|
||||
config = pkgs.writeText "depot-treefmt-config" ''
|
||||
|
@ -14,8 +14,21 @@ let
|
|||
options = [ "fmt" ]
|
||||
includes = [ "*.tf" ]
|
||||
'';
|
||||
in pkgs.writeShellScriptBin "depotfmt" ''
|
||||
exec ${pkgs.treefmt}/bin/treefmt ''${@} \
|
||||
--config-file ${config} \
|
||||
--tree-root $(${pkgs.git}/bin/git rev-parse --show-toplevel)
|
||||
''
|
||||
|
||||
# helper tool for formatting the depot interactively
|
||||
depotfmt = pkgs.writeShellScriptBin "depotfmt" ''
|
||||
exec ${pkgs.treefmt}/bin/treefmt ''${@} \
|
||||
--config-file ${config} \
|
||||
--tree-root $(${pkgs.git}/bin/git rev-parse --show-toplevel)
|
||||
'';
|
||||
|
||||
# wrapper for running formatting checks in CI
|
||||
check = pkgs.runCommandNoCC "depotfmt-check" {} ''
|
||||
${pkgs.git}/bin/git clone ${depot.path.origSrc} depot
|
||||
export HOME="$(${pkgs.coreutils}/bin/realpath .)"
|
||||
${pkgs.treefmt}/bin/treefmt \
|
||||
--fail-on-change \
|
||||
--config-file ${config} \
|
||||
--tree-root depot && : > $out
|
||||
'';
|
||||
in depotfmt // depot.nix.readTree.drvTargets { inherit check; }
|
||||
|
|
Loading…
Reference in a new issue