From d95c670ada3b9160e7066d7969f441daa0c2bc67 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Thu, 12 Sep 2024 14:54:56 +0200 Subject: [PATCH] Add nix test. (#2513) * Add nix test. * Modifying yourself means you need to rerun. * Fixing the test + adding click (needed for pre-commit hooks). * Try thuis. * Our runner + pure test (not written) * Reemove server. * Root user. * Different user ? * Add the actual test target. * Forgot this modification. * Add a formatter. * Add the secrets. * Fixed the auth token ? * Adding the other tests. * Missing pre-commit. * Test requires cargo for cargo fmt. * Update it a bit. * Up. * Attempting to use a cache location for the models. * Ignore the cache for now. --- .github/workflows/nix_tests.yaml | 41 ++++++++++++++++++++++++++++++++ flake.nix | 25 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/nix_tests.yaml diff --git a/.github/workflows/nix_tests.yaml b/.github/workflows/nix_tests.yaml new file mode 100644 index 00000000..f2209f8a --- /dev/null +++ b/.github/workflows/nix_tests.yaml @@ -0,0 +1,41 @@ +name: "Nix Tests" +on: + pull_request: + paths: + - ".github/workflows/nix_tests.yaml" + - "server/**" + - "proto/**" + - "router/**" + - "launcher/**" + - "Cargo.lock" + - "rust-toolchain.toml" +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + tests: + runs-on: + group: aws-highmemory-32-plus-priv + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v27 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: cachix/cachix-action@v14 + with: + name: text-generation-inference + # If you chose signing key for write access + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + env: + USER: github_runner + - name: Build + run: nix develop .#test --command echo "Ok" + - name: Pre-commit tests. + run: nix develop .#test --command pre-commit run --all-files + - name: Python tests. + run: nix develop .#test --command python -m pytest server/tests/ + env: + HF_TOKEN: ${{ secrets.HF_TOKEN }} + - name: Rust tests. + run: nix develop .#test --command cargo test diff --git a/flake.nix b/flake.nix index 5be413c5..c6adf0a6 100644 --- a/flake.nix +++ b/flake.nix @@ -69,6 +69,7 @@ server = pkgs.python3.pkgs.callPackage ./nix/server.nix { inherit nix-filter; }; in { + formatter = pkgs.nixfmt-rfc-style; devShells = with pkgs; rec { default = pure; @@ -80,6 +81,29 @@ server ]; }; + test = mkShell { + buildInputs = + [ + # benchmark + # launcher + # router + server + openssl.dev + pkg-config + cargo + rustfmt + clippy + ] + ++ (with python3.pkgs; [ + docker + pytest + pytest-asyncio + syrupy + pre-commit + ruff + ]); + + }; impure = mkShell { buildInputs = @@ -99,6 +123,7 @@ docker pip ipdb + click pyright pytest pytest-asyncio