Skip to content

Commit

Permalink
ci: Use nix+cachix (#126)
Browse files Browse the repository at this point in the history
* Add cachix to actions

* run slt_runner via nix

* Remove slt-cehck

* Run tests in flake check using cargo-nextest

* add slt_runner build to check

* Add clippy failure

* Revert "Add clippy failure"

This reverts commit b395ff9.
  • Loading branch information
justinrubek authored Sep 27, 2022
1 parent 9fa25a8 commit 34a5eac
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 28 deletions.
36 changes: 12 additions & 24 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion flake-parts/apps/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion flake-parts/devshell/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
rustfmt
bacon
cargo-udeps
cargo-nextest
cocogitto
protobuf
gdb
miniserve
];

otherNativeBuildInputs = with pkgs; [pkgconfig openssl openssl.dev llvmPackages.bintools];
Expand Down
20 changes: 18 additions & 2 deletions flake-parts/packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
Expand All @@ -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;
Expand All @@ -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);
};
};
}

0 comments on commit 34a5eac

Please sign in to comment.