Skip to content

Commit

Permalink
Merge pull request #131 from urbit/eamsden/nix-ci
Browse files Browse the repository at this point in the history
Use Nix shell in CI
  • Loading branch information
ashelkovnykov authored Nov 23, 2023
2 parents 4052339 + 3dc74f7 commit e2d8e90
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 252 deletions.
32 changes: 19 additions & 13 deletions .github/workflows/ares-shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:

env:
CARGO_TERM_COLOR: always
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"

defaults:
run:
Expand All @@ -14,29 +15,34 @@ jobs:
steps:
- uses: actions/checkout@v3

# Makes it easier to determine why CI might differ from local linter/build
#
- name: Version
run: rustc --version
# Install nix, required by nix-shell-action
- uses: cachix/install-nix-action@v23
name: Install Nix
with:
extra_nix_config: "extra-experimental-features = nix-command flakes"

# Check formatting
- name: Format
run: cargo fmt --check
run: |
nix develop --command bash -c "cargo fmt --check"
# See clippy linter docs: https://github.com/rust-lang/rust-clippy
#
# First linter is set to fail for all warnings, then ignored warnings are
# explicitly listed
#
# XX TODO make a script with all the flags for the linter
- name: Lint
run: |
cargo clippy \
--all-targets \
--no-deps \
-- -D warnings \
-A clippy::missing_safety_doc
nix develop --command bash -c "cargo clippy --all-targets --no-deps -- -D warnings -A clippy::missing_safety_doc"
# Build Ares
- name: Build
run: cargo build --release --verbose --features check_all
run: |
nix develop --command bash -c "cargo build --release --verbose --features check_all"
# Run tests
- name: Test
run: |
nix develop --command bash -c "cargo test --verbose -- --test-threads=1"
- name: Run tests
run: cargo test --verbose -- --test-threads=1
100 changes: 100 additions & 0 deletions rust/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions rust/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {self, fenix, flake-utils, nixpkgs}:
let supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-darwin"];
in flake-utils.lib.eachSystem supportedSystems
(system:
let pkgs = import nixpkgs { inherit system; };
in { devShells.default = pkgs.mkShell {
buildInputs = [
(fenix.packages.${system}.complete.withComponents [
"cargo"
"clippy"
"rustc"
"rustfmt"
"rust-src"
])
pkgs.cargo-watch
pkgs.gdb
pkgs.iconv
];
};
}
);
}

26 changes: 0 additions & 26 deletions rust/nix/sources.json

This file was deleted.

Loading

0 comments on commit e2d8e90

Please sign in to comment.