diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f14384262..a160837da 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,32 +15,20 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - uses: abelfodil/protoc-action@v1 + - name: Install nix + uses: cachix/install-nix-action@v15 with: - protoc-version: '21.5' + extra_nix_config: | + access-tokens = github=${{ github.token }} - # Taken from: https://github.com/actions/cache/blob/main/examples.md#rust---cargo - - uses: actions/cache@v3 + - name: configure cachix + uses: cachix/cachix-action@v10 with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - name: Configure toolchain - uses: dtolnay/rust-toolchain@stable - - - name: Unit tests - run: cargo test - - - name: Clippy - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features -- -D warnings + name: glaredb + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + + - name: run checks + run: nix flake check - name: SQL Logic Tests - run: cargo run --bin slt_runner -- testdata/sqllogictests/*.slt + run: nix run .#slt_runner testdata/sqllogictests/*.slt diff --git a/.github/workflows/image.yaml b/.github/workflows/image.yaml index 29677007e..193507af2 100644 --- a/.github/workflows/image.yaml +++ b/.github/workflows/image.yaml @@ -28,6 +28,12 @@ jobs: extra_nix_config: | access-tokens = github=${{ github.token }} + - name: configure cachix + uses: cachix/cachix-action@v10 + with: + name: glaredb + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Authenticate to Google Cloud uses: google-github-actions/auth@v0 with: diff --git a/flake-parts/apps/default.nix b/flake-parts/apps/default.nix index 4710fcfdb..6ac4ae628 100644 --- a/flake-parts/apps/default.nix +++ b/flake-parts/apps/default.nix @@ -12,7 +12,11 @@ apps = { cli = { type = "app"; - program = "${self.packages.${system}.cli}/bin/main"; + program = "${self.packages.${system}.cli}/bin/glaredb"; + }; + slt_runner = { + type = "app"; + program = "${self.packages.${system}.slt_runner}/bin/slt_runner"; }; default = apps.cli; }; diff --git a/flake-parts/devshell/default.nix b/flake-parts/devshell/default.nix index 65fb675f2..90defce8f 100644 --- a/flake-parts/devshell/default.nix +++ b/flake-parts/devshell/default.nix @@ -17,10 +17,10 @@ rustfmt bacon cargo-udeps + cargo-nextest cocogitto protobuf gdb - miniserve ]; otherNativeBuildInputs = with pkgs; [pkgconfig openssl openssl.dev llvmPackages.bintools]; diff --git a/flake-parts/packages/default.nix b/flake-parts/packages/default.nix index e8602045a..2d86c1b99 100644 --- a/flake-parts/packages/default.nix +++ b/flake-parts/packages/default.nix @@ -18,16 +18,21 @@ inputs'.fenix.packages.stable.toolchain; common-build-args = rec { + # crane arguments src = lib.cleanSourceWith { src = ../..; filter = self.lib.filterSrc craneLib; }; + pname = "glaredb"; + # application config arguments buildInputs = otherBuildInputs; nativeBuildInputs = otherNativeBuildInputs; + # clang LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; BINDGEN_EXTRA_CLANG_ARGS = "-isystem ${pkgs.llvmPackages.libclang.lib}/lib/clang/${lib.getVersion pkgs.clang}/include"; LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + # protobuf compilation PROTOC = "${pkgs.protobuf}/bin/protoc"; PROTOC_INCLUDE = "${pkgs.protobuf}/include"; }; @@ -40,15 +45,20 @@ cargoClippyExtraArgs = "--all-features -- --deny warnings"; } // common-build-args); + tests-check = craneLib.cargoNextest ({ + inherit cargoArtifacts; + partitions = 1; + partitionType = "count"; + } // common-build-args); in rec { checks = { - inherit clippy-check; + inherit clippy-check tests-check; build-crate = packages.default; + build-sltrunner = packages.slt_runner; }; packages = { default = packages.cli; - # cli = craneLib.cargoBuild ({ cli = craneLib.buildPackage ({ pname = "glaredb-cli"; inherit cargoArtifacts; @@ -61,6 +71,12 @@ created = "now"; config.Cmd = ["${packages.cli}/bin/glaredb"]; }; + + slt_runner = craneLib.buildPackage ({ + pname = "glaredb-slt-runner"; + inherit cargoArtifacts; + cargoExtraArgs = "--bin slt_runner"; + } // common-build-args); }; }; }