From 7a799868fb9874fa33f7a09f804c91eed18af663 Mon Sep 17 00:00:00 2001 From: trev Date: Thu, 17 Apr 2025 07:33:41 -0400 Subject: [PATCH] feat: nix checks --- .github/workflows/lint.yaml | 28 ++----------------- .scripts/lint.sh | 23 ---------------- flake.nix | 54 +++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 49 deletions(-) delete mode 100755 .scripts/lint.sh diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 47c06b1..1593e1f 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -24,29 +24,5 @@ jobs: name: trevstack authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - name: Install NPM Packages - working-directory: ./client - run: npm i && npm ci # https://github.com/npm/cli/issues/7793 - - - uses: nicknovitski/nix-develop@v1 - - - run: npx prettier --check . - working-directory: ./client - - - run: npx eslint . - working-directory: ./client - - - run: npx svelte-check - working-directory: ./client - - - run: revive -config revive.toml -set_exit_status ./... - working-directory: ./server - - - run: sqlfluff lint - working-directory: ./server - - - run: buf lint - - - run: nix fmt -- flake.nix --check - - - run: nix flake check --all-systems \ No newline at end of file + - name: Run checks + run: nix flake check --all-systems \ No newline at end of file diff --git a/.scripts/lint.sh b/.scripts/lint.sh deleted file mode 100755 index 9f1e390..0000000 --- a/.scripts/lint.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -git_root=$(git rev-parse --show-toplevel) - -echo "linting client" -cd "${git_root}/client" -npx prettier --check . -npx eslint . -npx svelte-check - -echo "linting server" -cd "${git_root}/server" -revive -config revive.toml -set_exit_status ./... -sqlfluff lint - -echo "linting protobuf" -cd "${git_root}" -buf lint - -echo "linting nix" -cd "${git_root}" -nix fmt -- flake.nix --check -nix flake check --all-systems \ No newline at end of file diff --git a/flake.nix b/flake.nix index f630500..699f617 100644 --- a/flake.nix +++ b/flake.nix @@ -92,6 +92,60 @@ }; }); + checks = forSystem ({pkgs, ...}: { + buf = with pkgs; + runCommandLocal "check-buf" { + nativeBuildInputs = with pkgs; [ + buf + ]; + } '' + export HOME=$(pwd) + cd ${./.} + buf lint + touch $out + ''; + + nix = with pkgs; + runCommandLocal "check-nix" { + nativeBuildInputs = with pkgs; [ + alejandra + ]; + } '' + cd ${./.} + alejandra -c . + touch $out + ''; + + client = with pkgs; + buildNpmPackage { + pname = "check-client"; + inherit version; + src = ./client; + npmDepsHash = "sha256-u7zkBgaxDEB2XFrNl0f7/HtW0Oy2B7FVPot9MLPzXGc="; + dontNpmInstall = true; + + buildPhase = '' + npx prettier --check . + npx eslint . + npx svelte-kit sync && npx svelte-check + touch $out + ''; + }; + + server = with pkgs; + runCommandLocal "check-server" { + nativeBuildInputs = with pkgs; [ + revive + sqlfluff + ]; + } '' + cd ${./server} + revive -config revive.toml -set_exit_status ./... + sqlfluff lint + touch $out + ''; + }); + formatter = forSystem ({pkgs, ...}: pkgs.alejandra); packages = forSystem ({pkgs, ...}: rec {