diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 06187d96..4ce5d1fa 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -24,21 +24,25 @@ jobs: extraPullNames: holochain-ci authToken: ${{ secrets.CACHIX_HOLOCHAIN_WIND_TUNNEL }} + - name: Check scripts + run: | + nix develop --command bash -c "shellcheck scripts/*.sh" + - name: Check Nix formatting run: | - nix fmt ./nix flake.nix -- --check + nix develop .#ci --command bash -c "source ./scripts/checks.sh && check_nix_fmt" - name: Lint Nix run: | - nix develop --command bash -c "statix check ./nix && statix check ./flake.nix" + nix develop .#ci --command bash -c "source ./scripts/checks.sh && check_nix_static" - name: Check Rust formatting run: | - nix develop --command bash -c "cargo fmt --all -- --check" + nix develop .#ci --command bash -c "source ./scripts/checks.sh && check_rust_fmt" - name: Lint Rust run: | - nix develop --command bash -c "cargo clippy --workspace --all-targets --all-features -- -D warnings" + nix develop --command bash -c "source ./scripts/checks.sh && check_rust_static" - name: Unit tests run: | @@ -80,7 +84,3 @@ jobs: # pkill hc # pkill holochain # pkill lair-keystore - - - name: Check scripts - run: | - nix develop --command bash -c "shellcheck scripts/*.sh" diff --git a/flake.nix b/flake.nix index b2af06e8..66565bd1 100644 --- a/flake.nix +++ b/flake.nix @@ -44,6 +44,7 @@ inputsFrom = [ inputs.holochain.devShells.${system}.holonix ]; + packages = [ pkgs.influxdb2-cli pkgs.influxdb2-server @@ -58,9 +59,21 @@ shellHook = '' source ./scripts/influx.sh source ./scripts/telegraf.sh + source ./scripts/checks.sh ''; }; + devShells.ci = pkgs.mkShell { + inputsFrom = [ + inputs.holochain.devShells.${system}.holochainBinaries + ]; + + packages = [ + pkgs.shellcheck + pkgs.statix + ]; + }; + apps = builtins.listToAttrs (builtins.map (name: { inherit name; value = { program = self'.packages.${name}; }; }) scenario_package_names); }; }; diff --git a/scripts/checks.sh b/scripts/checks.sh new file mode 100644 index 00000000..3967d5bd --- /dev/null +++ b/scripts/checks.sh @@ -0,0 +1,22 @@ +check_nix_fmt() { + nix fmt ./nix flake.nix -- --check +} + +check_nix_static() { + statix check ./nix && statix check ./flake.nix +} + +check_rust_fmt() { + cargo fmt --all -- --check +} + +check_rust_static() { + cargo clippy --workspace --all-targets --all-features -- -D warnings +} + +check_all() { + check_nix_fmt + check_nix_static + check_rust_fmt + check_rust_static +}