Skip to content
Draft
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
20 changes: 20 additions & 0 deletions .github/actions/nix-setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Setup Nix and direnv
description: |
Sets up the Nix package manager and direnv to use the same packages
vendored through Nix for local development.
inputs:
github_token:
description: 'Github Access Token'
required: true
runs:
using: composite
steps:
- name: Install Nix package manager
uses: cachix/install-nix-action@v22
with:
github_access_token: ${{ inputs.github_token }}
extra_nix_config: |
experimental-features = nix-command flakes
- name: Set up Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v2
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,51 @@ jobs:
env:
DATABASE_URL: postgres://eventually:password@localhost:5432/eventually?sslmode=disable

nix-test:
name: Test [Nix]
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.required }}
strategy:
matrix:
build: [stable, nightly]
include:
- build: stable
required: true
toolchain: stable
- build: nightly
required: false
toolchain: nightly

services:
postgres:
env:
POSTGRES_USER: eventually
POSTGRES_PASSWORD: password
POSTGRES_DB: eventually
image: postgres:latest
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set up Nix system
uses: ./.github/actions/nix-setup
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Preload nix-develop shell
run: nix develop .#${{ matrix.toolchain }} --verbose -c echo "nix-develop shell loaded!"
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Run 'cargo test'
run: nix develop .#${{ matrix.toolchain }} --verbose -c cargo test --workspace --all-features
env:
DATABASE_URL: postgres://eventually:password@localhost:5432/eventually?sslmode=disable

coverage:
name: Code Coverage
runs-on: ubuntu-latest
Expand Down
43 changes: 39 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,55 @@

pkgs = import nixpkgs {
inherit system overlays;
config.allowBroken = true;
};

nativeBuildInputs = with pkgs; [ rust-bin.nightly.latest.default protobuf3_24 ];
nativeBuildInputs = with pkgs; [ protobuf3_24 ];

buildInputs = with pkgs; [ pkg-config openssl ] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.SystemConfiguration
];

packages = with pkgs; [
cargo-llvm-cov
];

defaultShell = with pkgs; mkShell {
inherit buildInputs packages;

nativeBuildInputs = with pkgs; nativeBuildInputs ++ [
rust-bin.nightly.latest.default
];

PROTOC = "${protobuf3_24}/bin/protoc";
};
in
with pkgs;
{
devShells.default = with pkgs; mkShell {
inherit nativeBuildInputs buildInputs;
devShells = rec {
default = nightly;

PROTOC = "${protobuf3_24}/bin/protoc";
nightly = with pkgs; mkShell {
inherit buildInputs packages;

nativeBuildInputs = with pkgs; nativeBuildInputs ++ [
rust-bin.nightly.latest.default
];

PROTOC = "${protobuf3_24}/bin/protoc";
};

stable = with pkgs; mkShell {
name = "stable";

inherit buildInputs packages;

nativeBuildInputs = with pkgs; nativeBuildInputs ++ [
rust-bin.stable.latest.default
];

PROTOC = "${protobuf3_24}/bin/protoc";
};
};
}
);
Expand Down