Skip to content

Commit

Permalink
add command go-tidy-all
Browse files Browse the repository at this point in the history
  • Loading branch information
lostbean committed Jul 10, 2024
1 parent ad42d22 commit 34f045b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
run: |
nix develop --command test -z $(gofmt -l .)
- name: Check Go tidiness
run: |
nix develop --command go-tidy-all && git diff-files --quiet
build_publish_images:
name: Test, build and publish images
needs: check_nix
Expand Down
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
packages.cli-kontrol-api = pkgs.callPackage ./libs/cli-kontrol-api/default.nix {
inherit pkgs;
};
packages.go-tidy-all = pkgs.callPackage ./scripts/go-tidy-all.nix {
inherit pkgs;
};

containers = let
os = "linux";
Expand Down
9 changes: 9 additions & 0 deletions scripts/go-tidy-all.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{pkgs, ...}:
pkgs.writeShellApplication {
name = "go-tidy-all";
runtimeInputs = with pkgs; [go git gomod2nix];
text = ''
root_dirpath=$(git rev-parse --show-toplevel)
find "$root_dirpath" -type f -name 'go.mod' -exec sh -c 'dir=$(dirname "$1") && cd "$dir" && echo "$dir" && go mod tidy && gomod2nix' shell {} \;
'';
}
7 changes: 0 additions & 7 deletions scripts/go-tidy-all.sh

This file was deleted.

3 changes: 3 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
nix run .#kardinal-cli -- "$@"
'';

go-tidy-all = import ./scripts/go-tidy-all.nix {inherit pkgs;};

manager_shell = pkgs.callPackage ./kardinal-manager/shell.nix {inherit pkgs;};
cli_shell = pkgs.callPackage ./kardinal-cli/shell.nix {inherit pkgs;};
cli_kontrol_api_shell = pkgs.callPackage ./libs/cli-kontrol-api/shell.nix {inherit pkgs;};
Expand All @@ -21,6 +23,7 @@
nativeBuildInputs = [bashInteractive bash-completion];
buildInputs = [
kardinal
go-tidy-all
kubectl
kustomize
kubernetes-helm
Expand Down

0 comments on commit 34f045b

Please sign in to comment.