Skip to content

Commit

Permalink
nixify, bump versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranshila committed Apr 5, 2024
1 parent 539043f commit bb400e4
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 67 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake .
121 changes: 59 additions & 62 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,72 @@
on: push
name: CI
name: Check and build the library using Nix
on:
push:
branches:
- main
tags:
- "v*.*.*"
pull_request:
branches:
- main

jobs:
lint:
name: Lint
check:
name: Check/Lint
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
# We need nightly for fmt
toolchain: nightly
override: true
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v1
- name: Lint (clippy)
uses: actions-rs/cargo@v1
- name: git checkout
uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Check Nixpkgs inputs
uses: DeterminateSystems/flake-checker-action@main
with:
command: clippy
args: --all-targets --all-features
- name: Lint (rustfmt)
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --check
fail-mode: true

# Nix-specific logic begins here
- name: Check Rust formatting
run: |
nix develop --command cargo fmt --all --check
- name: Check Clippy lints
run: |
nix develop --command cargo clippy --all-targets
- name: Check spelling
run: |
nix develop --command \
codespell \
--skip target,.git \
--ignore-words-list crate
build:
name: Build and test
# We don't need to build on windows, do we?
test_and_build:
name: Test and build library
needs: check
runs-on: ubuntu-latest
strategy:
matrix:
rust-version: [stable, 1.57, nightly]
fail-fast: false
env:
RUSTFLAGS: -D warnings
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
override: true
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v1
- name: Build all targets with all features
uses: actions-rs/cargo@v1
with:
command: build
args: --all-targets --all-features
- name: Doctests
uses: actions-rs/cargo@v1
with:
command: test
args: --doc --all-features
- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: Test with latest nextest release
uses: actions-rs/cargo@v1
- name: git checkout
uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Set up Rust cache
uses: actions/cache@v3
with:
command: nextest
args: run --all-features
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: sigproc_filterbank-${{ hashFiles('**/Cargo.lock') }}
- name: Test library
run: |
nix develop --command cargo test
- name: Build library
run: |
nix develop --command cargo build
- name: Generate code coverage
if: startsWith(matrix.rust-version, 'stable')
run: cargo llvm-cov nextest --all-features --workspace --lcov --output-path lcov.info
run: nix develop --command cargo llvm-cov --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
if: startsWith(matrix.rust-version, 'stable')
uses: codecov/codecov-action@v3
with:
files: lcov.info
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/Cargo.lock
.direnv
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sigproc_filterbank"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
rust-version = "1.57.0"
license = "Apache-2.0 OR MIT"
Expand All @@ -9,10 +9,9 @@ description = "A parser and serializer for SIGPROC pulsar filterbank files"
homepage = "https://github.com/kiranshila/sigproc_filterbank"
readme = "README.md"
keywords = ["astronomy", "parser", "pulsars"]
categories = ["encoding","parser-implementations"]

categories = ["encoding", "parser-implementations"]

[dependencies]
nom = "7.1"
thiserror = "1.0"
nom = "7"
thiserror = "1"
ux = "0.1"
85 changes: 85 additions & 0 deletions flake.lock

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

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

outputs = {
nixpkgs,
flake-utils,
rust-overlay,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {inherit system overlays;};

runCiLocally = pkgs.writeScriptBin "ci-local" ''
echo "Checking Rust formatting..."
cargo fmt --check
echo "Checking clippy..."
cargo clippy --all-targets
echo "Testing Rust code..."
cargo test
'';

nativeBuildInputs = with pkgs; [];
buildInputs =
[runCiLocally]
++ (with pkgs; [
# Rust stuff, some stuff dev-only
(rust-bin.nightly.latest.default.override {
extensions = ["rust-src" "rust-analyzer"];
})

# Linting support
alejandra
]);
in
with pkgs; {
devShells.default = mkShell {inherit buildInputs nativeBuildInputs;};
});
}

0 comments on commit bb400e4

Please sign in to comment.