Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Use nix+cachix #126

Merged
merged 7 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
};
};
}